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

Dynamic import breaks object identity #219

Closed
heypiotr opened this issue Nov 4, 2021 · 1 comment · Fixed by #220
Closed

Dynamic import breaks object identity #219

heypiotr opened this issue Nov 4, 2021 · 1 comment · Fixed by #220

Comments

@heypiotr
Copy link
Contributor

heypiotr commented Nov 4, 2021

Minimal repro: esm-shims-1.3-issue.zip. Downgrading to 1.2 fixes the issue.

Situation: I've got modules "a.js" and "b.js", import-mapped under "a" and "b" respectively. Both of these modules import an object from "./common.js", and expose it on window.common_a and window.common_b (just for debugging).

If I do:

<script type="module">
import "a";
await import("b");
console.log(window.common_a === window.common_b);
</script>

... then in Safari and Firefox (polyfilled import maps), the console.log expression evalautes to false, i.e., the supposedly shared common object actually ends up being different in a and b.

image

In Chrome, it works as expected:

image

In a real situation, "a" is ReactDOM, "b" is a React component, and "common" is React, which means trouble 😄

@guybedford
Copy link
Owner

Thanks for the clear replication, fix in #220.

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

Successfully merging a pull request may close this issue.

2 participants