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

【react-compiler-babel】示例项目跑不通 #87

Closed
emojiiii opened this issue May 31, 2024 · 2 comments
Closed

【react-compiler-babel】示例项目跑不通 #87

emojiiii opened this issue May 31, 2024 · 2 comments

Comments

@emojiiii
Copy link

下载项目后启动出现

window10系统、mac系统都一样

image

@fi3ework
Copy link
Member

fi3ework commented May 31, 2024

The reason is when using react-compiler as a babel plugin with @rsbuild/plugin-babel with a specified include or exclude. In the final rspack.config.js, the babel-js rule will append after the built-in js rule, that will make react-compiler not processing the raw source code.

A workaround would be tweaking the rule order as below, not graceful though.
@chenjiahan any suggestion about this, should we register babel loader earlier internally?

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginBabel({
      include: /\.(?:jsx|tsx)$/,
      babelLoaderOptions(opts) {
        opts.plugins?.unshift('babel-plugin-react-compiler')
      },
    }),
  ],
+  tools: {
+    bundlerChain: (chain, { env, CHAIN_ID }) => {
+      chain.module.rule('babel-js').before(CHAIN_ID.RULE.JS)
+    },
+  },
})

@emojiiii emojiiii closed this as completed Jun 1, 2024
@chenjiahan
Copy link
Member

Get, I will fix this in the @rsbuild/plugin-babel, we should avoid transforming a JS module twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants