linaria
linaria copied to clipboard
Duplicate export 'default' in linaria v5
Environment
- Linaria version: 5.0.3
- Bundler (+ version): Webpack 5, webpack5-loader 5.0.4
- Node.js version: 18.17.1
- OS: Win 10
Description
After upgrade linaria version from v4 to v5 i getting error from loader:
ERROR in ../components/src/index.ts 53:92
Module parse failed: Duplicate export 'default' (53:92)
File was processed with these loaders:
* ../../node_modules/babel-loader/lib/index.js
* ../../node_modules/@linaria/webpack5-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| export { ModalsProvider, ModalsProviderProps, default, useModalState } from "./ModalsProvider/index.js";
> export { ThemeProvider, useTheme, default } from "./theme/index.js";
| export { useSubMenu, SubmenuPositions } from './utils/useSubMenu.js';
...
Source code of index.ts has only reexports:
export * from './ModalsProvider/index.js';
export * from './theme/index.js';
export { useSubMenu, SubmenuPositions } from './utils/useSubMenu.js';
Re-exported modules has other named exports and default. Wildcard exports should works fine in this case and it parsed correctly in previous version of linaria/webpack5-loader.
Reproducible Demo
Simple example:
webpack.config.js
...
use: [
'babel-loader',
{
loader: '@linaria/webpack5-loader',
options: { sourceMap: devMode }
},
],
linaria.config.cjs
module.exports = {
babelOptions: {
presets: ['@babel/preset-typescript', '@babel/preset-react'],
},
};
src/moduleA.ts
export const namedA = 'namedA';
const componentA = 'componentA';
export default componentA;
src/moduleB.ts
export const namedB = 'namedB';
const componentB = 'componentB';
export default componentB;
src/index.ts
export * from './moduleA.js';
export * from './moduleB.js';
I am seeing this in v6 as well (with WyW). it feels like the loader is expanding * as Namespace
imports and emitting duplicate names. this is blocking me from using v6 😢
https://phuoc.ng/collection/tips/avoid-using-default-exports/#re-exporting