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

Fix exports #749

Merged
merged 1 commit into from
Jul 22, 2022
Merged

Fix exports #749

merged 1 commit into from
Jul 22, 2022

Conversation

caseywebdev
Copy link
Contributor

@caseywebdev caseywebdev commented Jul 19, 2022

The recent exports change broke ESM imports. Attempting to import '@svgr/core' results in

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /code/node_modules/@svgr/core/package.json imported from ...

According to https://nodejs.org/api/packages.html#conditional-exports, a default key should be used here instead of require since it will work for both CJS and ESM. I made this change locally and verified ESM imports worked again.

@vercel
Copy link

vercel bot commented Jul 19, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
svgr ✅ Ready (Inspect) Visit Preview Jul 19, 2022 at 3:26PM (UTC)

@caseywebdev
Copy link
Contributor Author

Reproduction:

$ npm install @svgr/core@6.2
$ node -e "import('@svgr/core').catch(console.error.bind(console))"
# no error
$ npm install @svgr/core@6.3.0
$ node -e "import('@svgr/core').catch(console.error.bind(console))"
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/casey/node_modules/@svgr/core/package.json imported from ...
  ...

@caseywebdev
Copy link
Contributor Author

Thanks!

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