stephencookdev / speed-measure-webpack-plugin

⏱ See how fast (or not) your plugins and loaders are, so you can optimise your builds
MIT License
2.42k stars 79 forks source link

Supports webpack5 and mini-css-extract-plugin #199

Open sunft1996 opened 1 year ago

sunft1996 commented 1 year ago

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 :)

brollin commented 1 year ago

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

sharikovvladislav commented 1 year ago

Why don't you merge it? @stephencookdev

tanchu commented 1 year ago

@stephencookdev merge please

sharikovvladislav commented 1 year ago

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.

tanchu commented 1 year ago

@sharikovvladislav Thanx!

Rush commented 12 months ago

@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