With an application I'm currently developing I am also learning Gulp and using source maps. The application is a hybrid of Typescript and Javascript. The files are concatenated and minified. When passing the files through gulp-uglify
an error occurs:
\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-consumer.js:415
throw new Error('"' + aSource + '" is not in the SourceMap.');
^
Error: "Common.ts" is not in the SourceMap.
at SourceMapConsumer_sourceContentFor [as sourceContentFor] (Z:\Dev\financial-app\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-consumer.js:415:13)
at SourceMapGenerator.<anonymous> (Z:\Dev\financial-app\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-generator.js:233:42)
at Array.forEach (native)
This only happens when using gulp-sourcemaps
. When I remove the source map generation calls in the pipeline the issue doesn't occur but then I don't have any of the source maps either.
return merge(
// TS compile
gulp.src(filePath.appjs.src.ts)
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write()),
// JS compile
gulp.src(filePath.appjs.src.js)
)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('appscripts.js'))
.pipe(size({ title: 'APPJS' }))
.pipe(sourcemaps.write())
.pipe(gulp.dest(filePath.appjs.dest))
//.pipe(uglify(filePath.uglifyOptions))
.pipe(concat('appscripts.min.js'))
.pipe(size({ title: 'APPJS minified' }))
.pipe(gulp.dest(filePath.appjs.dest));
Perhaps useful to know, the typescript is to be found in ./js/ts/
and the javascript in ./js/App
.