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

Duplicate export 'default' in linaria v5 #1385

Open
eKazim opened this issue Nov 28, 2023 · 2 comments
Open

Duplicate export 'default' in linaria v5 #1385

eKazim opened this issue Nov 28, 2023 · 2 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@eKazim
Copy link

eKazim commented Nov 28, 2023

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';
@eKazim eKazim added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 28, 2023
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 28, 2023
@eKazim eKazim changed the title Duplicate export 'default' Duplicate export 'default' in linaria v5 Nov 28, 2023
@giladgray
Copy link

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 😢

@mulfyx
Copy link

mulfyx commented Feb 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

3 participants