@@ -446,15 +446,42 @@ describe("plugin npm package manifest staging", () => {
446446 } ) ;
447447
448448 const nodeModulesPath = join ( packageDir , "node_modules" ) ;
449- withAugmentedPluginNpmManifestForPackage (
450- { repoRoot : repoDir , packageDir, bundleDependencies : true } ,
451- ( ) => {
452- expect ( existsSync ( join ( nodeModulesPath , "local-runtime-dep" , "package.json" ) ) ) . toBe ( true ) ;
453- expect ( existsSync ( join ( nodeModulesPath , "optional-platform-dep" , "package.json" ) ) ) . toBe (
454- true ,
455- ) ;
456- } ,
457- ) ;
449+ const manifestModuleUrl = new URL (
450+ "../scripts/lib/plugin-npm-package-manifest.mjs" ,
451+ import . meta. url ,
452+ ) . href ;
453+ const childSource = `
454+ import { existsSync } from "node:fs";
455+ import { join } from "node:path";
456+ import { withAugmentedPluginNpmManifestForPackage } from ${ JSON . stringify ( manifestModuleUrl ) } ;
457+
458+ const packageDir = ${ JSON . stringify ( packageDir ) } ;
459+ const nodeModulesPath = ${ JSON . stringify ( nodeModulesPath ) } ;
460+ withAugmentedPluginNpmManifestForPackage(
461+ {
462+ repoRoot: ${ JSON . stringify ( repoDir ) } ,
463+ packageDir,
464+ bundleDependencies: true,
465+ },
466+ () => {
467+ if (!existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))) {
468+ throw new Error("missing bundled runtime dependency");
469+ }
470+ if (!existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))) {
471+ throw new Error("missing portable optional bundled dependency");
472+ }
473+ process.stdout.write("pack-json\\n");
474+ },
475+ );
476+ ` ;
477+ const result = spawnSync ( process . execPath , [ "--input-type=module" , "--eval" , childSource ] , {
478+ cwd : repoDir ,
479+ encoding : "utf8" ,
480+ env : process . env ,
481+ } ) ;
482+
483+ expect ( result . status , result . stderr ) . toBe ( 0 ) ;
484+ expect ( result . stdout ) . toBe ( "pack-json\n" ) ;
458485
459486 expect ( existsSync ( nodeModulesPath ) ) . toBe ( false ) ;
460487 } ) ;
0 commit comments