Skip to content

Commit e1fb8fa

Browse files
committed
fixup! use the current platform for --os in dev
1 parent acb64b2 commit e1fb8fa

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,28 @@ To run `OpenNext` locally:
9898

9999
There is also a way to run OpenNext locally. You can read a guide about it [here](https://opennext.js.org/aws/contribute/local_run). Its mostly used for development/debugging purposes.
100100

101-
### Coldstart
101+
## Testing
102+
103+
You can run unit tests with
104+
105+
```bash
106+
pnpm test
107+
```
108+
109+
You can tun e2e locally with:
110+
111+
```bash
112+
pnpm -r openbuild:local
113+
pnpm -r openbuild:local:start
114+
```
115+
116+
And in a different shell:
117+
118+
```bash
119+
pnpm e2e:test
120+
```
121+
122+
## Coldstart
102123

103124
OpenNext provide you with a warmer function that can be used to reduce cold start.
104125

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "node:fs";
22
import { createRequire } from "node:module";
3+
import os from "node:os";
34
import path from "node:path";
45

56
import logger from "../logger.js";
@@ -112,12 +113,17 @@ export async function createImageOptimizationBundle(
112113

113114
const sharpVersion = process.env.SHARP_VERSION ?? "0.32.6";
114115

116+
// In development, we want to use the local machine settings
117+
const isDev = config.imageOptimization?.loader === "fs-dev";
118+
115119
installDependencies(
116120
outputPath,
117121
config.imageOptimization?.install ?? {
118122
packages: [`sharp@${sharpVersion}`],
119-
// By not specifying an arch, `npm install` will choose one for us (i.e. our system one)
120-
arch: config.imageOptimization?.loader === "fs-dev" ? undefined : "arm64",
123+
// By not specifying an arch in dev, `npm install` will choose one for us (i.e. our system one)
124+
arch: isDev ? undefined : "arm64",
125+
// Use the local platform in dev
126+
os: isDev ? os.platform() : "linux",
121127
nodeVersion: "18",
122128
libc: "glibc",
123129
},

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ export function installDependencies(
3434
const libcOption = installOptions.libc
3535
? `--libc=${installOptions.libc}`
3636
: "";
37+
const osOption = installOptions.os ? `--os=${installOptions.os}` : "linux";
3738

3839
const additionalArgs = installOptions.additionalArgs ?? "";
39-
const installCommand = `npm install --os=linux ${archOption} ${targetOption} ${libcOption} ${additionalArgs} ${installOptions.packages.join(" ")}`;
40+
const installCommand = `npm install ${osOption} ${archOption} ${targetOption} ${libcOption} ${additionalArgs} ${installOptions.packages.join(" ")}`;
4041
execSync(installCommand, {
4142
stdio: "pipe",
4243
cwd: tempInstallDir,

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,15 @@ export interface InstallOptions {
296296
* ```
297297
*/
298298
packages: string[];
299-
/**
300-
* @default undefined
301-
*/
299+
/** @default undefined */
302300
arch?: "x64" | "arm64";
303-
/**
304-
* @default undefined
305-
*/
301+
/** @default undefined */
306302
nodeVersion?: string;
307-
/**
308-
* @default undefined
309-
*/
303+
/** @default undefined */
310304
libc?: "glibc" | "musl";
305+
/** @default "linux" */
306+
os?: string;
307+
311308
/**
312309
* @default undefined
313310
* Additional arguments to pass to the install command (i.e. npm install)

0 commit comments

Comments
 (0)