-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gulp V4 need advanced sourcemap settings #2288
Comments
tsProject subverts many of our conventions. We can't really help you if they break our sourcemap integration. |
Please reopen this issue. It's not about TS. You can reproduce the issue with babel too. In fact, you can reproduce the issue without any transpiling step. It's a gulp issue. https://github.com/3cp/gulp-sm-demo gulp.src('src/**/*.js', {sourcemaps: true})
.pipe(gulp.dest('dist', {sourcemaps: '.'})); In this tiny demo, there are two files in src/folder: Because of the extra folder under {
"version":3,
"names":[],
"mappings":""
,"sources":["foo/index.js"],
"sourcesContent":["module.exports = \"Hello Foo\";\n"],
"file":"foo/index.js"
} For an app that uses this npm module, it thinks:
This can be fixed by using https://github.com/3cp/gulp-sm-demo/tree/gulp-sourcemaps gulp.src('src/**/*.js', {sourcemaps: true})
.pipe(gulpSourcemaps.write('.', {
sourceRoot: '../src/'
}))
.pipe(gulp.dest('dist')); gulp-sourcemaps smartly does
So the default gulp v4 sourceMap offering is incorrect in term of source path. But this can be fixed in gulp v4 gracefully because the sourceMap writing is handled by I can try to make a PR if this makes sense. |
@3cp Thanks for your good reproduction codes. I'm trying to solve this issue. |
@3cp it was never intended that gulp support the full set of gulp-sourcemaps options. Gulp just loads the initial sourcemaps and writes the final ones to disk—this is to avoid any filesystem calls within the middle of a pipeline. If you want extra features, you can reach for an For your sourceRoot example, it looks like the gulp-sourcemaps team hasn't had the chance to implement a separate plugin for that yet. If you want to help, or just ask for it to be created, I'd suggest visiting gulp-sourcemaps/gulp-sourcemaps#285 If you think there is a bug in gulp on how source paths are calculated, please open an issue (with a test case) at https://github.com/gulpjs/vinyl-sourcemap |
Sure, I understand. I will do some study and try to open an issue on vinyl-sourcemap. One thing I noticed, is that gulp-sourcemaps without explicit sourceRoot option behaves exactly like gulp v4 built-in sourceMap support. Both did not care about the duplicated source path segments. I thought it probably makes more sense to get a correct default behaviour (for both gulp-sourcemaps and gulp v4 built-in). gulp v4 doesn't need to have any new features or new options to get this right, gulp.src and gulp.dest got enough information to make it right out of the box. |
@3cp vinyl-sourcemap was created using gulp-sourcemap code as a basis. If there was a bug in gulp-sourcemaps, it would be present in vinyl-sourcemap as well. |
As of new Gulp v4 I can get rid of gulp-sourcemaps plugin.
As far as I know Gulp v4 uses its own sourcemap.
I refactored my project to use Gulp v4 sourcemap, however I am missing advanced settings in sourcemap.
I have following project structure:
As you can see after typescript compilation all files that were in
src/*.ts
goes intodist/*.js
.Path from generated
*.map
file to original*.ts
file is incorect. It is correct only for one nested level.I need correct path for debug in VSCode.
E.g. path from
app.bot.js.map
toapp.bot.ts
is correct:E.g. path from
authorize.js.map
toauthorize.ts
is invalid:With gulp-sourcemaps plugin I managed to do correct path as following:
With Gulp v4 sourcemap I can not do above example, right now I have this (but it does not help):
Is there any possibility to setup advanced settings for Gulp v4 sourcemap (so it will generate correct sourcemap path)?
The text was updated successfully, but these errors were encountered: