[Bug]: Published package can't be resolved by Node's ESM resolver
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- build-system
Research direction
Start by reproducing the failure with the Node import command in the issue and inspect the package's emitted .js files and exports. Check the extensionless imports, the *styles.css.js CSS imports, and theming-runtime's browser/index.js imports. Done means the affected package subpaths resolve under Node's ESM resolver, with the SSR reproduction no longer failing.
Written by the indexing model from the issue text.
Description
Browser
No response
Package version
v3.0.1352
React version
No response
Description
Many of the subpaths declared in @cloudscape-design/components' exports subpath fail to load under Node's ESM resolver. Example:
$ node -e "import('@cloudscape-design/components/button')"
ERR_UNSUPPORTED_DIR_IMPORT: Directory import '.../components/internal/base-component'
is not supported resolving ES modules imported from '.../components/button/index.js'
This issue isn't observed in most bundlers (including Vite in its default configuration) because they use their own, more forgiving ESM resolver. But if you run vite build --ssr, dependencies are externalized and handed to Node at runtime, triggering the error.
There are three separate root causes:
- Emitted relative specifiers omit the extension. 2,880 of 3,764 relative specifiers in the emitted .js are extensionless: 925 name a directory (needing /index.js), 1,955 name a file (needing .js), and 0 are unresolvable or ambiguous. Node's ESM resolver doesn't probe extensions and has no directory-index fallback.
.cssimports. The 229 emitted*styles.css.jsimport'./styles.scoped.css', and Node has no loader for.css.theming-runtimehas three extensionless directory imports inbrowser/index.js, which is the./themingsubpath.
Previous related discussion: https://github.com/cloudscape-design/components/discussions/1768
Source code
No response
Reproduction
You can recreate this in the CLI:
mkdir esm-repro && cd esm-repro && echo '{"type":"module"}' > package.json
npm i @cloudscape-design/components react react-dom
node -e "import('@cloudscape-design/components')"
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate problems
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 248
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 83
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudscape-design/components
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cloudscape-design/components#5184 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudscape-design/components#5152 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 15/100
cloudscape-design/components#5149 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
cloudscape-design/components#5117 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
cloudscape-design/components#5106 · 1 comment ·
Maintainers usually reply within 2 days
All issues in cloudscape-design/components
Similar issues
-
bug hacktoberfest help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
libredb/libredb-studio#1941 ·
Maintainers usually reply within 1 day
-
chore other
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
alastair-smith/card-games#308 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
paperclipai/paperclip#17379 ·
Maintainers usually reply within 1 day
-
[good first issue, hacktoberfest] 🏯 Hacktoberfest Task - Add new Anime Quote 626 (good-first-issue)Opencommunity first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
lingdojo/kana-dojo#33040 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
bug mobile ui
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day