Skip to content
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

chore: provide an esm distribution #2166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

me4502
Copy link

@me4502 me4502 commented Nov 15, 2022

What issue does this pull request resolve?

#2015

What changes did you make?

I setup the build script to create a second distribution folder containing esm. This is done by running tsc with two flags passed to it, that alter the output directory, and the module format. The rest uses the existing tsconfig.

I passed the module entrypoint of the package json to this distribution, which allows anything that supports ESM to consume a native ESM version. This allows better tree shaking and scope hoisting for supported environments.

This makes no alterations to existing distributions, and the bundles are left unchanged. This only affects the package when consumed via the package.json file in an environment supporting ESM.

Is there anything that requires more attention while reviewing?

I'm a bit confused about why files in the runtime folder assign a code property that contains a require statement in a string. Currently this continues to point to the CJS variants of the files in case this is required

@cyberwombat
Copy link

dist-esm needs to be added to the files entry of package.json. I had some issues importing it though - my code is all esm but still pulling from dist. Not sure what I am missing though. I played around with adding exports field without success.

@Zamiell
Copy link

Zamiell commented Feb 2, 2023

@epoberezkin Can you please review this pull request? I am trying to update my JavaScript project to use ESM and I use Ajv, so this is a show-stopper for me, and I'm sure many others as well.

@dasa
Copy link

dasa commented Oct 4, 2023

This looks like a great addition 👍🏻 Has anyone found an alternative solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants