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

Upgrade to css-minimize-webpack-plugin 2.0 #966

Merged
merged 7 commits into from
Apr 28, 2021

Conversation

stof
Copy link
Member

@stof stof commented Apr 21, 2021

This upgrades cssnano to version 5, which fixes a bunch of bugs and uses postcss 8 (avoiding to install multiple versions of postcss).
The BC breaks in the plugin are dropping support for webpack 4 (not impacted Encore as we already dropped it), removing some options which were only for webpack 4 and the fact that cssnano 5 requires node 10.13+ (not impacting Encore as we already require 10.19+)

Closes #965

@stof stof added the dependencies Pull requests that update a dependency file label Apr 21, 2021
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Thanks for this Stof!

I think we need to also remove our sourceMap option here -

sourceMap: webpackConfig.useSourceMaps
- as it looks like this option is was removed.

This would be the first time (since our 1.0) that we would upgrade dependencies over a major version. That's a gray area in our BC policy. The changes, in this case, are not for any options, etc that are used (or advertised to be used, e.g. in index.js documentation) by Encore. Therefore, my opinion is that it does not require a major a bump (and I think you agree).

This upgrades cssnano to version 5, which fixes a bunch of bugs and uses
postcss 8 (avoiding to install multiple versions of postcss).
@stof stof force-pushed the upgrade_css_minimizer branch 4 times, most recently from adb5ca5 to a8eb4c8 Compare April 23, 2021 10:57
The new version of webpack has different runtime chunks
@stof
Copy link
Member Author

stof commented Apr 23, 2021

For fixing the tests, I went the lazy way for finding the version of webpack that changed the naming of chunks, and I made 5.35 (the current version) the min version. I know that 5.25 is still using the old naming of the split chunk.

Due to the way yarn and npm work, supporting a wide range of versions for dependencies is not useful, as yarn and npm will use the latest version anyway (happily installing multiple versions of the package in different parts of the tree if needed). The place where supporting wider ranges is useful is for peerDependencies.

@stof
Copy link
Member Author

stof commented Apr 23, 2021

ok, apparently, it is not webpack itself changing the naming of chunks, but probably a plugin...

@stof
Copy link
Member Author

stof commented Apr 23, 2021

@weaverryan how do you generally fix this issue about the generated chunk ids being different for the lowest deps job ?

@weaverryan
Copy link
Member

@weaverryan how do you generally fix this issue about the generated chunk ids being different for the lowest deps job ?

I have been, on a case-by-case basis, making our test suite able to be "smarter" by matching in a fuzzy way. For example:

'main.[hash:8].js',

Outside of this PR, we just need to find the new problems and make them fuzzy like this :)

@@ -101,11 +101,12 @@ module.exports = Encore.getWebpackConfig();
expect(parsedOutput).to.be.an('object');
expect(parsedOutput.modules).to.be.an('array');

// We expect 3 modules there:
// We expect 4 modules there:
// - webpack/runtime/chunk loaded
Copy link
Member

Choose a reason for hiding this comment

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

Was this related to the babel-loader bump? V 8.2.2 causes an extra module to be in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

webpack itself. They refactored their runtime in the 5.25 release

@stof
Copy link
Member Author

stof commented Apr 27, 2021

@weaverryan the issue is the test about splitting entry points in production mode. there, the file names are integers generated by webpack, and they depend on a bunch of things

@weaverryan
Copy link
Member

@weaverryan the issue is the test about splitting entry points in production mode. there, the file names are integers generated by webpack, and they depend on a bunch of things

👍 So, for reference, this line causes problems:

js: ['/build/runtime.js', '/build/961.js', '/build/38.js', '/build/main.js'],

Matching the 2 integers in a "fuzzy" way would be a little odd... just because they could be anything. The test would be reduced to:

  • Check that there are 4 .js files
  • And that 2 of them are runtime.js and main.js... but the other 2 could be anything

It makes me think it would be easier just to rewrite the test. Instead of asserting the entire entrypoints.json contents, we would check specifically for the two items above (check for 4 files, and that two of them are runtime.js and main.js).

For the webpackAssert.assertManifestKeyExists('build/843.js'); check, probably we could loop through all of the main keys in the entrypoints.json file, and assert that they exist (without the opening slash) in manifest.json.

@stof
Copy link
Member Author

stof commented Apr 28, 2021

@weaverryan any chance that you do the refactoring of this test, as you know better than me the architecture of the testsuite ?

@weaverryan
Copy link
Member

No problem - I was thinking already about doing that - I pushed a commit that should hopefully do the trick :)

test/functional.js Outdated Show resolved Hide resolved
@stof
Copy link
Member Author

stof commented Apr 28, 2021

Looks like the enableIntegrityHashes() now breaks in the highest deps job (which was not the case last week).

@weaverryan
Copy link
Member

I noticed that too :/ - I'll take a look at it in a separate PR - the cause is not immediately obvious

@weaverryan
Copy link
Member

Thanks Stof!

@weaverryan weaverryan merged commit 44bebd7 into symfony:main Apr 28, 2021
@Kocal
Copy link
Contributor

Kocal commented Apr 28, 2021

Thanks! :)

@stof stof deleted the upgrade_css_minimizer branch April 28, 2021 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

css-minimizer-webpack-plugin should be updated to v2
3 participants