-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Implement 'exports' field in package.json for the core & basics setup packages #692
Conversation
react-codemirror/core/package.json Lines 11 to 17 in c2437c7
@fatton139 modified |
Thanks for fixing that, no problems on our side. Cheers! |
This change now breaks my build and I always get this error:
|
@sotasan Could you provide an example to help us resolve this issue? |
Added exports field to the core (@uiw/react-codemirror) and basic setup (@uiw/codemirror-extensions-basic-setup) package.json so Node-like environments such as the test runners can utilise the esm outputs.
Context:
Our unit tests are failing with:
After some investigation, it looks like when this library is used in a Node environment all imports use the cjs output.
main
andmodule
are already defined and work for bundlers. However, Node doesn't have support formodule
and opts to look inexports
for entry points. Sinceexports
is not defined it falls back tomain
meaning Node will use the cjs outputs of this library. Normally this is fine, but the@codemirror
packages (i.e. @codemirror/language) in thepeerDependencies
do defineexports
so the esm outputs are used if we use any of those packages are used in our source code resulting in the error above.We're using
@codemirror/language
to construct an extension that gets passed intouseCodeMirror
, where cjs is used but the extension uses the esm output. This results in theinstanceof
checfailingil as the esm instance is not the cjs class.Likely related to #680 as they're using SSR which is potentially also in a Node-like environment.
We've manually modified the package.json locally to include the
export
field asserted our tests are passing and are using the correct esm output.