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

[bundler] circular dynamic import cause "Duplicated export" #7521

Open
codehz opened this issue Dec 7, 2023 · 1 comment
Open

[bundler] circular dynamic import cause "Duplicated export" #7521

codehz opened this issue Dec 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@codehz
Copy link
Contributor

codehz commented Dec 7, 2023

What version of Bun is running?

1.0.15+b3bdf22eb

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

https://replit.com/@codehz/bun-build-bug-repro

//a.ts
export const a = 1;
import("./b")

//b.ts
import { a } from "./a"
export const b = a;

//index.ts
Bun.build({
  entrypoints: ["./a.ts", "./b.ts"],
  outdir: "./dist",
})

What is the expected behavior?

no runtime error

What do you see instead?

output a.js:

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getProtoOf = Object.getPrototypeOf;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __toESM = (mod, isNodeMode, target) => {
  target = mod != null ? __create(__getProtoOf(mod)) : {};
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
  for (let key of __getOwnPropNames(mod))
    if (!__hasOwnProp.call(to, key))
      __defProp(to, key, {
        get: () => mod[key],
        enumerable: true
      });
  return to;
};
var __require = (id) => {
  return import.meta.require(id);
};

// a.ts
var a = 1;
import("./b.js");
export {
  a
};

export { a };

Additional information

No response

@codehz codehz added the bug Something isn't working label Dec 7, 2023
@codehz codehz changed the title circular import with code splitting cause "Duplicated export" [bundler] circular dynamic import cause "Duplicated export" Dec 7, 2023
@tobowers
Copy link

In fact, it doesn't even need to be circular: https://replit.com/@topper2/bun-build-bug-repro-no-circular#dist-c/c.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants