rspack: [Bug]: `parallelCodeSplitting` increases js output size

System Info

Rspack 1.2.8 with explicit opt-in experiments.parallelCodeSplitting = true or 1.3 with default (true)

Details

When parallelCodeSplitting it turned on, the JS output size increases

This has been caught by our CI bundle size checker while upgrading to v1.3 (see https://github.com/facebook/docusaurus/pull/11039), but also reproduces when turning the option on manually on v1.2.8

Image

The diff increase looks related to code splitting

Image

Reproduce link

No response

Reproduce Steps

clone https://github.com/facebook/docusaurus

Change rspack version in docusaurus/packages/docusaurus-faster/package.json

Run on Rspack 1.2.8

yarn install
yarn build:website:fast

Save website/build/assets/js/main.*.js

Run on Rspack 1.3.x

yarn install
yarn build:website:fast

Save website/build/assets/js/main.*.js

Diff both files, the v1.3.0 one is larger than the 1.2.8 one.

Disabling parallelCodeSplitting on v1.3 gives an output that looks like before (ignoring positive changes related to output.environment)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Let’s keep this issue as we still need to add more documentation for the current parallelCodeSplitting impact. 😄

Oh persistent case, I think it’s fixed by #9886

Let me explain the history here.

removeAvailableModules was the option to optimize chunk modules in early webpack, enable it will add a plugin to remove modules that already in parent chunks. Later, webpack has refactored code splitting algorithm, after then, code splitting can skip visiting modules that already exist in parent chunks entirely, the removeAvailableModules is no need then as its functionality is already covered by code splitting itself.

webpack suggests turning this on might make the build slower, is this a valid concern in practice?

Should keep it false for webpack, as it will add an unnecessary plugin to do the duplicated work.

For Rspack, well, I think we need to discuss further whether we should keep this config or not

Thanks, I’ll check it out

The .docusaurus folder is generated by Docusaurus core based on content and logic of plugins.

The routes.js file is generated based on all routes created by various plugins:

export default function friendsPlugin(context, options) {
  return {
    name: 'docusaurus-friends-plugin',

    async contentLoaded({content, actions}) {

      const friendsModulePath = await actions.createData(
        'friends.json',
        JSON.stringify(['Yangshun', 'Sebastien']),
      );

      // Add the '/friends' routes, and ensure it receives the friends module as props
      actions.addRoute({
        path: '/friends',
        component: '@site/src/components/Friends.js',
        modules: {
          friends: friendsJsonPath,
        },
        exact: true,
      });
    },
  };
}

Other files that might be related to this problem: registry.js and routesChunkNames.json

The code that generates all these files from plugin routes is located in docusaurus/packages/docusaurus/src/server/codegen