fix: export cjs/esm/umd modules explicitly #2747
Closed
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.
Marked version: 4.2.12
Markdown flavor: n/a
Description
Expectation
Including marked in a subpackage should work as expected.
Result
I wish I had a more reproducible setup.
In short, we have a monorepo using
pnpm
. I have a package in that repo that usesmarked
. The file in question looks something like:That package compiles that to CJS, which ends up looking something like:
That module then gets imported in another project in the monorepo, which is a
create-react-app
. I'm trying to upgrade thereact-scripts
in that project, which means I'm also upgrading from Webpack 4 to Webpack 5. That upgrade is going smoothly, except for the above file now throwing theTypeError: Cannot read properties of undefined (reading 'use')
error.What was attempted
If I explicitly export the three generated files, which should be safe to mark as
exports
, I'm able to sidestep this issue in my downstream projects usingresolve
:Which in effect applies @emilmuller's wrokaround to Webpack 5.
Contributor
Committer
In most cases, this should be a different person than the contributor.