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 import identifier when re-exporting with export star when preserveModules is true #3365

Closed
kamranayub opened this issue Feb 3, 2020 · 0 comments · Fixed by #3435

Comments

@kamranayub
Copy link
Contributor

kamranayub commented Feb 3, 2020

  • Rollup Version: 1.31.0-2.0.3
  • Operating System (or Browser): Mac OS Mojave
  • Node Version: v12.14.1

Search terms: export star, reexport, re-export, nested modules, preserveModules

When using preserveModules, we're seeing an issue handling nested module re-exporting using export * as shown below.

How Do We Reproduce?

Minimal reproduction: https://github.com/kamranayub/rollup-bug-reexporting-preserveModules

  1. You can view the output in dist/index.js
  2. You can also run yarn and yarn build to rebuild the output

Expected Behavior

We'd expect Rollup to de-dupe the import alias similar to how it behaves with preserveModules: false (e.g. index$1)

import * as index from './module-a/v1/index.js';
export { index as ModuleA_V1 };
import * as index$1 from './module-b/v1/index.js';
export { index$1 as ModuleB_V1 };

Actual Behavior

Rollup generates a duplicate import alias:

import * as index from './module-a/v1/index.js';
export { index as ModuleA_V1 };
import * as index from './module-b/v1/index.js';
export { index as ModuleB_V1 };

This will result in an error when consumed:

Identifier 'index' has already been declared

See: https://github.com/kamranayub/rollup-bug-reexporting-preserveModules/blob/master/dist/index.js

kamranayub added a commit to kamranayub/rollup that referenced this issue Mar 10, 2020
lukastaegert pushed a commit that referenced this issue Mar 12, 2020
…at using nested export star statements (#3435)

* Add failing test for barrel exports #3365

* Update expected outputs

* Fix expected output

* Set chunkOrExternalModule.variableName in deconflictImportsEsm

* Dconflict deps when preserveModules is true

* Update system-exports-wrap-pure-annotation

* Actually use preserveModules flag

* Only deconflict deps in esm to minimize impact

* Update tests expected output

* Update test, add more context to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant