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
Unique package detection, when importing both as CommonJS and ESM #4315
Comments
The (EDIT: Had a brief play with my hack, will have to wait 6+ months until WP4 is indeed deal as just do it correctly - trying to hack this is just a road to insanity, as horrible as having no paths are, it is a nightmare between Web, Node and RN to make it nice and clean/portable) Anyway, back on-topic... let me ponder this question a bit as of now have no clue. (EDIT 2: Still pondering...) |
So this is exactly the dual-package-hazard, https://nodejs.org/api/packages.html#dual-package-hazard So comments on what was laid out -
On the last point, this may not be "as slow as imagined" i.e. you can have a |
See the chore here - KILTprotocol/sdk-js#446 (it is a start, not a full-blown final solution) |
Yes, that seems exactly what it is. |
The issue with ESM-only is that is forced all users to be ESM-only as well. It will break the world and force everybody to migrate. So it is not on the cards for at least 12 months. (Probably longer) The issue with shim-ing ESM from CJS is that the CJS outputs are absolutely crazy horrible. There is a lot of baggage in that world. Plus it makes the whole development process 2x as strenuous since everything is doubled-up as source instead of just as a compile-step. |
This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days. |
I'm going to close this. It has 2 parts - (a) it is absolutely horrible having to dictate what downstream packages do, i.e. having to do both ESM and CJS to not run into the dual-package hazard trap With this in mind, it is certainly an issue, but at this point one with no real solution. |
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. |
General issue description
We have built a library on top of polkadot/api (and other @PolkaDot packages), which currently only transpiles to CommonJS.
Since polkadot/api supports both ESM and CommonJS, but requires projects to import modules just once, people using both our library and the polkadot/api directly, with ESM import, get warnings in the console.
Additionally, the warnings include
<unknown>
for the second path, which I don't know why and doesn't hint to the underlying problem.I have added some solutions, we thought of at the bottom of this issue, but wanted to get another opinion, maybe you already thought of something like this.
So what do you think would be the best solution?
How to reproduce
yarn init
yarn add @polkadot/util-crypto
yarn add @kiltprotocol/sdk-js
"type": "module"
inpackage.json
index.js
node index.js
Output will be similar to:
Solutions, we thought of
mnemonicGenerate
) (? / fast)The text was updated successfully, but these errors were encountered: