-
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
Default import is broken when bundling JS files compiled from TypeScript #1295
Comments
What's happening here is that the import from Here are some ideas for how to avoid this but still do what you're trying to do:
|
@evanw Thank you for your answers. 2nd and 4th options work fine for me.
I wander that imports in |
I think converting |
Thank you for taking a look. Is the issue already being tracked anywhere? If not, I'll keep this issue open to track it. |
Actually I was wrong. The behavior I was thinking of is the one where if you import I think using |
I confirmed
fixed the Is the correct behavior that TypeScript file is prioritized on resolving imports in JavaScript file when file extension is omitted? (It looked confusing for me.) If it is correct, this issue is actually an intended behavior so we can happily close this. Otherwise I think this issue would be kept to be open. |
Yes, that is what I consider to be correct behavior. The default resolve order is documented as |
Versions
Repro
Put
tsconfig.json
,index.ts
andapp.ts
in current directory as follows:tsconfig.json:
app.ts:
index.ts:
Compile TypeScript files with
tsc
command:Confirm the compiled files work fine:
It should output:
Then bundle the JS files with esbuild:
Run the bundled file:
Expected behavior
node out.js
outputsActual behavior
node out.js
causes an exception:Note
Directly bundling TypeScript files with:
does not cause this issue. It works as expected.
The text was updated successfully, but these errors were encountered: