From f8a95204386844afdb1d1bfcf82bcdaf4fa89559 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Fri, 27 Nov 2026 16:34:06 +0900 Subject: [PATCH 1/4] NXT-21937: Support npm workspaces hoisted ilib in jest config 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 --- config/jest/jest.config.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config/jest/jest.config.js b/config/jest/jest.config.js index 17c36671..5c37f487 100644 --- a/config/jest/jest.config.js +++ b/config/jest/jest.config.js @@ -21,9 +21,26 @@ const rbConst = name => '_PATH'; const iLibDirs = ['node_modules/@enact/i18n/ilib', 'node_modules/ilib', 'ilib']; + +// Resolve the ilib base path, supporting npm workspaces where ilib may be +// hoisted to a parent node_modules directory. +function resolveIlibDir(context) { + // Check local directories first (backward compatibility) + const found = iLibDirs.find(f => fs.existsSync(path.join(context, f))); + if (found) return found; + + // Fall back to Node module resolution (supports workspaces hoisting) + try { + const ilibPkg = require.resolve('ilib/package.json', {paths: [context]}); + return path.relative(context, path.dirname(ilibPkg)); + } catch { + return iLibDirs[1]; + } +} + const globals = { __DEV__: true, - ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) || iLibDirs[1], + ILIB_BASE_PATH: resolveIlibDir(app.context), ILIB_RESOURCES_PATH: 'resources', ILIB_CACHE_ID: new Date().getTime() + '', [rbConst(app.name)]: 'resources' From 0fa17cecbfd6e9be96a61e175ec2f25e550e4910 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Fri, 27 Nov 2026 16:50:04 +0900 Subject: [PATCH 2/4] NXT-21937: Fix eslint space-before-function-paren Co-Authored-By: Claude Code --- config/jest/jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/jest/jest.config.js b/config/jest/jest.config.js index 5c37f487..ae6ea845 100644 --- a/config/jest/jest.config.js +++ b/config/jest/jest.config.js @@ -24,7 +24,7 @@ const iLibDirs = ['node_modules/@enact/i18n/ilib', 'node_modules/ilib', 'ilib']; // Resolve the ilib base path, supporting npm workspaces where ilib may be // hoisted to a parent node_modules directory. -function resolveIlibDir(context) { +function resolveIlibDir (context) { // Check local directories first (backward compatibility) const found = iLibDirs.find(f => fs.existsSync(path.join(context, f))); if (found) return found; From 5822f03e8e15f1ebad6410ac7edc88e2e714c0f2 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Fri, 27 Nov 2026 17:14:04 +0900 Subject: [PATCH 3/4] NXT-21937: Simplify resolveIlibDir into inline expression Replace the separate function with a single-line expression using the existing iLibDirs.find() with a require.resolve() fallback. Co-Authored-By: Claude Code --- config/jest/jest.config.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/config/jest/jest.config.js b/config/jest/jest.config.js index ae6ea845..3ecaac10 100644 --- a/config/jest/jest.config.js +++ b/config/jest/jest.config.js @@ -21,26 +21,11 @@ const rbConst = name => '_PATH'; const iLibDirs = ['node_modules/@enact/i18n/ilib', 'node_modules/ilib', 'ilib']; - -// Resolve the ilib base path, supporting npm workspaces where ilib may be -// hoisted to a parent node_modules directory. -function resolveIlibDir (context) { - // Check local directories first (backward compatibility) - const found = iLibDirs.find(f => fs.existsSync(path.join(context, f))); - if (found) return found; - - // Fall back to Node module resolution (supports workspaces hoisting) - try { - const ilibPkg = require.resolve('ilib/package.json', {paths: [context]}); - return path.relative(context, path.dirname(ilibPkg)); - } catch { - return iLibDirs[1]; - } -} - const globals = { __DEV__: true, - ILIB_BASE_PATH: resolveIlibDir(app.context), + // Support npm workspaces where ilib may be hoisted to a parent node_modules + ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) + || (() => { try { return path.relative(app.context, path.dirname(require.resolve('ilib/package.json', {paths: [app.context]}))); } catch { return iLibDirs[1]; } })(), ILIB_RESOURCES_PATH: 'resources', ILIB_CACHE_ID: new Date().getTime() + '', [rbConst(app.name)]: 'resources' From f78c5624cb14292991fdd131799f5614a55f5345 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Fri, 27 Nov 2026 17:16:28 +0900 Subject: [PATCH 4/4] NXT-21937: Fix eslint brace-style and operator-linebreak Co-Authored-By: Claude Code --- config/jest/jest.config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/jest/jest.config.js b/config/jest/jest.config.js index 3ecaac10..97d5266e 100644 --- a/config/jest/jest.config.js +++ b/config/jest/jest.config.js @@ -24,8 +24,14 @@ const iLibDirs = ['node_modules/@enact/i18n/ilib', 'node_modules/ilib', 'ilib']; const globals = { __DEV__: true, // Support npm workspaces where ilib may be hoisted to a parent node_modules - ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) - || (() => { try { return path.relative(app.context, path.dirname(require.resolve('ilib/package.json', {paths: [app.context]}))); } catch { return iLibDirs[1]; } })(), + ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) || + (() => { + try { + return path.relative(app.context, path.dirname(require.resolve('ilib/package.json', {paths: [app.context]}))); + } catch { + return iLibDirs[1]; + } + })(), ILIB_RESOURCES_PATH: 'resources', ILIB_CACHE_ID: new Date().getTime() + '', [rbConst(app.name)]: 'resources'