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]: Invalid code generated when using DLL plugins and mode: development or optimization.moduleIds: named #9076

Closed
robrichard opened this issue Jan 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@robrichard
Copy link

System Info

  System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 115.81 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/.npm-global/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
    pnpm: 9.1.1 - /usr/local/bin/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
    Watchman: 2023.09.04.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 18.1
  npmPackages:
    @rspack/cli: ^1.2.0 => 1.2.0 
    @rspack/core: ^1.2.0 => 1.2.0 

Details

When generating a DLL bundle using rspack.DLLPlugin, with mode: development or optimization.moduleIds: named, a DLL manifest is created with module ids using the relative path of the file name.

Creating an app bundle using rspack.DLLReferencePlugin, referencing this manifest generates invalid JS code. The module ID is an unquoted string which cannot be parsed by the JS engine.

Example:

module.exports = __webpack_require__(/*! dll-reference my_dll */ "dll-reference my_dll")(./node_modules/relay-runtime/index.js);

Reproduce link

https://github.com/robrichard/rspack-dll-test

Reproduce Steps

Build with dll and dll reference plugin: npm run build

$ npm run build                                                       

> [email protected] build
> rspack build -c ./config/rspack.dll.config.js && rspack build -c ./config/rspack.dllRef.config.js

Rspack compiled successfully in 67 ms
Rspack compiled successfully in 12 ms

Open public/index.html in a browser and see in the console:

Uncaught SyntaxError: Unexpected token '.' (at main.js:4:90)

Generated code:

(() => { // webpackBootstrap
var __webpack_modules__ = ({
"./node_modules/relay-runtime/index.js": (function (module, __unused_webpack_exports, __webpack_require__) {
module.exports = __webpack_require__(/*! dll-reference my_dll */ "dll-reference my_dll")(./node_modules/relay-runtime/index.js);

Note unquoted string reference (./node_modules/relay-runtime/index.js);

@robrichard robrichard added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jan 21, 2025
@inottn inottn removed the pending triage The issue/PR is currently untouched. label Jan 22, 2025
@ahabhgk
Copy link
Contributor

ahabhgk commented Jan 23, 2025

fixed by #9091

@ahabhgk ahabhgk closed this as completed Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants