Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Published package can't be resolved by Node's ESM resolver

Open
#4,948 2 comments 0 reactions 0 assignees View on GitHub

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

enhancement
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:

  1. 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.
  2. .css imports. The 229 emitted *styles.css.js import './styles.scoped.css', and Node has no loader for .css.
  3. theming-runtime has three extensionless directory imports in browser/index.js, which is the ./theming subpath.

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
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudscape-design/components

All issues in cloudscape-design/components

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.