-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Incorrect cyclic transpilation to cjs #1856
Comments
Thanks for the report. I just checked and this is not a recent regression (I suspected #1591). I can reproduce it when compiling files one-at-a-time but not when bundling, so I'm assuming you're not bundling.
I'm confused. It does seem to be a problem with Babel too. Here's what I get from Babel:
And here's what I get when I run
I'm also confused about why you're mentioning Webpack. Webpack is a bundler, but this works fine with esbuild when bundling too. Are you comparing esbuild without bundling to Webpack with bundling? If Webpack works for you with bundling, then couldn't you just use esbuild with bundling instead? |
Typo; I meant Typescript (via ts-node) 🙂
We currently run Yarn in development live-from-sources using
No, during development we don't run bundling, we just transpile the files as they get required by Node. |
Just took a quick look at your repro and there's an issue: I'm not running |
I think I'm running into the same issue also when bundling. I'm troubleshooting a regression in a somewhat large TypeScript lambda function bundled and deployed via AWS CDK (that uses esbuild under the hood). I'm not sure if regression is due to updated esbuild or updated dependency that is causing the issue. However, the issue looks the same: Esbuild generates code like this:
Which fails at runtime with:
|
I hit this issue today and had to workaround it. https://crrev.com/c/4710866 |
I spotted this issue while trying to replace babel-register w/ esbuild-register in the Yarn codebase.
x.js
y.js
Running
y.js
after both files have been transpiled crashes with:This is caused by
__toESM
, which turns the import into a new object (__create(__getProtoOf(module2))
) before copying exported symbols. In the case of cyclic imports however, the exported symbols aren't ready yet when__toESM
finishes executing, thus causingimport_y
to be an empty object:This isn't a problem when transpiled with Babel or Webpack.
The text was updated successfully, but these errors were encountered: