Skip to content
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

Merged
merged 4 commits into from
Jun 10, 2016
Merged

gulp-sourcemap support #94

merged 4 commits into from
Jun 10, 2016

Conversation

jGleitz
Copy link
Contributor

@jGleitz jGleitz commented Jun 8, 2016

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 Reviewable

file: file.path
}
});
instrumenter = new opts.instrumenter(fileOpts);
Copy link
Owner

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.

Copy link
Contributor Author

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);

Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@SBoudrias SBoudrias merged commit 8a07dbe into SBoudrias:master Jun 10, 2016
@SBoudrias
Copy link
Owner

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants