Skip to content

Commit 4ffd8dd

Browse files
authored
Don't force args for install (#597)
* make install deps args optional * update default for sharp
1 parent dfc174d commit 4ffd8dd

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

packages/open-next/src/build/createImageOptimizationBundle.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ export async function createImageOptimizationBundle(
114114
outputPath,
115115
config.imageOptimization?.install ?? {
116116
packages: [`sharp@${sharpVersion}`],
117+
arch: "arm64",
118+
nodeVersion: "18",
119+
libc: "glibc",
117120
},
118121
);
119122
}

packages/open-next/src/build/installDeps.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ export function installDependencies(
2323
logger.info(`Installing dependencies for ${name}...`);
2424
// We then need to run install in the tempDir
2525
// We don't install in the output dir directly because it could contain a package.json, and npm would then try to reinstall not complete deps from tracing the files
26-
const installCommand = `npm install --arch=${
27-
installOptions.arch ?? "arm64"
28-
} --platform=linux --target=${installOptions.nodeVersion ?? "18"} --libc=${
29-
installOptions.libc ?? "glibc"
30-
} ${installOptions.packages.join(" ")}`;
26+
const archOption = installOptions.arch
27+
? `--arch=${installOptions.arch}`
28+
: "";
29+
const targetOption = installOptions.nodeVersion
30+
? `--target=${installOptions.nodeVersion}`
31+
: "";
32+
const libcOption = installOptions.libc
33+
? `--libc=${installOptions.libc}`
34+
: "";
35+
36+
const additionalArgs = installOptions.additionalArgs ?? "";
37+
const installCommand = `npm install --platform=linux ${archOption} ${targetOption} ${libcOption} ${additionalArgs} ${installOptions.packages.join(" ")}`;
3138
execSync(installCommand, {
3239
stdio: "pipe",
3340
cwd: tempInstallDir,

packages/open-next/src/types/open-next.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,22 @@ export interface InstallOptions {
200200
*/
201201
packages: string[];
202202
/**
203-
* @default "arm64"
203+
* @default undefined
204204
*/
205205
arch?: "x64" | "arm64";
206206
/**
207-
* @default "18"
207+
* @default undefined
208208
*/
209-
nodeVersion?: "18" | "20" | "22";
209+
nodeVersion?: string;
210210
/**
211-
* @default "glibc"
211+
* @default undefined
212212
*/
213213
libc?: "glibc" | "musl";
214+
/**
215+
* @default undefined
216+
* Additional arguments to pass to the install command (i.e. npm install)
217+
*/
218+
additionalArgs?: string;
214219
}
215220

216221
export interface DefaultFunctionOptions<

0 commit comments

Comments
 (0)