Skip to content

fix(design-core): emit Node-compatible ES modules - #898

Merged
gamegee merged 2 commits into
mainfrom
fix/design-core-node-esm
Oct 15, 2026
Merged

gamegee merged 2 commits into
mainfrom
fix/design-core-node-esm

Conversation

@gamegee

@gamegee gamegee commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Description

@ledgerhq/lumen-design-core's built output only loads through bundlers. Its relative imports have no file extension (import … from './lib/themes/css/index'), which plain Node rejects for ES modules:

Cannot find module '…/design-core/dist/lib/themes/css/index' imported from …/design-core/dist/index.js

This breaks any tool that loads a tailwind.config.ts importing the Lumen presets with Node. For example, @shadcn/lint can't build Lumen's theme, so its no-unknown-classes rule reported 373 valid Lumen classes as unknown on ui-react (body-2, heading-4…). With this fix, it reports 9, all real.

  • All 136 extensionless relative imports in libs/design-core/src (39 files) now carry .js, or /index.js for folders. The change was made by a codemod, and every path was resolved against an existing file.
  • tsconfig.lib.json uses nodenext module resolution, so the compiler rejects any new extensionless import.
  • No API change. Consumers go through dist, and nothing imports design-core's source directly.
  • Patch version plan included.

Split out of #895 (lint presets), where it was found.

How to test

  1. npx nx run-many -t build test typecheck lint --projects=@ledgerhq/lumen-design-core should pass (112 tests).
  2. node --input-type=module -e "await import('./libs/design-core/dist/index.js')" should succeed. On main it fails with the error above.
  3. Everything depending on design-core should still build and test: npx nx run-many -t build typecheck test --projects=@ledgerhq/lumen-ui-react,@ledgerhq/lumen-ui-rnative,@ledgerhq/lumen-utils-shared (verified locally, including ui-rnative's 1,419 Jest tests).

Screenshots

N/A (no UI change).

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 7, 2026 16:22
@gamegee
gamegee requested a review from a team as a code owner October 7, 2026 16:22
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ldls Ready Ready Preview Oct 15, 2026 9:31am UTC
ldls-react-native Ready Ready Preview Oct 15, 2026 9:31am UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

All 148 relative specifiers use .js, resolve to source files, and the release plan follows repository requirements.

0 open findings

What changed in this PR

Updates @ledgerhq/lumen-design-core output so it can be loaded directly by Node.js as ESM.

Changes:

  • Adds .js extensions to all relative imports and exports.
  • Enables nodenext compilation and resolution.
  • Adds the required patch version plan.
File Description
libs/​design-core/​tsconfig.lib.json Enforces Node-compatible ESM resolution.
libs/​design-core/​src/​lib/​utils/​createPrimitivesPlugin.ts Adds explicit ESM extensions.
libs/​design-core/​src/​lib/​utils/​createIconUtilities.test.ts Updates test import.
libs/​design-core/​src/​lib/​themes/​jsThemeSync.test.ts Updates theme synchronization imports.
libs/​design-core/​src/​lib/​themes/​js/​websites/​theme.ts Updates website theme imports.
libs/​design-core/​src/​lib/​themes/​js/​websites/​theme.light.ts Updates light-theme imports.
libs/​design-core/​src/​lib/​themes/​js/​websites/​theme.dark.ts Updates dark-theme imports.
libs/​design-core/​src/​lib/​themes/​js/​utils/​extractCryptoGradients.ts Updates primitive token import.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​typography.xs.ts Updates typography imports.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​typography.xl.ts Updates typography imports.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​typography.sm.ts Updates typography imports.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​typography.md.ts Updates typography imports.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​typography.lg.ts Updates typography imports.
libs/​design-core/​src/​lib/​themes/​js/​typographies/​index.ts Updates typography barrel imports.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitives.shadows.ts Updates primitive imports.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitives.others.ts Updates type import.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitives.motion.ts Updates type import.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitive.typographies.ts Updates type import.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitive.gradients.ts Updates gradient imports.
libs/​design-core/​src/​lib/​themes/​js/​primitives/​primitive.colors.ts Updates type import.
libs/​design-core/​src/​lib/​themes/​js/​ledger-live/​theme.ts Updates Ledger Live theme imports.
libs/​design-core/​src/​lib/​themes/​js/​ledger-live/​theme.light.ts Updates light-theme imports.
libs/​design-core/​src/​lib/​themes/​js/​ledger-live/​theme.dark.ts Updates dark-theme imports.
libs/​design-core/​src/​lib/​themes/​js/​index.ts Updates JS theme exports.
libs/​design-core/​src/​lib/​themes/​js/​enterprise/​theme.ts Updates enterprise theme imports.
libs/​design-core/​src/​lib/​themes/​js/​enterprise/​theme.light.ts Updates light-theme imports.
libs/​design-core/​src/​lib/​themes/​js/​enterprise/​theme.dark.ts Updates dark-theme imports.
libs/​design-core/​src/​lib/​themes/​css/​tokenIntegrity.test.ts Updates token test imports.
libs/​design-core/​src/​lib/​themes/​css/​index.ts Updates CSS token imports.
libs/​design-core/​src/​lib/​presets/​websites.ts Updates preset imports.
libs/​design-core/​src/​lib/​presets/​ledger-live.ts Updates preset imports.
libs/​design-core/​src/​lib/​presets/​index.ts Updates preset exports.
libs/​design-core/​src/​lib/​presets/​enterprise.ts Updates preset imports.
libs/​design-core/​src/​lib/​presets/​allBrands.ts Updates preset imports.
libs/​design-core/​src/​lib/​cssVar/​cssVar.ts Updates theme type import.
libs/​design-core/​src/​lib/​cssVar/​cssVar.test.ts Updates test imports.
libs/​design-core/​src/​lib/​colorContrast/​hslToHex.ts Updates type import.
libs/​design-core/​src/​lib/​colorContrast/​colorContrast.ts Updates utility imports.
libs/​design-core/​src/​lib/​colorContrast/​colorContrast.test.ts Updates test import.
libs/​design-core/​src/​index.ts Updates public barrel exports.
.nx/​version-plans/​version-plan-1791391200000-design-core.md Adds the required patch release plan.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Relative imports in the built output had no file extension, so `dist`
only loaded through bundlers and lenient loaders. Plain Node, used for
example by @shadcn/lint to load a `tailwind.config.ts` that imports the
Lumen presets, rejected it.

All relative imports in `src` now carry their `.js` (or `/index.js`)
extension, and the build uses `nodenext` resolution so the compiler
rejects new extensionless imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@zel-kass zel-kass left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Signed-off-by: Simon Bruneaud <simon.bruneaud@ledger.fr>
@sonarqubecloud

Copy link
Copy Markdown

@gamegee
gamegee merged commit 4528cac into main Oct 15, 2026
24 checks passed
@gamegee
gamegee deleted the fix/design-core-node-esm branch October 15, 2026 09:34

This branch was successfully deployed

2 active deployments
Preview – ldls-react-native — d1e33319 Deployed Oct 15, 2026 by vercel[bot]
Preview – ldls — d1e33319 Deployed Oct 15, 2026 by vercel[bot]
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.

3 participants