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

generate warning for reexport name conflict #2322

Closed
hardfist opened this issue Jun 16, 2022 · 2 comments
Closed

generate warning for reexport name conflict #2322

hardfist opened this issue Jun 16, 2022 · 2 comments

Comments

@hardfist
Copy link
Contributor

when I reexport multi module

  • a.js
export const common = 42;
export const answer = 12;
  • b.js
export const secret = 23;
export const common = 42;
  • index.js
export * from './a';
export * from './b';
console.log('index');

run

$ esbuild index.js --bundle --format=esm

generate result

// answer.js
var answer = 12;

// secret.js
var secret = 23;

// index.js
console.log("xxx");
export {
  answer,
  secret
};

and the common is lost because it conflicts in a.js and b.js and not generates warning, which is dangerous

@evanw
Copy link
Owner

evanw commented Jun 16, 2022

Makes sense. I don't think this should be a warning by default because this is a normal part of how JavaScript works. I disagree that it's always dangerous. You may have use cases where it doesn't matter for example, and you may not be able to do anything about the warning if you don't control the source code of the files you are re-exporting from. But I can add a way to opt-in to logging this with something like --log-override:ambiguous-import=warning.

@evanw evanw closed this as completed in d500061 Jun 16, 2022
@hardfist
Copy link
Contributor Author

I don't know it's a standard behavior, but it seems that when these files are compiled into commonjs, the runtime behaves differs from the esm result.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants