Skip to content

Commit a5fab84

Browse files
authored
Reduce install size for linux glibc/musl (#32850)
In Next.js [12.0.1]( https://packagephobia.com/[email protected]), musl support was added which caused linux to install both glibc and musl binaries. This PR adds the `install` script to prevent installing unused binaries, reducing the install size by 47MB. We originally thought this could be added to Node.js core and thus npm but [it was rejected](nodejs/node#41338). Note getReport() works on Node.js [`>=11.8.0`](https://nodejs.org/api/process.html#processreportgetreporterr) which is safe to use since Next.js requires [`"node": ">=12.22.0"`](https://github.com/vercel/next.js/blob/265f71e225ed18fcb099c28cf1b5c83519acc3b0/packages/next/package.json#L280).
1 parent d0e72fd commit a5fab84

File tree

8 files changed

+28
-4
lines changed

8 files changed

+28
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { glibcVersionRuntime } = process.report.getReport().header;
2+
process.exit(glibcVersionRuntime ? 0 : 1);

packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
],
1010
"main": "next-swc.linux-arm64-gnu.node",
1111
"files": [
12-
"next-swc.linux-arm64-gnu.node"
12+
"next-swc.linux-arm64-gnu.node",
13+
"install.js"
1314
],
15+
"scripts": {
16+
"install": "node install.js"
17+
},
1418
"license": "MIT",
1519
"engines": {
1620
"node": ">= 10"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { glibcVersionRuntime } = process.report.getReport().header;
2+
process.exit(glibcVersionRuntime ? 1 : 0);

packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
],
1010
"main": "next-swc.linux-arm64-musl.node",
1111
"files": [
12-
"next-swc.linux-arm64-musl.node"
12+
"next-swc.linux-arm64-musl.node",
13+
"install.js"
1314
],
15+
"scripts": {
16+
"install": "node install.js"
17+
},
1418
"license": "MIT",
1519
"engines": {
1620
"node": ">= 10"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { glibcVersionRuntime } = process.report.getReport().header;
2+
process.exit(glibcVersionRuntime ? 0 : 1);

packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
],
1010
"main": "next-swc.linux-x64-gnu.node",
1111
"files": [
12-
"next-swc.linux-x64-gnu.node"
12+
"next-swc.linux-x64-gnu.node",
13+
"install.js"
1314
],
15+
"scripts": {
16+
"install": "node install.js"
17+
},
1418
"license": "MIT",
1519
"engines": {
1620
"node": ">= 10"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { glibcVersionRuntime } = process.report.getReport().header;
2+
process.exit(glibcVersionRuntime ? 1 : 0);

packages/next-swc/crates/napi/npm/linux-x64-musl/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
],
1010
"main": "next-swc.linux-x64-musl.node",
1111
"files": [
12-
"next-swc.linux-x64-musl.node"
12+
"next-swc.linux-x64-musl.node",
13+
"install.js"
1314
],
15+
"scripts": {
16+
"install": "node install.js"
17+
},
1418
"license": "MIT",
1519
"engines": {
1620
"node": ">= 10"

0 commit comments

Comments
 (0)