-
Notifications
You must be signed in to change notification settings - Fork 355
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
[Request] Add .js
file extensions to generated imports
#5524
Comments
"As we all know, commonJs / ESM compatibility is really annoying." That has to be the understatement of the 2020's :) It is not just a simple fix here actually since the generation itself also affects all the polkadot-js code which uses extensionless imports everywhere. So it actually means adapting all polkadot-js repos to first use ... that is the bad news, the good news is that I have been pondering doing exactly that. (It probably means re-adjusting the export maps in packages as well) |
After a PR marathon above (once all are released stuff like At least the specific commented-on generation will now align, cannot vouch everything else - the typegen stuff is hairy so sadly atm it is a bit of a whack-a-mole to find where templates/code should get extensions. TL;DR Could work, if not, specifics to "where there are holes" would cover the rest. |
Related to this, after the PR of this issue #5440 merged, I am not longer unable to generate types. Getting the same error about Unknown file extension ".ts". What would be the correct |
@montogeek Ok, that sounds worrying - could you please log a separate issue with to not cross lines - it makes it easy to miss stuff otherwise when seemingly related stuff are bundled together. Please do include as much details as possible as well -
|
Verified this is working correctly in |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query. |
I'm submitting a ...
What is the current behavior and expected behavior?
As we all know, commonJs / ESM compatibility is really annoying. One such issues is when relative imports lack a
.js
extension. This means when using the typegen facility of polkadotJs, the generated interfaces (Typescript) are all non-esm compatible:I could look to using a bundler to rewrite paths, but it is far far simpler to just fix it source.
This is not going to be fixed by MS: microsoft/TypeScript#49083 (comment)
Now there are workarounds for this, such as providing an experimental flag to node to override, but these are being phased out in newer versions of node - and instead custom loaders are expected to override this behaviour.
Furthermore, these workarounds are unreliable and tend to fail when the dependency graph is large (like with polkadotJs).
To allow me to import augmented apis into a custom substrate test framework, which combines them.
Please tell us about your environment:
Version:
Environment:
Language:
The text was updated successfully, but these errors were encountered: