Open mytecor opened 4 years ago
I'm also getting this issue with create-react-app
Similar issue, CRA doesn't support .mjs files. But regardless wondering why sucrase doesn't compile to something standard like ESM modules? I guess it's primary target is Node and not the browser 😞 Edit: it does but it's under the name .mjs and there is a commonjs version at .js. This seems to confuse compilers.
./node_modules/sucrase/dist/Options-gen-types.mjs
Can't import the named export 'array' from non EcmaScript module (only default export is available)
I made a fork which works for CRA, Gatsby etc - yarn add sucrase-browser
Thanks @DominicTobias!
Sucrase does not work with webpack
Webpack config
```js let webpack = require('webpack') // CSS let MiniCssExtractPlugin = require('mini-css-extract-plugin') let autoprefixer = require('autoprefixer-stylus') // Config module.exports = { entry: './examples/app.js', resolve: { extensions: ['.js', '.styl'] }, module: { rules: [ { test: /\.styl$/, use: [ { loader: MiniCssExtractPlugin.loader, options: { hmr: true, reloadAll: true } }, { loader: 'css-loader', options: { modules: false } }, { loader: 'stylus-loader', options: { use: [autoprefixer()] } } ], }, { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], plugins: ['@babel/plugin-syntax-jsx', '@babel/plugin-transform-react-jsx'] } } } ], }, plugins: [ new MiniCssExtractPlugin({ filename: '[name].css', }), new webpack.ProvidePlugin({ ReactDOM: 'react-dom', React: 'react' }) ], devServer: { contentBase: './examples', historyApiFallback: true, inline: true, hot: true, port: 80 } } ```