speed-measure-webpack-plugin icon indicating copy to clipboard operation
speed-measure-webpack-plugin copied to clipboard

Supports webpack5 and mini-css-extract-plugin

Open sunft1996 opened this issue 1 year ago • 6 comments

Supports webpack5 and mini-css-extract-plugin, with the following 3 changes:

  1. Cancel proxy for the parameters of the tap/tapAsync/tapPromise function, as mini-css-extract-plugin will use the compilation parameter passed to the tap function(code here), but it will get the proxy object instead of itself, which causes some bugs.
  2. Cancel the proxy for all methods of the compiler for a similar reason as the first one, as some plugins require the original method, such as mini-css-extract-plugin, which uses compile.webpack as the cache. code here
  3. Replace webpack5 incompatible normal-module-loader hook, although it can still be used now, it will be removed in the future.

I ran through all the test cases and it seems to be okay. I hope it helps :)

sunft1996 avatar Jul 20 '23 06:07 sunft1996

Worked for me - thanks! In case this repo is still maintained, this should definitely be merged. @stephencookdev

brollin avatar Oct 02 '23 20:10 brollin

Why don't you merge it? @stephencookdev

sharikovvladislav avatar Oct 16 '23 15:10 sharikovvladislav

@stephencookdev merge please

tanchu avatar Oct 16 '23 19:10 tanchu

For those who can't run the plugin on the 5th webpack:

  1. Clone the @sunft1996 repo https://github.com/sunft1996/speed-measure-webpack-plugin-source-read/tree/webpack5
  2. Go the repo dir
  3. Checkout the needed branch: it is the webpack5 branch
  4. npm ci in the directory to get the dependencies (install nodejs of needed version if you don't have one or fix the .nvmrc)
  5. Go to your project directory
  6. Run the npm i --save-dev <path_to>/speed-measure-webpack-plugin-source-read command

For example, in my case, it was the npm i --save-dev ../speed-measure-webpack-plugin-source-read because it was an adjacent directory.

After that you will be able to run the plugin even with the webpack@5

FYI @tanchu

@sunft1996 Great effort, man. You helped a lot.

sharikovvladislav avatar Oct 16 '23 23:10 sharikovvladislav

@sharikovvladislav Thanx!

tanchu avatar Oct 17 '23 09:10 tanchu

@sunft1996 can you use npx publish-to-git to publish a version to your repo? Then we will be able to install as such https://www.npmjs.com/package/publish-to-git#consumption-of-private-git-npm-packages

Rush avatar Nov 24 '23 22:11 Rush