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

breaking: change to webpack 5 #1

Merged
merged 2 commits into from Nov 9, 2021
Merged

breaking: change to webpack 5 #1

merged 2 commits into from Nov 9, 2021

Conversation

lwr
Copy link

@lwr lwr commented Aug 14, 2021

drop compatibility for webpack 1~4 and then rollup version to 2

about defer and stage options

  1. by defaults plugin run at processAssets phase in stage PROCESS_ASSETS_STAGE_DEV_TOOLING (that is, after all optimizations liked CssMinimizerPlugin done)
    • new options.stage added for precise controlling
  2. if options.defer is true, then the plugin will run in afterProcessAssets phase

known problems

ref webpack-contrib/mini-css-extract-plugin#256, now css-split-webpack-plugin can not work with mini-css-extract-plugin (even in webpack 4) for async chunks, there are tow workarounds

  1. use option {imports: true}
  2. or add stylesheet links staticcally and patch to remove __webpack_require__.f.miniCss
    config = {
        // ...
        plugins: [
            new MiniCssExtractPlugin({/* ... */}),
            {   // remove `__webpack_require__.f.miniCss`
                apply(compiler) {
                    compiler.hooks.thisCompilation.tap('remove require.f.miniCss', compilation => {
                        compilation.hooks.afterRuntimeRequirements.tap('remove require.f.miniCss', () => {
                            [...compilation.modules].find(x => x.name === 'css loading').generate = () => null;
                        });
                    });
                },
            },
            new CSSSplitWebpackPlugin(),
        ]
    }

simple example to demonstrate this issue

// index.js
// using dynamic import to split chunk
import('./index.less')

now we must config the plugin with {imports: true} to avoid chunk load problem

Also
- fix eslint config to use standard js
- npm ignore all unused filed
Also
- fix repository url
@yibn2008
Copy link
Owner

@lwr Great job! I'll review your PR in the next few days.

@aleen42
Copy link

aleen42 commented Nov 9, 2021

@yibn2008 Any progress?

@yibn2008 yibn2008 merged commit ae578ef into yibn2008:master Nov 9, 2021
@yibn2008
Copy link
Owner

yibn2008 commented Nov 9, 2021

v2.0.0 released

@lwr lwr deleted the next branch November 9, 2021 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants