Adds CommonJS to regex/internals #31
Closed
+17
−5
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.
This is adding CJS/ESM to export
regex/internals.attwlooks good to me.As
regexalready supports CommonJS. This pull request would improve platform support for usingregex/internals(and transient dependents) in environments that doesn't fully support ESM. For example, Webpack 4, which is still commanding about 25.8% of Webpack weekly installations based on data from latest v4 vs. v5.As
regexis gaining popularity, packages that transiently depends onregex/internalsmay need this little lifts to get onboard the train. One such example is the very popular code syntax highlightershiki, which has > 2M weekly downloads. It transiently depends onregex/internals.regexis building block for great packages. Personally, as the package already support CommonJS, I think it makes sense to improveregex/internalssupport for broader platforms as well, including some popular but slowly deprecating platforms. It would help dependents to improve their build environment supports.The other way to solve the problem would be embedding all packages down to
regexvia esbuildnoExternaloptions. While this is an acceptable solution, it would hurt vulnerability patching process as the code is embedded deeply.I hope you would consider this pull request.
Notes: barrel files at the root is required for Webpack 4 as it does not understand
package.json/exports. It could be moved to another directory and copied to the root with the post-build script. I have tested this with a vanilla Webpack 4 +babel-loadersetup.