Rollup + React not compiling JSX

后端 未结 1 2178
余生分开走
余生分开走 2021-02-20 11:54

I\'m trying to use Rollup + React but I\'m encounting an error when rollup encounters JSX.

Unexpected token... export default () => 

M...

相关标签:
1条回答
  • 2021-02-20 12:05

    The solution to this is two swap the order of 2 of the plugins

    from:

    plugins: [
        resolve(),
        commonjs(),
        babel({ 
            exclude: 'node_modules/**',
            presets: ['@babel/env', '@babel/preset-react']
        })
    ],
    

    to:

    plugins: [
        resolve(),
        babel({ 
            exclude: 'node_modules/**',
            presets: ['@babel/env', '@babel/preset-react']
        }),
        commonjs()
    ],
    

    Thanks vladshcherbin.

    0 讨论(0)
提交回复
热议问题