-
-
Notifications
You must be signed in to change notification settings - Fork 177
fix(index): deep cloning options (options.uglifyOptions)
#87
fix(index): deep cloning options (options.uglifyOptions)
#87
Conversation
options.uglifyOptions)
|
Please share your |
|
@scott-thrillist @michael-ciniawsky Pretty sure this is already covered in #80 |
|
@hulkish interesting, this schema method is new to me. I'll test 😄 |
|
Not sure why this isn't installing the
|
|
@scott-thrillist try commenting this line on your local: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/test/helpers.js#L51 |
|
I think my install process may be wrong. I add that dependency line in my package.json, run an No subdirectories for some reason. |
|
@scott-thrillist make sure you're using npm >= 5 |
|
Yea totally: |
|
whats the full extent of the commands youre trying and whats the error you receive? Also, whats your node version? |
|
Node v8.1.4
Here's the error I get: |
|
dont do this: By doing this, you're essentially side-stepping the package-lock behavior. do this instead: |
|
Really appreciate the help, though doing all of the above gives me the same result- no subdirectories in
|
|
Yea dont do that, it won't really work correctly. Instead: |
|
That seems right. All my Googling kept referencing install by URL :p Apologies for taking up so much of your time. Will try it this way |
|
No worries, the internet has a lot of misinformation on the topic. |
|
Dont forget to |
|
That said.. let me know if your issue is resolved in that PR and ill close this. |
|
Will do! I'm guessing passing this to UglifyJS() won't work anymore: Getting this: throw new _ValidationError2.default(ajv.errors, name); Based on the schema file it seems like it should look like this correct? |
|
@scott-thrillist try it: node
> console.log(require('uglify-es').minify{({ foo: `const $super = 5 + 5; exports.foo = require('foo');`,
warnings: false,
mangle: {
reserved: ['$super', '$', 'exports', 'require']
}
}).code);But, yea you will need to renest those options when you create the plugin instance. |
|
Sorry, I meant the new schema for uglifyjs-webpack-plugin. Trying to match my options with this file: |
|
I see, yes the schema is a breaking change in that regard. Have you confirmed yet if that pr solves your issue? |
|
Unfortunately no. :( I got back and forth on this, but in the end I think best practice would be for me to deep clone my own data before sending it to a plugin, mainly because the nature of open source plugins can do anything they want with the data you provide. If you don't have any other feedback on this issue feel free to close this PR. And thanks again for being patient with my testing. |
|
I think handling the deep clone in your implementation is probably best bet. Mainly because this is not an issue which is exclusive to this plugin. For ex... if you were to do the same test with your actual webpack config.. you will see your original webpack config object be mutated. Which I realize is generally not a good idea from a purist perspective... but the reality is that by solving this here wouldn't really be solving the problem as a whole imo. |
|
Oh I forgot to mention the best part. It now builds fine with my vanilla uglify-es processes in the |
|
Awesome... I'm thinking we can close this now considering previous convo... agreed? |
|
Yes, done |
Proper deep clone, as recommended by MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Deep_Clone
Use case: I found my
config.uglifyOptionsobject being altered when I passed it into uglifyjs-webpack-plugin. The properties "test" and "warningsFilter" were being added. I also have processes outside of webpack that use this object and it fails as these properties are not recognized by uglify-es/js.