combining sourcemaps over two gulp tasks yields hard to read maps
See original GitHub issuegulp-sourcemaps version: 1.6.0 & 2.1.1
I have the following Gulp tasks:
gulp.task('compile-client-scripts', () => {
return gulp.src(["!src/client/scripts/client.js", "src/client/scripts/**/*.js"])
.pipe(sourcemaps.init())
.pipe(babel({moduleIds: true}))
.pipe(sourcemaps.write("."))
.pipe(print())
.pipe(gulp.dest("src/client/lib"));
});
gulp.task('concat-compiled-client-scripts', ['compile-client-scripts'], () => {
return gulp.src("src/client/lib/**/*.js")
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat("client.js"))
.pipe(sourcemaps.write("."))
.pipe(print())
.pipe(gulp.dest("src/client/scripts"));
});
The final sourcemap map to the right places in code, but it generates a hard-to-read structure in the browser’s (both FF and Chrome) devtools.
Do I have to specify another option to fix this or is what I want just not possible?
Edit: What I want to achieve as result:
The following Gulp task (Basically both above combined) generates the result below:
gulp.task('debug-client-scripts', () => {
return gulp.src(["!src/client/scripts/client.js", "src/client/scripts/**/*.js"])
.pipe(sourcemaps.init())
.pipe(babel({moduleIds: true}))
.pipe(concat("client.js"))
.pipe(sourcemaps.write("."))
.pipe(print())
.pipe(gulp.dest("src/client/scripts"));
});
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:13
Top Results From Across the Web
Gulp + source maps (multiple output files) - Stack Overflow
This task will take multiple files, do stuff to them, and output them along with source maps. It will include the source code...
Read more >CoffeeScript
-m, --map, Generate source maps alongside the compiled JavaScript files. ... There are many great task runners for setting up JavaScript build chains, ......
Read more >A complete toolchain for AngularJs - Gulp, Browserify, Sass
In this blog post we will propose a set of tools that a new Angular project will likely need, and present a simple...
Read more >gulp-jumpscript - npm Package Health Analysis | Snyk
Learn more about gulp-jumpscript: package health score, popularity, ... Instead, create multiple projects or use a single task to compile your sources.
Read more >Source Maps - SurviveJS
Source map types supported by webpack can be split into two categories: ... Thanks to their speed, inline source maps are ideal for...
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
@plamens @Nimelrian I think this has to deal with more of how your using gulp. gulp-sourcemaps and gulp are doing exact what you are telling them to do in you example.
The main issue is that when you run the task
compile-source-scripts
it keeps the folder integrity in the destination. Then you run gulp again on the source destination thus doubling the folder hierarchy. The simple solution is to flatten the files in thecompile-source-scripts
task.example.tar
Code:
I also observed that with gulp-sourcemaps 2.1.1. The problem is that paths in the properties of the generated sourceMap are relative to the base of the project, just like gulp-sourcemaps docs say.
For example: if the file ./subdir/main.ts is transpiled, the output source map will have the following property: “sources”:[“subdir/main.ts”]
When the next build task inits a sourcemap with loadMaps: true and loads this file, it will think that the sources property is relative to the sourceMap, so it will just append it to the path to the sourceMap. This happens at https://github.com/floridoo/gulp-sourcemaps/blob/master/src/init.js#L86 Thus, a part of the path will be duplicated and the sourceMap from the output of the second build task will have: “sources”:[“subdir/subdir/main.ts”]
Here is an example project with 2 simple build tasks, one transpiles a typescript file and the other does a gulp-concat with just this file: example-project.zip