tailwindcss/patches/@parcel__watcher@2.5.1.patch
Robin Malfait 2228a57a9e
Bump Lightning CSS (#19771)
This PR bumps Lightning CSS. The `node/index.js` file in the package
changed, so we had to update the patched version of it as well.

We also had to update the patches for `@parcel/watcher` and
`lightningcss` now that they ship with `detect-libc@2`. Unfortunately,
we still require the patches because we also need to take the
`process.env.PLATFORM_LIBC` into account. Another issue is that bun
needs to be able to statically analyze the `require(…)` calls, so using
the nice `parts.push` approach doesn't really work here.

# Test plan

1. Existing tests should pass
2. Updated some tests to reflect the changes in the generated CSS based
on the version bump.

[ci-all]
2026-03-18 15:57:52 +01:00

67 lines
2.4 KiB
Diff

diff --git a/index.js b/index.js
index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..f28fd092644ccfb8aff2618b966cb5219a181a02 100644
--- a/index.js
+++ b/index.js
@@ -1,40 +1,32 @@
const {createWrapper} = require('./wrapper');
-let name = `@parcel/watcher-${process.platform}-${process.arch}`;
-if (process.platform === 'linux') {
- const { MUSL, family } = require('detect-libc');
- if (family === MUSL) {
- name += '-musl';
- } else {
- name += '-glibc';
- }
-}
+// We need to take the `process.env.PLATFORM_LIBC` into account, and we also
+// need static analysis, so we can't make use of the `parts.push(…)` approach.
+function loadPackage() {
+ if (process.platform === 'linux') {
+ if (process.env.PLATFORM_LIBC === "musl") {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`)
+ } else if (process.env.PLATFORM_LIBC === "glibc") {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`)
+ } else {
+ let { MUSL, GLIBC, familySync } = require('detect-libc')
+ let family = familySync()
-let binding;
-try {
- binding = require(name);
-} catch (err) {
- handleError(err);
- try {
- binding = require('./build/Release/watcher.node');
- } catch (err) {
- handleError(err);
- try {
- binding = require('./build/Debug/watcher.node');
- } catch (err) {
- handleError(err);
- 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.`);
- }
- }
-}
-function handleError(err) {
- if (err?.code !== 'MODULE_NOT_FOUND') {
- throw err;
+ if (family === MUSL) {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`)
+ } else if (family === GLIBC) {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`)
+ } else {
+ throw new Error(`Unsupported libc on: ${process.platform}-${process.arch}`)
+ }
+ }
+ } else {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}`)
}
}
-const wrapper = createWrapper(binding);
+const wrapper = createWrapper(loadPackage());
exports.writeSnapshot = wrapper.writeSnapshot;
exports.getEventsSince = wrapper.getEventsSince;
exports.subscribe = wrapper.subscribe;