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

Can not resolve sub-module #1143

Closed
ije opened this issue Apr 12, 2021 · 3 comments
Closed

Can not resolve sub-module #1143

ije opened this issue Apr 12, 2021 · 3 comments

Comments

@ije
Copy link

ije commented Apr 12, 2021

Screenshot 2021-04-13 at 00 36 34

the screen-shot is from:

yarn add vanillajs-datepicker
echo "export { default } from 'vanillajs-datepicker/js/i18n/locales/cs';" > entry.js
esbuild entry.js --bundle --format=esm --outfile=bundle.js

esbuld 0.11.9

@ije
Copy link
Author

ije commented Apr 12, 2021

i understand esbuild will respect the exports in package.json, but maybe we should support the native path as well.

Screenshot 2021-04-13 at 00 59 16

@evanw
Copy link
Owner

evanw commented Apr 12, 2021

Closing as by design. Node doesn't allow you to access this either, and has the same error message:

$ node -p "require.resolve('vanillajs-datepicker/js/i18n/locales/cs')"
internal/modules/cjs/loader.js:438
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './js/i18n/locales/cs' is not defined by "exports" in node_modules/vanillajs-datepicker/package.json

This is a result of esbuild following node's specification for the exports field. This package uses the import path vanillajs-datepicker/locales/cs not vanillajs-datepicker/js/i18n/locales/cs:

$ node -p "require.resolve('vanillajs-datepicker/locales/cs')"
/Users/evan/Desktop/foo/node_modules/vanillajs-datepicker/js/i18n/locales/cs.js

You have to import this using the path vanillajs-datepicker/locales/cs instead.

@evanw evanw closed this as completed Apr 12, 2021
@ije
Copy link
Author

ije commented Apr 13, 2021

i see, thanks for your replay!

evanw added a commit that referenced this issue Apr 13, 2021
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