Skip to content

Commit a3aec17

Browse files
Add musl binaries to the Standalone CLI (#15567)
Closes #15031 This adds musl binaries for the Standalone CLI on Linux aarch64 (ARM 64-bit) and x86_64 (Intel/AMD 64-bit).
1 parent 76151d4 commit a3aec17

File tree

7 files changed

+151
-119
lines changed

7 files changed

+151
-119
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ jobs:
265265
files: |
266266
packages/@tailwindcss-standalone/dist/sha256sums.txt
267267
packages/@tailwindcss-standalone/dist/tailwindcss-linux-arm64
268+
packages/@tailwindcss-standalone/dist/tailwindcss-linux-arm64-musl
268269
packages/@tailwindcss-standalone/dist/tailwindcss-linux-x64
270+
packages/@tailwindcss-standalone/dist/tailwindcss-linux-x64-musl
269271
packages/@tailwindcss-standalone/dist/tailwindcss-macos-arm64
270272
packages/@tailwindcss-standalone/dist/tailwindcss-macos-x64
271273
packages/@tailwindcss-standalone/dist/tailwindcss-windows-x64.exe

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Add `@reference "…"` API as a replacement for the previous `@import "…" reference` option ([#15565](https://github.com/tailwindlabs/tailwindcss/pull/15565))
1414
- Add functional utility syntax ([#15455](https://github.com/tailwindlabs/tailwindcss/pull/15455))
1515
- Add new `--spacing(…)`, `--alpha(…)`, and `--theme(…)` CSS functions ([#15572](https://github.com/tailwindlabs/tailwindcss/pull/15572))
16+
- Add Linux musl builds of the Standalone CLI ([#15567](https://github.com/tailwindlabs/tailwindcss/pull/15567))
1617

1718
### Fixed
1819

packages/@tailwindcss-standalone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@parcel/watcher-linux-x64-musl": "^2.5.0",
4444
"@parcel/watcher-win32-x64": "^2.5.0",
4545
"@types/bun": "^1.1.14",
46-
"bun": "1.1.42",
46+
"bun": "1.1.43",
4747
"lightningcss-darwin-arm64": "^1.25.1",
4848
"lightningcss-darwin-x64": "^1.25.1",
4949
"lightningcss-linux-arm64-gnu": "^1.25.1",

packages/@tailwindcss-standalone/scripts/build.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ async function buildForPlatform(triple: string, outfile: string) {
1010
// We wrap this in a retry because occasionally the atomic rename fails for some reason
1111
for (let i = 0; i < 5; ++i) {
1212
try {
13-
return await $`bun build --compile --target=${triple} ./src/index.ts --outfile=${outfile}`
13+
let cmd = $`bun build --compile --target=${triple} ./src/index.ts --outfile=${outfile} --env inline`
14+
15+
// This env var is used by our patched versions of Lightning CSS and Parcel Watcher
16+
// to statically bundle the proper binaries for musl vs glibc
17+
cmd = cmd.env({
18+
PLATFORM_LIBC: triple.includes('-musl') ? 'musl' : 'glibc',
19+
})
20+
21+
return await cmd
1422
} catch (err) {
1523
if (i < 5) continue
1624

@@ -46,7 +54,9 @@ await mkdir(path.resolve(__dirname, '../dist'), { recursive: true })
4654
// Build platform binaries and checksum them
4755
let results = await Promise.all([
4856
build('bun-linux-arm64', './tailwindcss-linux-arm64'),
57+
build('bun-linux-arm64-musl', './tailwindcss-linux-arm64-musl'),
4958
build('bun-linux-x64', './tailwindcss-linux-x64'),
59+
build('bun-linux-x64-musl', './tailwindcss-linux-x64-musl'),
5060
// build('linux-armv7', 'tailwindcss-linux-armv7'),
5161
build('bun-darwin-arm64', './tailwindcss-macos-arm64'),
5262
build('bun-darwin-x64', './tailwindcss-macos-x64'),

patches/@parcel__watcher@2.5.0.patch

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/index.js b/index.js
2-
index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..f3b1158eb5612235388ff5f5347f6edcbf323090 100644
2+
index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..398af238a439912d150b3573367873d2a9a311e3 100644
33
--- a/index.js
44
+++ b/index.js
5-
@@ -1,41 +1,27 @@
5+
@@ -1,41 +1,34 @@
66
-const {createWrapper} = require('./wrapper');
77
+const { createWrapper } = require('./wrapper')
88

@@ -17,11 +17,12 @@ index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..f3b1158eb5612235388ff5f5347f6edc
1717
-}
1818
+function loadPackage() {
1919
+ if (process.platform === 'linux') {
20-
+ let { MUSL, GLIBC, family, familySync } = require('detect-libc')
21-
+ // Bun polyfills `detect-libc` in compiled binaries. We rely on
22-
+ // detect-libc@1.0.3 but the polyfilled version is 2.x. In detect-libc@2x
23-
+ // there is a `familySync` function that we can use instead.
24-
+ if (typeof familySync === 'function') family = familySync()
20+
+ if (process.env.PLATFORM_LIBC === "musl") {
21+
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`)
22+
+ } else if (process.env.PLATFORM_LIBC === "glibc") {
23+
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`)
24+
+ } else {
25+
+ let { MUSL, GLIBC, family, familySync } = require('detect-libc')
2526

2627
-let binding;
2728
-try {
@@ -37,24 +38,30 @@ index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..f3b1158eb5612235388ff5f5347f6edc
3738
- } catch (err) {
3839
- handleError(err);
3940
- throw new Error(`No prebuild or local build of @parcel/watcher found. Tried ${name}. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.`);
40-
+ if (family === MUSL) {
41-
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`)
42-
+ } else if (family === GLIBC) {
43-
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`)
44-
+ } else {
45-
+ throw new Error(`Unsupported libc on: ${process.platform}-${process.arch}`)
46-
}
41+
- }
42+
- }
43+
-}
44+
+ // Bun polyfills `detect-libc` in compiled binaries. We rely on
45+
+ // detect-libc@1.0.3 but the polyfilled version is 2.x. In detect-libc@2x
46+
+ // there is a `familySync` function that we can use instead.
47+
+ if (typeof familySync === 'function') family = familySync()
48+
49+
-function handleError(err) {
50+
- if (err?.code !== 'MODULE_NOT_FOUND') {
51+
- throw err;
52+
+ if (family === MUSL) {
53+
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`)
54+
+ } else if (family === GLIBC) {
55+
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`)
56+
+ } else {
57+
+ throw new Error(`Unsupported libc on: ${process.platform}-${process.arch}`)
58+
+ }
59+
+ }
4760
+ } else {
4861
+ return require(`@parcel/watcher-${process.platform}-${process.arch}`)
4962
}
5063
}
5164

52-
-function handleError(err) {
53-
- if (err?.code !== 'MODULE_NOT_FOUND') {
54-
- throw err;
55-
- }
56-
-}
57-
-
5865
-const wrapper = createWrapper(binding);
5966
-exports.writeSnapshot = wrapper.writeSnapshot;
6067
-exports.getEventsSince = wrapper.getEventsSince;

patches/lightningcss@1.26.0.patch

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/node/index.js b/node/index.js
2-
index a9f2f6d5f3394329fcf8bc06af549030c01167a5..b92cc804adb694dbb17ee48368f13a03dd729267 100644
2+
index a9f2f6d5f3394329fcf8bc06af549030c01167a5..db3b1c6cab5e4bac140d2f7a2b2e041d9a0a8a36 100644
33
--- a/node/index.js
44
+++ b/node/index.js
5-
@@ -1,27 +1,32 @@
5+
@@ -1,27 +1,43 @@
66
-let parts = [process.platform, process.arch];
77
-if (process.platform === 'linux') {
88
- const { MUSL, family } = require('detect-libc');
@@ -18,11 +18,16 @@ index a9f2f6d5f3394329fcf8bc06af549030c01167a5..b92cc804adb694dbb17ee48368f13a03
1818
-}
1919
+function loadPackage() {
2020
+ if (process.platform === "linux") {
21-
+ let { MUSL, GLIBC, family, familySync } = require("detect-libc");
22-
+ // Bun polyfills `detect-libc` in compiled binaries. We rely on
23-
+ // detect-libc@1.0.3 but the polyfilled version is 2.x. In detect-libc@2x
24-
+ // there is a `familySync` function that we can use instead.
25-
+ if (typeof familySync === 'function') family = familySync()
21+
+ if (process.env.PLATFORM_LIBC === 'musl') {
22+
+ return require(`lightningcss-${process.platform}-${process.arch}-musl`);
23+
+ } else if (process.env.PLATFORM_LIBC === 'glibc') {
24+
+ if (process.arch === "arm") {
25+
+ return require(`lightningcss-${process.platform}-${process.arch}-gnueabihf`);
26+
+ } else {
27+
+ return require(`lightningcss-${process.platform}-${process.arch}-gnu`);
28+
+ }
29+
+ } else {
30+
+ let { MUSL, GLIBC, family, familySync } = require('detect-libc')
2631

2732
-if (process.env.CSS_TRANSFORMER_WASM) {
2833
- module.exports = require(`../pkg`);
@@ -31,18 +36,24 @@ index a9f2f6d5f3394329fcf8bc06af549030c01167a5..b92cc804adb694dbb17ee48368f13a03
3136
- module.exports = require(`lightningcss-${parts.join('-')}`);
3237
- } catch (err) {
3338
- module.exports = require(`../lightningcss.${parts.join('-')}.node`);
34-
+ if (family === MUSL) {
35-
+ return require(`lightningcss-${process.platform}-${process.arch}-musl`);
36-
+ } else if (family === GLIBC) {
37-
+ if (process.arch === "arm") {
38-
+ return require(`lightningcss-${process.platform}-${process.arch}-gnueabihf`);
39+
+ // Bun polyfills `detect-libc` in compiled binaries. We rely on
40+
+ // detect-libc@1.0.3 but the polyfilled version is 2.x. In detect-libc@2x
41+
+ // there is a `familySync` function that we can use instead.
42+
+ if (typeof familySync === 'function') family = familySync()
43+
+
44+
+ if (family === MUSL) {
45+
+ return require(`lightningcss-${process.platform}-${process.arch}-musl`);
46+
+ } else if (family === GLIBC) {
47+
+ if (process.arch === "arm") {
48+
+ return require(`lightningcss-${process.platform}-${process.arch}-gnueabihf`);
49+
+ } else {
50+
+ return require(`lightningcss-${process.platform}-${process.arch}-gnu`);
51+
+ }
3952
+ } else {
40-
+ return require(`lightningcss-${process.platform}-${process.arch}-gnu`);
53+
+ throw new Error(
54+
+ `Unsupported libc on: ${process.platform}-${process.arch}`
55+
+ );
4156
+ }
42-
+ } else {
43-
+ throw new Error(
44-
+ `Unsupported libc on: ${process.platform}-${process.arch}`
45-
+ );
4657
+ }
4758
+ } else if (process.platform === "win32") {
4859
+ return require(`lightningcss-${process.platform}-${process.arch}-msvc`);

0 commit comments

Comments
 (0)