When trying to load my app on an iOS device I get the following error;
VMundefined bundle.js:1722 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.
This error occurred on iPhone 5s/6s + a couple of different iPad's I tried (can't remember which). It also did not work on the HTC one. This error did not occur on any samsung/windows phones I tried. It also worked on desktops. (I have not tried to run it on a mac yet).
Here is that line of code from the bundle.js;
{}],12:[function(require,module,exports){
"use strict";
const guage_1 = require("./charts/kpi/guage");
const stacked_1 = require("./charts/area/stacked");
const barChart_1 = require("./charts/compare/barChart");
When I remove the "use strict" from the bundle.js it works fine on all devices. Just wondering if there is a way to make sure typescript does not compile with "use strict" or a fix for the problem with iOS devices?
Here is my gulpfile for compiling (followed the guide published on typescripts website)
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
source = require('vinyl-source-stream'),
tsify = require('tsify'),
browserSync = require('browser-sync'),
postcss = require('gulp-postcss'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
watchify = require("watchify"),
browserify = require('browserify'),
gutil = require("gulp-util"),
buffer = require('vinyl-buffer'),
processorArray = [
...
],
watchedBrowserify = watchify(browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
}).plugin(tsify)),
devPlugin = './src/plugins/';
function bundle() {
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
}
gulp.task('default', ['styles', 'browser-sync', 'watch'], bundle, function() {
return browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.transform("babelify")
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
});
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);