Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

feat: support devtool (options.sourceMap) #81

Closed
wants to merge 4 commits into from

Conversation

hulkish
Copy link
Contributor

@hulkish hulkish commented Jul 12, 2017

As described here: #80 (comment)

expect(errors).toMatchSnapshot('devtool === "sourcemap" errors');
expect(warnings).toMatchSnapshot('devtool === "sourcemap" warnings');

for (const file in stats.compilation.assets) {
Copy link
Member

@michael-ciniawsky michael-ciniawsky Jul 12, 2017

Choose a reason for hiding this comment

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

const assets = stats.compilation.assets

Object.keys(assets).forEach((asset) => {
  const source = assets[asset].source()
  expect(source).toMatchSnapshot(asset)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do..but i dont think we want we return in that forEach

Copy link
Member

@michael-ciniawsky michael-ciniawsky Jul 13, 2017

Choose a reason for hiding this comment

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

Yup we don't want toreturn there, updated 😛

@@ -157,6 +157,10 @@ class UglifyJsPlugin {
uglifyOptions.output = uglifyOptions.output || {};
}

if (typeof this.options.sourceMap === 'undefined' && ['sourcemap', 'source-map', 'hidden-source-map'].indexOf(compiler.options.devtool) > -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the typeof this.options.sourceMap === 'undefined' necessary here ?

Copy link
Contributor Author

@hulkish hulkish Jul 12, 2017

Choose a reason for hiding this comment

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

Yes, if we're talking current usage. Because it can be user defined as true or false. This basically only auto-sets the sourceMap option value if u aren't manually overriding it.

This way, we aren't breaking current usage of sourceMap option

Copy link
Member

Choose a reason for hiding this comment

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

If devtool should be automatically supported, the previous this.options.sourceMap 'doesn't matter' as it is overridden to true anyways in case compilation.options.devtool is set ? Maybe I'm missing a case here 🙃

Copy link
Member

Choose a reason for hiding this comment

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

And if I missed one if (typeof this.options.sourceMap === "undefined") => if (!this.options.sourceMap) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, honestly I'm not certain of the history of this option.. I was just being careful to not break it's current usage.

That said, i see your point and im alright with removing the exposing of this option all together. Up to u.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michael-ciniawsky what u think?

@michael-ciniawsky michael-ciniawsky changed the title feat: auto sourceMap feat: support devtool (options.sourceMap) Jul 12, 2017
@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Jul 12, 2017
@mikesherov
Copy link

My vote is this logic should remain in webpack proper, as the logic has even changed since this PR was suggested. Just my 2 cents.

@michael-ciniawsky
Copy link
Member

Agreeing with @mikesherov here, this adds unnecessary side effects to the plugin

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

Successfully merging this pull request may close these issues.

4 participants