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
Question around ESM support for bundlers + node #513
Comments
I'm definitely curious to hear @emmatown's perspective on this, but I went somewhat deep into it by way of evaluating unbuild as a potential replacement for Preconstruct because it does provide ESM stubs (via jiti). Unfortunately, those stubs only work for Node.js, and therefore do not address linking packages to be consumed by something that uses a bundler, like Next.js. I'm honestly not even sure if hooking into the experimental and very unstable loaders API would work for that case. You can see a bit more of my related ramblings in a comment over there. |
To start, Also, Preconstruct is unlikely to ever emit ESM targeting Node + CommonJS like some other tools do because ESM targeting Node (the For bundlers, you have to configure them to compile all TS and etc. outside of
Is there a particular reason why you want ESM stubs? What problems does importing CommonJS cause? (other than not having named exports (which that solution also doesn't provide), I have thoughts on solving that, though it will likely require re-running |
Hey folks! Love the library, definitely helps making package interop in monorepos easier. With ES what's the current support like, and how should it work for local dev?
Looking at commonjs - it uses the babel hook to transpile on the fly so local development works without any extra work, fantastic! It doesn't look like the ESM output has the same treatment though. Should it? E.g. if I have my package with
"type": "module"
, and have it flow through into the esm module, it won't work during local dev since it's TypeScript and most bundlers (and ts-node) won't transpile node modules without extra effort.If anyone has insight I'd appreciate it, cheers
The text was updated successfully, but these errors were encountered: