-
Notifications
You must be signed in to change notification settings - Fork 311
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
The TypeScript file generated by Fable tries to import a file with a .js extension that does not exist #3686
Comments
I believe in general when importing files in JavaScript, it is recommended to set the extension. This is because, resolution of the import is dependant on the runtime and if you are in the browser for example. Then it can't guess the extension of the file because it doesn't have access to the file system. When generating to TypeScript, Fable should use the |
After additional research, it appears that this is (or should be) considered a bug in Next.js. I am not sure it is reasonable for the Fable compiler to address this issue. |
I think when generating TypeScript Fable should import files using Unless, this is interop import like |
Here is the reason why TypeScript compiler doesn't want to support OTOH, some runtimes only support imports with Perhaps we can introduce another compiler flag just for the TypeScript import extension. (Technically, using |
I didn't know about that. Seems like the current Fable behaviour is the recommended way from TypeScript team. And so indeed if we want to address this issue we should add a new flag. The question is it worth adding it? |
I am closing this issue for now. It seems like we are doing the correct generation and adding a new flag could be confusing. We can re-visit in the future if needed. |
Description
The TypeScript file generated by Fable imports a
.js
file, for exampleHowever, this is problematic in a non-Vite environment because Fable only generates
.ts
files.For reference, I got the following build error when I tried to use the Fable generated TypeScript file with Next.js.)
When Fable generates a TypeScript file, how about omitting the extension of the file to be imported as follows?
Alternatively, I would like to know if there is a recommended way to use TypeScript files in a non-Vite environment (Next.js in this case).
Related information
dotnet fable --version
4.9.0The text was updated successfully, but these errors were encountered: