Skip to content

NXT-21937: Support npm workspaces hoisted ilib in jest config - #410

Open
hong6316 wants to merge 4 commits into
developfrom
feature/NXT-21937
Open

hong6316 wants to merge 4 commits into
developfrom
feature/NXT-21937

Conversation

@hong6316

@hong6316 hong6316 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • I have run automated testing and it is passed
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

NXT-21937: The jest config ilib base path resolution only checked directories relative to app.context (the package directory). In an npm workspaces monorepo, dependencies are hoisted to the root node_modules, so ilib was not found at packages/*/node_modules/ilib, causing jest moduleNameMapper and ILIB_BASE_PATH to point to non-existent paths.

Resolution

Added resolveIlibDir() to config/jest/jest.config.js that:

  1. First checks the existing local paths (node_modules/@enact/i18n/ilib, node_modules/ilib, ilib) for backward compatibility
  2. Falls back to require.resolve("ilib/package.json", {paths: [context]}) which follows Node's standard module resolution and naturally walks up to parent node_modules directories

This fixes both moduleNameMapper and ILIB_BASE_PATH for projects using npm workspaces without requiring symlink workarounds.

Tested against enactjs/enact with npm workspaces enabled — all 107 test suites pass (core 21, i18n 6, spotlight 15, ui 63, webos 2).

Additional Considerations

Fully backward compatible — the existing local directory checks run first, and require.resolve is only used as a fallback when none of them match.

Links

NXT-21937

Comments

Enact-DCO-1.0-Signed-off-by: Taeyoung Hong (taeyoung.hong@lge.com)

hong6316 and others added 4 commits November 27, 2026 16:34
The ilib base path resolution only checked directories relative to
the package directory (app.context). In an npm workspaces monorepo,
dependencies are hoisted to the root node_modules, so ilib is not
found at packages/*/node_modules/ilib.

Add resolveIlibDir() that first checks the existing local paths
for backward compatibility, then falls back to require.resolve()
which follows Node's standard module resolution and naturally
walks up to parent node_modules directories.

This fixes jest moduleNameMapper and ILIB_BASE_PATH for projects
using npm workspaces without requiring symlink workarounds.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Replace the separate function with a single-line expression using
the existing iLibDirs.find() with a require.resolve() fallback.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
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.

1 participant