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

Vend CommonJS module as well as ESM (dual vend) #28

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

vcschapp
Copy link
Contributor

Description

Per the discussion in #26, this PR configures the module to vend a CommonJS (CJS) module as well as an ESM module.

I followed the example of https://github.com/slevithan/regex, which is another one of Steven's libraries that is dual-vended already and also is a dependency of this one, as closely as possible, while making what I hope is the minimum number of edits and changes.

Testing

$ pnpm run build

package.json Outdated Show resolved Hide resolved
@slevithan
Copy link
Owner

Thanks for the PR.

Yeah, it should continue externalizing the dependencies.

Also, it needs to have separate paths for the ESM and CJS types so the package.json file in the respective directories can have the appropriate type value (Regex+ sets this up with a postbuild script). That isn't the only possible solution to make type resolution work for both ESM and CJS, but it's a simple one, and if you're changing the solution, please verify that type resolution works for both.

@vcschapp
Copy link
Contributor Author

vcschapp commented Jan 13, 2025

Thanks for the PR.

Yeah, it should continue externalizing the dependencies.

Also, it needs to have separate paths for the ESM and CJS types so the package.json file in the respective directories can have the appropriate type value (Regex+ sets this up with a postbuild script). That isn't the only possible solution to make type resolution work for both ESM and CJS, but it's a simple one, and if you're changing the solution, please verify that type resolution works for both.

Thanks for this. I'll endeavor to put that into practice. I should be able to copy the pattern from regex library also. I'll test it.

@slevithan slevithan merged commit 6d543f3 into slevithan:main Jan 14, 2025
2 checks passed
slevithan added a commit that referenced this pull request Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants