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

[Bug]: failed to retrieve chunk name #6078

Closed
theninthsky opened this issue Apr 1, 2024 · 5 comments · Fixed by #6428
Closed

[Bug]: failed to retrieve chunk name #6078

theninthsky opened this issue Apr 1, 2024 · 5 comments · Fixed by #6428
Labels
bug Something isn't working pr welcome

Comments

@theninthsky
Copy link

System Info

Operating System: Windows 11
Node Version: 20.11.1
Rspack CLI Version: 0.5.9

Details

Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
Message:  failed to retrieve chunk name:   × TypeError: Cannot read properties of undefined (reading 'map')
  │     at name (C:\Projects\client-side-rendering\rspack.config.js:77:45)
  │     at C:\Projects\client-side-rendering\node_modules\@rspack\core\dist\builtin-plugin\SplitChunksPlugin.js:37:28
  │

Location: crates\rspack_binding_options\src\options\raw_split_chunks\raw_split_chunk_name.rs:42

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 1: napi_register_module_v1
    at <unknown source file>
 2: napi_register_module_v1
    at <unknown source file>
 3: napi_register_module_v1
    at <unknown source file>
 4: napi_register_module_v1
    at <unknown source file>
 5: napi_register_module_v1
    at <unknown source file>
 6: wasmer_vm_imported_memory32_atomic_notify
    at <unknown source file>
 7: wasmer_vm_imported_memory32_atomic_notify
    at <unknown source file>
 8: napi_register_module_v1
    at <unknown source file>
 9: napi_register_module_v1
    at <unknown source file>
10: napi_register_module_v1
    at <unknown source file>
11: napi_register_module_v1
    at <unknown source file>
12: napi_register_module_v1
    at <unknown source file>
13: napi_register_module_v1
    at <unknown source file>
14: napi_register_module_v1
    at <unknown source file>
15: napi_register_module_v1
    at <unknown source file>
16: napi_register_module_v1
    at <unknown source file>
17: napi_register_module_v1
    at <unknown source file>
18: napi_register_module_v1
    at <unknown source file>
19: napi_register_module_v1
    at <unknown source file>
20: napi_register_module_v1
    at <unknown source file>
21: napi_register_module_v1
    at <unknown source file>
22: napi_register_module_v1
    at <unknown source file>
23: wasmer_vm_imported_memory32_atomic_notify
    at <unknown source file>
24: napi_register_module_v1
    at <unknown source file>
25: napi_register_module_v1
    at <unknown source file>
26: napi_register_module_v1
    at <unknown source file>
27: napi_register_module_v1
    at <unknown source file>
28: BaseThreadInitThunk
    at <unknown source file>
29: RtlUserThreadStart
    at <unknown source file>

Reproduce link

No response

Reproduce Steps

Create the following optimization in a project (coming from Webpack):

 optimization: {
      runtimeChunk: 'single',
      splitChunks: {
        chunks: 'initial',
        cacheGroups: {
          vendors: {
            test: /[\\/]node_modules[\\/]/,
            chunks: 'all',
            minSize: 100000,
            name: (module, chunks) => {
              const allChunksNames = chunks.map(({ name }) => name).join('.')
              const moduleName = (module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/) || [])[1]

              return `${moduleName}.${allChunksNames}`.replace('@', '')
            }
          }
        }
      }
    },

The purpose of this splitChunks configuration is to extract dependencies from async chunks and combine them.
A thorough explanation can be found here:
https://github.com/theninthsky/client-side-rendering?tab=readme-ov-file#preventing-duplicate-async-vendors

@theninthsky theninthsky added bug Something isn't working pending triage The issue/PR is currently untouched. labels Apr 1, 2024
@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Apr 1, 2024

Rspack does not support chunks as the second argument.

@theninthsky
Copy link
Author

Thanks.

@theninthsky
Copy link
Author

@h-a-n-a
Is there a plan to support this feature?
Especially since it's not a plugin, but rather a core Webpack property.

@theninthsky theninthsky reopened this Apr 18, 2024
@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Apr 18, 2024

@h-a-n-a

Is there a plan to support this feature?

Especially since it's not a plugin, but rather a core Webpack property.

@theninthsky Yes, we can support this and PR is welcome.

@h-a-n-a h-a-n-a added pr welcome and removed pending triage The issue/PR is currently untouched. labels Apr 18, 2024
@mxmason
Copy link

mxmason commented May 22, 2024

Hi, @h-a-n-a. I'm also very interested in this fix, as I think this is the exact issue that's preventing me from migrating to Rspack. My team has a django app that relies on a manifest file to look up build chunks when rendering html files. This same bug prevents the chunks from being mapped into the manifest file.

Repro

When I use the same config with both Webpack and Rspack, the output file yields different results.

webpack.config.js:

import BundleTrackerPlugin from 'webpack-bundle-tracker';

export default {
  plugins: [new BundleTrackerPlugin({ filename: `stats.json` })],
  entry: './src/index.js',
  output: {
    filename: 'main.js',
  },
};

Manifest from Rspack

{
  "status": "done",
  "assets": {
    "main.js": {
      "name": "main.js",
      "path": "/Users/user/dev/webpack-demo/dist/main.js"
    },
    "main.js.map": {
      "name": "main.js.map",
      "path": "/Users/user/dev/webpack-demo/dist/main.js.map"
    }
  },
  "chunks": {}
}

Manifest from Webpack

{
  "status": "done",
  "assets": {
    "main.js": {
      "name": "main.js",
      "path": "/Users/user/dev/webpack-demo/dist/main.js"
    }
  },
  "chunks": {
    "main": ["main.js"]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants