-
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
Importing file without filename extension, with filename prefix which matches other file, fails #118
Comments
I've been trying to make sure esbuild follows the node module resolution algorithm for compatibility, so I look to what node does to resolve questions like these. If I create the following files: // foo.bar
console.log('in foo.bar')
// foo.bar.js
console.log('in foo.bar.js')
// main.js
const hi = require('./foo.bar') and then run I also tried webpack to see what it does in this case. I used your original example with // foo.bar
console.log('in foo.bar')
// foo.bar.ts
console.log('in foo.bar.ts')
// main.ts
import hi from './foo.bar' I ran webpack with So I'm not convinced that what you expected esbuild to do (ignore |
Oh, very interesting. I agree that it would be a good idea to stick with the behavior of existing stuff like nodejs. Let’s close this :–) For anyone coming here in the future, there are three workarounds that I can think of:
Thank you for investigating Evan! |
Since typescript actually supports importing with a E.g |
@matthiasg Thanks for the reminder about this behavior. That sounds reasonable to me. I'll include this in the next release. |
Repro
main.ts
,foo.bar.ts
andfoo.bar
(see below)esbuild --bundle main.ts
Expected:
foo.bar.ts
and ignore thefoo.bar
fileActual:
$ esbuild --bundle main.ts main.ts:1:15: error: File extension not supported: /Users/rsms/esbuild/foo.bar import hi from "./foo.bar" ~~~~~~~~~~~ 1 error
Notes
This can be worked around by
import “./foo.bar.ts”
, however if you run TypeScript’stsc
for type checking, it will complain with an error:File listing
import "./foo.bar"
export default 1
Versions
The text was updated successfully, but these errors were encountered: