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

Babel Decorators Error When Enabling experimental.reactCompiler #77440

Open
programming-with-ia opened this issue Mar 23, 2025 · 1 comment
Open
Labels
React Related to React. Turbopack Related to Turbopack with Next.js. TypeScript Related to types with Next.js. Webpack Related to Webpack with Next.js.

Comments

@programming-with-ia
Copy link

Link to the code that reproduces this issue

https://github.com/shadcn-ui/next-template

To Reproduce

Description

Enabling experimental.reactCompiler in next.config.js causes a Babel error related to missing decorator plugins.

Error Message

Add @babel/plugin-proposal-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators) to the 'plugins' section to enable parsing.

Current vs. Expected behavior

Steps to Reproduce

  1. Set experimental.reactCompiler = true in next.config.js:
    module.exports = {
      experimental: {
        reactCompiler: true
      }
    };
  2. Ensure tsconfig.json has the following settings:
    {
      "compilerOptions": {
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "downlevelIteration": true,
        "forceConsistentCasingInFileNames": true
      }
    }
  3. Run the project (next dev or next build).
  4. The error appears.

Expected Behavior

Next.js should handle decorators properly when reactCompiler is enabled.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16231
  Available CPU cores: 4
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.15.4
Relevant Packages:
  next: 15.1.6 // There is a newer version (15.2.3) available, upgrade recommended!
  eslint-config-next: 15.1.6
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3

Which area(s) are affected? (Select all that apply)

Turbopack, Webpack, TypeScript, React

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

sorry: Link to the code that reproduces this issue

@github-actions github-actions bot added React Related to React. Turbopack Related to Turbopack with Next.js. TypeScript Related to types with Next.js. Webpack Related to Webpack with Next.js. labels Mar 23, 2025
@programming-with-ia
Copy link
Author

when use .babelrc with

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    "babel-plugin-transform-typescript-metadata",
    "babel-plugin-react-compiler",
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ]
  ]
}

Error

Make sure that all the Babel plugins and presets you are using
are defined as dependencies or devDependencies in your package.json
file. It's possible that the missing plugin is loaded by a preset
you are using that forgot to add the plugin to its dependencies: you
can workaround this problem by explicitly adding the missing package
to your top-level package.json.
    at loadPlugin.next (<anonymous>)
    at createDescriptor.next (<anonymous>)
    at Array.map (<anonymous>)
    at Generator.next (<anonymous>)
    at createDescriptors.next (<anonymous>)
    at createPluginDescriptors.next (<anonymous>)
    at Generator.next (<anonymous>)
    at Generator.next (<anonymous>)
    at Generator.next (<anonymous>)
    at cachedFunction.next (<anonymous>)
    at mergeChainOpts.next (<anonymous>)
    at chainWalker.next (<anonymous>)
    at buildRootChain.next (<anonymous>)
    at loadPrivatePartialConfig.next (<anonymous>)
    at loadFullConfig.next (<anonymous>)
    at Generator.next (<anonymous>)
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
 ⨯ [TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
 ⨯ [TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "path" argument must be of type string. Received undefined] {
  code: 'ERR_INVALID_ARG_TYPE'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React Related to React. Turbopack Related to Turbopack with Next.js. TypeScript Related to types with Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant