-
Notifications
You must be signed in to change notification settings - Fork 9
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
does not use pre-existing source map #27
Comments
How did you configure it? I just tested it, and the source map it generates restores the original ts code in the browser. |
@duan602728596 Did you compile TS to JS then through Terser using Gulp? Would you mind sharing a sample Gulpfile that does this if you did? From looking at the code, it really doesn't seem like the function es(){
return gulp.src('./src/**/*.js')
.pipe(sourcemaps.init())
.pipe(terser({
sourceMap: {
content: function(inputFilePath) {
return inputFilePath + '.orig.map';
}
}
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build'));
} This is something like what gulp-sourcemaps does. I think it needs to be a function because you can't have a static input source map like if you were using it directly. |
Gulp's sourcemaps use vinyl-sourcemaps-apply. If you want to add sourcemaps, sourcemaps must have file attribute. function es(){
return gulp.src('./src/**/*.js')
.pipe(sourcemaps.init())
.pipe(terser(async function(opt) {
return {
sourceMap: {
content: ''
}
}
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build'));
} But I still recommend that if you want to modify sourcemaps, you can use gulp-sourcemaps to modify. |
I am trying to use gulp-terser to run terser against js files that were compiled from TypeScript. The TypeScript compiler generated sourcemaps when it ran, and in this source map, "sources" lists my .ts file, as I would expect. When gulp-terser runs, however, it's as if the source map is generated from scratch. "sources" ends up listing the .js file instead of the original .ts file as expected.
Looking at the code, I don't see terser's sourceMap.content being set from chunk.sourceMap. Only sourceMap.filename is set. The terser doc says "The value of filename is only used to set file attribute (see the spec) in source map file.... If you're compressing compiled JavaScript and have a source map for it, you can use sourceMap.content".
Does this plugin support source maps that were previously loaded?
The text was updated successfully, but these errors were encountered: