-
-
Notifications
You must be signed in to change notification settings - Fork 179
Conversation
a0656df
to
d1152b2
Compare
0802668
to
f8a79a1
Compare
README.md
Outdated
@@ -89,6 +90,8 @@ module.exports = { | |||
|
|||
### `cache` | |||
|
|||
If you use custom `minify` function please read `minify` option section for cache invalidation correctly. |
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.
a custom, see syntax below
README.md
Outdated
@@ -178,6 +181,8 @@ Number of concurrent runs. | |||
|
|||
### `sourceMap` | |||
|
|||
If you use custom `minify` function please read `minify` option section for handle source maps correctly. |
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.
If you use custom
minifyfunction please read
minify option section for handle source maps correctly.
-> If you use your own
minifyfunction please read the
minify section for handling source maps correctly.
README.md
Outdated
// ); | ||
// }, | ||
minify(file, sourceMap) { | ||
// Look https://github.com/mishoo/UglifyJS2#minify-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.
Remove Look, a link is enough perhaps
README.md
Outdated
// ); | ||
// }, | ||
minify(file, sourceMap) { | ||
// Look https://github.com/fabiosantoscode/terser#minify-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.
Strip Look
const errors = stats.compilation.errors.map(cleanErrorStack); | ||
const warnings = stats.compilation.warnings.map(cleanErrorStack); | ||
|
||
expect(errors).toMatchSnapshot('errors'); |
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.
Don't think this is needed, jest will resolve it
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.
@ev1stensberg will be done in other PR (refactor tests) 👍
function removeAbsoluteSourceMapSources(source) { | ||
if (source.map && source.map.sources) { | ||
// eslint-disable-next-line no-param-reassign | ||
source.map.sources = source.map.sources.map(sourceFromMap => path.relative(process.cwd(), sourceFromMap)); |
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.
any way to copy and reassign instead of directly mutating here? Perhaps extracting into a variable and reassigning would be better https://stackoverflow.com/questions/34716651/js-array-prototype-map-happens-to-be-mutable
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.
@ev1stensberg why? It is increase lines of code and decrease perf, but we just need remove absolute path. I don't think it is critical here.
|
||
for (const file in stats.compilation.assets) { | ||
if (Object.prototype.hasOwnProperty.call(stats.compilation.assets, file)) { | ||
expect(removeAbsoluteSourceMapSources(stats.compilation.assets[file].sourceAndMap())).toMatchSnapshot(file); |
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.
assertion is a bit long, maybe a variable to hold the assertion value would be good
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.
@ev1stensberg big in snapshots? I think it is normal, it is allow to catch some strange problem with source map and uglification
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.
Alright. Thought it would be better to test variables containing the values, but that might be hard with compilation instances
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.
The changes work but I don't like the minify
option. I think this option is a too low-level. Having a plugin per minifier would have been better.
In a near future (🤞) when we will have specified plugins, this option would no longer be relevant. Hence my hesitation about merging this.
README.md
Outdated
] | ||
``` | ||
|
||
By default plugin use `uglify-es` package. |
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.
uses?
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.
@ooflorent same people want to use own minification (forks) and without this low level function it is impossible, creating new plugin for this situation is not good solution, because it is require copy/paste 99% code of plugin, also we other fix small problems, this will require people to constantly monitor this and cause a lot of inconvenience. Also it is simple way to test alpha/beta/rc/etc versions.
d929a6a
to
9024f0a
Compare
9024f0a
to
876119d
Compare
/cc @ooflorent please review, it is one blocker for terser and future minimize plugins |
Something to consider... if the default uglifyjs-webpack-plugin/src/index.js Lines 177 to 179 in 0174605
and the cached assets will be invalid. |
@kzc it is not critical, |
Until the module with the minify replacement function is upgraded - terser, uglify-js, or whatever. You might mention in the docs if this minify field is overriden or dependencies are updated then the user should delete their build cache. You could also elect to allow the user to provide a custom version string to workaround this issue. |
@kzc PR welcome |
Also we provide way to invalidate cache https://github.com/webpack-contrib/uglifyjs-webpack-plugin#terser |
⭐
One question: what do with extracting comment for custom minify function, if people use
uglify-js
/terser
our logic https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/src/uglify/minify.js#L45 is work good, maybe we should export this function to avoid copy/paste this code