BREAKING! Hybrid build to CommonJS and ES Modules #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #6
Current Problem
Currently, this package doesn't expose a module. It just specifies
files
key withlib
folder.This is why
laravel-orion-ts
couldn't be used in Next.js applications.Solution
build
script to build separately two versions: CommonJS (under./dist/cjs
) and ES Modules (under./dist/esm
). It's necessary because in most cases plain ES Modules aren't transpiled and couldn't be used (at least in Next.js apps right now)index
file as entry point for our module, which currently exposes common entities.package.json
for both module types.Why breaking change
It could break up things, and it will be better to ship new major version.
In most cases this import would work:
Import as CommonJS module:
or as ES module:
I leave this PR in Draft while discussion isn't finished.
Possible points to discuss
dist
directory at all and build files to<package-root>/cjs
and<package-root>/esm
or whatever