init({ loadMaps: true }) does not remove sourcemaps added earlier in the same pipeline
See original GitHub issueIf a sourcemap is written, and then subsequently loaded and written again in the same pipeline, then the final output contains both sourcemaps.
For example, given the following input file (test.es6.js
):
let value = 'Test Value';
console.log(`value: ${ value }`);
When running the following Gulp script:
import gulp from 'gulp';
import gulpBabel from 'gulp-babel';
import gulpRename from 'gulp-rename';
import gulpSourcemaps from 'gulp-sourcemaps';
gulp.task('test.es5.js', [], () => {
return gulp.src('test.es6.js')
.pipe(gulpSourcemaps.init())
.pipe(gulpBabel())
.pipe(gulpRename('test.es5.js'))
.pipe(gulpSourcemaps.write())
.pipe(gulpSourcemaps.init({ loadMaps: true }))
.pipe(gulpSourcemaps.write())
.pipe(gulp.dest('.'))
});
Then the following output is produced (test.es5.js
):
'use strict';
var value = 'Test Value';
console.log('value: ' + value);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZXM2LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBSSxRQUFRLFlBQVo7O0FBRUEsUUFBUSxHQUFSLGFBQXVCLEtBQXZCIiwiZmlsZSI6InRlc3QuZXM1LmpzIiwic291cmNlc0NvbnRlbnQiOlsibGV0IHZhbHVlID0gJ1Rlc3QgVmFsdWUnO1xuXG5jb25zb2xlLmxvZyhgdmFsdWU6ICR7IHZhbHVlIH1gKTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZXM2LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBSSxRQUFRLFlBQVo7O0FBRUEsUUFBUSxHQUFSLGFBQXVCLEtBQXZCIiwiZmlsZSI6InRlc3QuZXM1LmpzIiwic291cmNlc0NvbnRlbnQiOlsibGV0IHZhbHVlID0gJ1Rlc3QgVmFsdWUnO1xuXG5jb25zb2xlLmxvZyhgdmFsdWU6ICR7IHZhbHVlIH1gKTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
If the pipeline is separated into two stages, with the file being output via gulp.dest()
after the first sourcemap is written and then a new pipeline is created via gulp.src()
, then the first sourcemap is removed as expected:
'use strict';
var value = 'Test Value';
console.log('value: ' + value);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuZXM2LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBSSxRQUFRLFlBQVo7O0FBRUEsUUFBUSxHQUFSLGFBQXVCLEtBQXZCIiwiZmlsZSI6InRlc3QuZXM1LnN0ZXAtMi5qcyIsInNvdXJjZXNDb250ZW50IjpbImxldCB2YWx1ZSA9ICdUZXN0IFZhbHVlJztcblxuY29uc29sZS5sb2coYHZhbHVlOiAkeyB2YWx1ZSB9YCk7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:12
Top Results From Across the Web
Remove Source Mapping with Gulp - Stack Overflow
task('jquery', function () { gulp.src(paths.jquerySrc) .pipe(sourcemaps.init({loadMaps: true})) .
Read more >gulp-relative-sourcemaps-source - npm
Converts paths to files with the sourcemaps content to be relative to the source file directory.. Latest version: 1.1.1, last published: 4 ...
Read more >4 Reasons Why Your Source Maps are Broken - Sentry Blog
This likely means that your source map doesn't contain or link to your original source files. Without your original source files, you're still ......
Read more >Documentation - Gulp - TypeScript
Before we get to Browserify, let's build our code out and add modules to the mix. This is the structure you're more likely...
Read more >Pinpoint Those Pesky Minified Javascript Errors With Sentry
One way to tackle this is to set up a VPN so these are not accessible anywhere ... writes source maps .pipe(sourcemaps.init({ loadMaps:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same problem:
This ended with a
map/index.js.map
file along with an inline sourcemap so the external.map
file would never be used.Another task includes an uglify step and it output the
.map
file and a correctsourceMappingURL
The essential difference is the
uglify
stepIn my case downgrading to 2.2.0 resolved this issue!