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

The path "./xxx" is not currently exported by package "xxx" (and bonus: sideEffects false) #2163

Closed
Kiyozz opened this issue Apr 7, 2022 · 1 comment

Comments

@Kiyozz
Copy link

Kiyozz commented Apr 7, 2022

Stack :

  • nodejs 16.13
  • electron 18
  • esbuild 0.14.29

When trying to use Sentry in my electron project, I found a problem with exports map.

Screens

import

CleanShot 2022-04-07 at 15 07 22

sentry's package json

CleanShot 2022-04-07 at 15 07 17

esbuild output

CleanShot 2022-04-07 at 15 07 10

@sentry/electron package

CleanShot 2022-04-07 at 15 17 20

/main/index.js file

esbuild report that this import does not exist because of the package.json exports map (I think). But this module exists. esbuild is not searching for a "module" key inside the exports map.

BONUS

Side effect false positive

CleanShot 2022-04-07 at 15 20 54

Because in the package.json, the project is marked as sideEffects: false, this file can't be imported. But this file is not sideEffects free.

Feel free to ask me any more details. Or just RTFM me 😄

@evanw
Copy link
Owner

evanw commented Apr 7, 2022

This package looks broken. The correct condition name for imports is import not module: https://nodejs.org/api/packages.html#conditional-exports. The name module is meaningless here. The package author should fix their broken exports map. They should also fix their incorrect sideEffects annotation.

You may be able to work around the incorrect exports map with --conditions=module and you may be able to work around the incorrect sideEffects annotation with --tree-shaking=ignore-annotations, but you should ideally get the package author to fix their broken package instead as those flags can have other negative side effects on your bundle. You can read more about those API options in the docs: https://esbuild.github.io/api/.

Closing this issue because it’s a problem with the package, not with esbuild.

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

No branches or pull requests

2 participants