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]: tools.swc.jsc.transform.react config overrides takes no effect #3418

Closed
SoonIter opened this issue Sep 9, 2024 · 5 comments · Fixed by #3449
Closed

[Bug]: tools.swc.jsc.transform.react config overrides takes no effect #3418

SoonIter opened this issue Sep 9, 2024 · 5 comments · Fixed by #3449
Assignees
Labels
🐞 bug Something isn't working

Comments

@SoonIter
Copy link
Member

SoonIter commented Sep 9, 2024

Version

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 67.98 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 128.0.6613.120
    Chrome Canary: 130.0.6702.0
    Safari: 17.6
  npmPackages:
    @rsbuild/core: 1.0.1-rc.5 => 1.0.1-rc.5 
    @rsbuild/plugin-react: 1.0.1-rc.5 => 1.0.1-rc.5

Details

  1. rsbuild.config.ts
export default defineConfig({
  plugins: [pluginReact()],
  tools: {
    swc: {
      jsc: {
        transform: {
          react: {
            runtime: 'classic',
          },
        },
      },
    },
  },
});
  1. DEBUG=rsbuild rsbuild build
image

Reproduce link

https://github.com/SoonIter/rsbuild-tools-swc-issue-repro

Reproduce Steps

const mergedSwcConfig = reduceConfigs({

  1. pnpm install
  2. DEBUG=rsbuild npx rsbuild build
@SoonIter SoonIter added the 🐞 bug Something isn't working label Sep 9, 2024
@SoonIter
Copy link
Member Author

SoonIter commented Sep 9, 2024

overrided by @rsbuild/plugin-react

fixed by

export default defineConfig({
  plugins: [pluginReact({
    swcReactOptions: {
      runtime: 'classic'
    }
  })],
  tools: {
    // swc(config) {
    //   (((config.jsc ??= {}).transform ??= {}).react ??= {}).runtime =
    //     'classic';
    // },
  },
});

@SoonIter SoonIter changed the title [Bug]: tools.swc config overrides takes no effect [Bug]: tools.swc.jsc.transform.react config overrides takes no effect Sep 9, 2024
@SoonIter
Copy link
Member Author

SoonIter commented Sep 9, 2024

tools.swc should execute in the final stage just like tools.bundlerChain and tools.rspack

so pluginSwc should execute after pluginReact?

modernjs has no entry for modifying the options of pluginReact

@chenjiahan cc

@chenjiahan
Copy link
Member

This is an order issue, I think we can try to let pluginReact to use tools.swc instead of using modifySwcLoaderOptions

@SoonIter SoonIter self-assigned this Sep 9, 2024
@SoonIter
Copy link
Member Author

SoonIter commented Sep 9, 2024

This is an order issue, I think we can try to let pluginReact to use tools.swc instead of using modifySwcLoaderOptions

I cannot get isDev usingHMR in modifyRsbuildConfig 😂...

@chenjiahan
Copy link
Member

Yes, let me think if there is a better way...

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.

2 participants