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]: rspack serve fails with InvalidArg if Rule.options has function in it #8180

Open
skoch13 opened this issue Oct 21, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@skoch13
Copy link

skoch13 commented Oct 21, 2024

System Info

System:
OS: macOS 15.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.92 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.16.0 - ~/.local/state/fnm_multishells/79899_1729519945071/bin/node
npm: 10.8.1 - ~/.local/state/fnm_multishells/79899_1729519945071/bin/npm
pnpm: 9.12.2 - ~/.local/state/fnm_multishells/79899_1729519945071/bin/pnpm
Browsers:
Chrome: 130.0.6723.59
Safari: 18.0.1
npmPackages:
@rspack/cli: 1.0.13 => 1.0.13
@rspack/core: 1.0.13 => 1.0.13
@rspack/plugin-react-refresh: 1.0.0 => 1.0.0

Details

In attempt to migrate from webpack I stumbled upon the following error that is a little bit hard to trace, but the root cause is the following:

ts-loader allows to provide options.getCustomTransformers as function.

  {
    test: /\.tsx?$/,
    loader: 'builtin:swc-loader',
    type: 'javascript/auto',
    options: {
      getCustomTransformers: () => {}
...
...

Starting the web server results in the following error:

/Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:17883
    this.#instance = new instanceBinding.Rspack(
                     ^
Error: JS functions cannot be represented as a serde_json::Value
    at _Compiler.#getInstance (/Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:17883:22)
    at _Compiler.#build (/Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:17330:22)
    at /Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:17302:18
    at done (/Users/user/PATH/node_modules/.pnpm/@rspack+lite-tapable@1.0.1/node_modules/@rspack/lite-tapable/dist/index.js:473:13)
    at AsyncSeriesHook.callAsyncStageRange (/Users/user/PATH/node_modules/.pnpm/@rspack+lite-tapable@1.0.1/node_modules/@rspack/lite-tapable/dist/index.js:480:20)
    at AsyncSeriesHook.callAsync (/Users/user/PATH/node_modules/.pnpm/@rspack+lite-tapable@1.0.1/node_modules/@rspack/lite-tapable/dist/index.js:82:21)
    at _Compiler.compile (/Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:17296:30)
    at /Users/user/PATH/node_modules/.pnpm/@rspack+core@1.0.13/node_modules/@rspack/core/dist/index.js:16733:21
    at done (/Users/user/PATH/node_modules/.pnpm/@rspack+lite-tapable@1.0.1/node_modules/@rspack/lite-tapable/dist/index.js:473:13)
    at next (/Users/user/PATH/node_modules/.pnpm/@rspack+lite-tapable@1.0.1/node_modules/@rspack/lite-tapable/dist/index.js:533:25) {
  code: 'InvalidArg'
}

Is it possible to improve error message here?

Reproduce link

https://github.com/skoch13/rspack-repro

Reproduce Steps

  1. add function inside of Rule.options
  2. execute rspack serve

or check repro at https://github.com/skoch13/rspack-repro

@skoch13 skoch13 added bug Something isn't working pending triage The issue/PR is currently untouched. labels Oct 21, 2024
@inottn
Copy link
Collaborator

inottn commented Oct 22, 2024

The builtin:swc-loader does not support the getCustomTransformers option. See https://rspack.dev/guide/features/builtin-swc-loader for more details.

@jerrykingxyz jerrykingxyz removed the pending triage The issue/PR is currently untouched. label Oct 22, 2024
@skoch13
Copy link
Author

skoch13 commented Oct 22, 2024

@inottn thank you for your reply. I did understand that eventually, but my question was, is it possible to improve error messaging here?

Copy link

stale bot commented Dec 21, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Dec 21, 2024
@stale stale bot removed the stale label Dec 21, 2024
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

No branches or pull requests

4 participants