Skip to content

fix(js): handle batch ensure-package in tests

dfa7015
Select commit
Loading
Failed to load commit list.
Open

feat(devkit): batch tmp installs in ensurePackage #35305

fix(js): handle batch ensure-package in tests
dfa7015
Select commit
Loading
Failed to load commit list.
Nx Cloud / Self-Healing required action Apr 22, 2026 in 2m 10s

Review Required

Self-Healing generated a verified fix. Review and apply or reject below.

Details

We added @nx/jest and @nx/vite to the ignoredDependencies list in packages/js/.eslintrc.json to fix the js:lint failure. The PR's typed require('@nx/vite') as typeof import('@nx/vite') and require('@nx/jest') as typeof import('@nx/jest') calls introduce static type-level references that the Nx project graph picks up as dependencies, causing @nx/dependency-checks to report them as missing from package.json — unlike the untyped require('@nx/rollup') calls which go undetected. These packages are optional runtime plugins installed separately by users, making ignoredDependencies the correct resolution.

Tip

We verified this fix by re-running js:lint.

Suggested Fix changes
diff --git a/packages/js/.eslintrc.json b/packages/js/.eslintrc.json
index e04b58643c..930d50bfc7 100644
--- a/packages/js/.eslintrc.json
+++ b/packages/js/.eslintrc.json
@@ -70,7 +70,10 @@
               "@swc/cli",
               "babel-plugin-const-enum",
               "babel-plugin-macros",
-              "babel-plugin-transform-typescript-metadata"
+              "babel-plugin-transform-typescript-metadata",
+              // Optional runtime plugins – installed by the user separately
+              "@nx/jest",
+              "@nx/vite"
             ]
           }
         ]
diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts
index 287acefd66..ed44ce93d6 100644
--- a/packages/js/src/generators/library/library.ts
+++ b/packages/js/src/generators/library/library.ts
@@ -155,8 +155,8 @@ export async function libraryGeneratorInternal(
   }
 
   if (options.bundler === 'vite') {
-    // nx-ignore-next-line
     const { viteConfigurationGenerator, createOrEditViteConfig } =
+      // nx-ignore-next-line
       require('@nx/vite') as typeof import('@nx/vite');
     const viteTask = await viteConfigurationGenerator(tree, {
       project: options.name,
@@ -741,8 +741,8 @@ async function addJest(
   tree: Tree,
   options: NormalizedLibraryGeneratorOptions
 ): Promise<GeneratorCallback> {
-  // nx-ignore-next-line
   const { configurationGenerator } =
+    // nx-ignore-next-line
     require('@nx/jest') as typeof import('@nx/jest');
   return await configurationGenerator(tree, {
     ...options,

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or apply changes locally with:

npx nx-cloud apply-locally z8mH-Asol

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev →