-
Notifications
You must be signed in to change notification settings - Fork 87
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-sourcemap support #94
Conversation
file: file.path | ||
} | ||
}); | ||
instrumenter = new opts.instrumenter(fileOpts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just extend the options in the if
statement. Then there's no need to do extra logic with the instrumenter as it'll just take in the options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before my changes, the instrumenter was created once for all files in the stream. My reasoning was that creating it might potentially be expensive. Thus, I wanted to only create a new instrumenter for each file if it’s really necessary (because we need to change its options).
Would you prefer something like this?:
var fileOpts = opts;
if (file.sourceMap) {
fileOpts = _.defaultsDeep(_.cloneDeep(opts), {
codeGenerationOptions: {
sourceMap: file.sourceMap.file,
sourceMapWithCode: true,
sourceContent: fileContents,
sourceMapRoot: file.sourceMap.sourceRoot,
file: file.path
}
});
var instrumenter = new opts.instrumenter(fileOpts);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that would be cleaner IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Awesome thanks! |
Escodegen can generate sourcemaps. This is extremely helpful, because it allows to debug instrumented code in the browser.
This PR uses escodegen’s sourcemap feature if the user uses
gulp-sourcemap
and emits the map accodingly.This change is