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

Bundling dynamic import of entrypoint emits reference to non-existent _exports #2793

Closed
zachkirsch opened this issue Jan 4, 2023 · 2 comments

Comments

@zachkirsch
Copy link

zachkirsch commented Jan 4, 2023

Minimal repro:

// src/a.js
export const A = 42;

// src/b.js
export const B = async () => (await import(".")).A

// src/index.js
export * from "./a"
export * from "./b"

esbuild command:

esbuild src/index.js --bundle --outfile=bundle.js --format=esm

Outputted bundle.js:

var __getOwnPropNames = Object.getOwnPropertyNames;
var __esm = (fn, res) => function __init() {
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};

// src/a.js
var A;
var init_a = __esm({
  "src/a.js"() {
    A = 42;
  }
});

// src/b.js
var B;
var init_b = __esm({
  "src/b.js"() {
    B = async () => (await Promise.resolve().then(() => (init_src(), src_exports))).A;
  }
});

// src/index.js
var init_src = __esm({
  "src/index.js"() {
    init_a();
    init_b();
  }
});
init_src();
export {
  A,
  B
};

Bug: in the dynamic import, there's a reference to src_exports, but there's no src_exports defined!

@zachkirsch zachkirsch changed the title Bundling dynamic import of directory emits reference to non-existent _exports Bundling dynamic import of entrypoint emits reference to non-existent _exports Jan 4, 2023
@zachkirsch
Copy link
Author

@evanw any thoughts here? If this is a good first issue I'm happy to PR

@evanw evanw closed this as completed in dad3e64 Jan 7, 2023
@zachkirsch
Copy link
Author

Thanks @evanw!!

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

1 participant