From 3fde364d4b0a3ac431facaaa39beb4a4b0bbc237 Mon Sep 17 00:00:00 2001 From: Advait Paliwal Date: Tue, 24 Mar 2026 10:48:08 -0700 Subject: [PATCH] Fix Windows native bundle dependency staging --- scripts/build-native-bundle.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/build-native-bundle.mjs b/scripts/build-native-bundle.mjs index 2db5f76..46099d7 100644 --- a/scripts/build-native-bundle.mjs +++ b/scripts/build-native-bundle.mjs @@ -6,6 +6,7 @@ import { spawnSync } from "node:child_process"; const appRoot = resolve(import.meta.dirname, ".."); const packageJson = JSON.parse(readFileSync(resolve(appRoot, "package.json"), "utf8")); const packageLockPath = resolve(appRoot, "package-lock.json"); +const rootNodeModulesPath = resolve(appRoot, "node_modules"); const bundledNodeVersion = process.env.FEYNMAN_BUNDLED_NODE_VERSION ?? process.version.slice(1); function fail(message) { @@ -120,6 +121,18 @@ function copyPackageFiles(appDir) { cpSync(packageLockPath, resolve(appDir, "package-lock.json")); } +function installAppDependencies(appDir) { + if (existsSync(rootNodeModulesPath)) { + cpSync(rootNodeModulesPath, resolve(appDir, "node_modules"), { recursive: true }); + run("npm", ["prune", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund", "--loglevel", "error"], { + cwd: appDir, + }); + return; + } + + run("npm", ["ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund", "--loglevel", "error"], { cwd: appDir }); +} + function extractTarball(archivePath, destination, compressionFlag) { run("tar", [compressionFlag, archivePath, "-C", destination]); } @@ -253,7 +266,7 @@ function main() { ensureBundledWorkspace(); copyPackageFiles(appDir); - run("npm", ["ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund", "--loglevel", "error"], { cwd: appDir }); + installAppDependencies(appDir); const appFeynmanDir = resolve(appDir, ".feynman"); extractTarball(resolve(appFeynmanDir, "runtime-workspace.tgz"), appFeynmanDir, "-xzf");