-
Notifications
You must be signed in to change notification settings - Fork 207
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
Use ES Modules with type:module #192
Comments
yes I should look into this, thanks |
any update on this? |
Sorry I haven't had the time to get to this. In theory it should be fairly simple (if repetitive) but I wanted to take the time to verify a POC before making updates. Will try to look at this over the holidays. |
one option which can save time with this is to add a small 3-4 line rollup file which compiles an es6 version of the library into There's an example of this here: mcollina/fastq#48 |
@angus-c want some help on this task? |
sure! |
Hey, any updates with this? |
@angus-c I was about start but I think, before any work, we should discuss how we want to do that. I believe there are some strategies to make it work. Copy strategyIf we don't want to change anything, we could simply:
The problem with that is we'll end up having duplicated code. If something needs to be fixed, it'll need to be done in 2 places. Single source of truthSince every package is self contained and written in CJS way, we could use a transpiler tool like SWC, ESbuild, or Rollup and then:
Since you're using a monorepo, it won't be much work. The only thing we should be aware is to run the build process for every new publish. I only can see these 2 approaches, let me know what you want to do so I can help in a more assertive way. Cheers. |
I second this and would love to help with transition. I'm already building a library on top of just, and this move will resolve tree-shaking issues in that |
@raulfdm Yeah I prefer the second option, for maintainability. Running the new build process on publish should be no problem |
@angus-c I've just opened a PR with a proposal. I did for one single package to align with you the direction. If you agreed I'll do for all packages. Otherwise we can refine the approach until we get in strategy I can following for all other packages. |
It'd be great to have
just
be a Node-compatible ES Module withtype: "module"
in the package.jsonI don't remember if there's a backwards-compatible way to have both CJS and
type:module
in the same import, but this is definitely possible:This would enable both:
The text was updated successfully, but these errors were encountered: