diff --git a/.github/workflows/release-fellowapp.yml b/.github/workflows/release-fellowapp.yml new file mode 100644 index 00000000..911f34dc --- /dev/null +++ b/.github/workflows/release-fellowapp.yml @@ -0,0 +1,166 @@ +name: release-fellowapp +# Build platform-specific .node binaries and publish the Fellow fork to +# GitHub Packages as @fellowapp/lightningcss + @fellowapp/lightningcss-. +# Triggered manually via workflow_dispatch. +on: + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: windows-latest + target: aarch64-pc-windows-msvc + - os: macos-latest + target: x86_64-apple-darwin + strip: strip -x + + name: build-${{ matrix.target }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: dtolnay/rust-toolchain@stable + - run: rustup target add ${{ matrix.target }} + - uses: bahmutov/npm-install@v1.8.32 + - name: Build release + run: yarn build-release + env: + RUST_TARGET: ${{ matrix.target }} + - name: Strip debug symbols + if: ${{ matrix.strip }} + run: ${{ matrix.strip }} *.node + - uses: actions/upload-artifact@v4 + with: + name: bindings-${{ matrix.target }} + path: '*.node' + + build-apple-silicon: + name: build-apple-silicon + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: dtolnay/rust-toolchain@stable + - run: rustup target add aarch64-apple-darwin + - uses: bahmutov/npm-install@v1.8.32 + - name: Build release + run: yarn build-release + env: + RUST_TARGET: aarch64-apple-darwin + JEMALLOC_SYS_WITH_LG_PAGE: 14 + - name: Strip debug symbols + run: strip -x *.node + - uses: actions/upload-artifact@v4 + with: + name: bindings-aarch64-apple-darwin + path: '*.node' + + build-linux: + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + strip: strip + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian + setup: npm install --global yarn@1 + - target: aarch64-unknown-linux-gnu + strip: llvm-strip + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + - target: aarch64-linux-android + strip: llvm-strip + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + - target: armv7-unknown-linux-gnueabihf + strip: llvm-strip + image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:c22284b2d79092d3e885f64ede00f6afdeb2ccef7e2b6e78be52e7909091cd57 + - target: aarch64-unknown-linux-musl + image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:78c9ab1f117f8c535b93c4b91a2f19063dda6e4dba48a6187df49810625992c1 + strip: aarch64-linux-musl-strip + - target: x86_64-unknown-linux-musl + image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:78c9ab1f117f8c535b93c4b91a2f19063dda6e4dba48a6187df49810625992c1 + strip: strip + + name: build-${{ matrix.target }} + runs-on: ubuntu-latest + container: + image: ${{ matrix.image }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: dtolnay/rust-toolchain@stable + - name: Setup Android NDK + if: ${{ matrix.target == 'aarch64-linux-android' }} + run: | + sudo apt update && sudo apt install unzip -y + cd /tmp + wget -q https://dl.google.com/android/repository/android-ndk-r28-linux.zip -O /tmp/ndk.zip + unzip ndk.zip + - name: Setup cross compile toolchain + if: ${{ matrix.setup }} + run: ${{ matrix.setup }} + - run: rustup target add ${{ matrix.target }} + - uses: bahmutov/npm-install@v1.8.32 + - name: Build release + run: yarn build-release + env: + ANDROID_NDK_LATEST_HOME: /tmp/android-ndk-r28 + RUST_TARGET: ${{ matrix.target }} + - name: Strip debug symbols + if: ${{ matrix.strip }} + run: ${{ matrix.strip }} *.node + - uses: actions/upload-artifact@v4 + with: + name: bindings-${{ matrix.target }} + path: '*.node' + + release: + runs-on: ubuntu-latest + name: Publish to GitHub Packages + needs: + - build + - build-linux + - build-apple-silicon + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: https://npm.pkg.github.com + scope: '@fellowapp' + - uses: bahmutov/npm-install@v1.8.32 + - uses: actions/download-artifact@v4 + with: + path: artifacts + - name: Show artifacts + run: ls -R artifacts + - name: Build npm packages + run: node scripts/build-npm.js + - name: Publish platform packages + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + for pkg in npm/*; do + echo "Publishing $pkg..." + (cd "$pkg" && npm publish) + done + - name: Publish main package + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Publishing @fellowapp/lightningcss..." + npm publish diff --git a/node/index.js b/node/index.js index 6fe25aef..a17f56e0 100644 --- a/node/index.js +++ b/node/index.js @@ -15,7 +15,7 @@ if (process.platform === 'linux') { let native; try { - native = require(`lightningcss-${parts.join('-')}`); + native = require(`@fellowapp/lightningcss-${parts.join('-')}`); } catch (err) { native = require(`../lightningcss.${parts.join('-')}.node`); } diff --git a/package.json b/package.json index 02b427aa..276fffba 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "lightningcss", - "version": "1.32.0", + "name": "@fellowapp/lightningcss", + "version": "1.32.0-fellow.0", "license": "MPL-2.0", - "description": "A CSS parser, transformer, and minifier written in Rust", + "description": "Fellow fork of lightningcss — a CSS parser, transformer, and minifier written in Rust, with css-loader/postcss-modules-compatible scoped-name hashing.", "main": "node/index.js", "types": "node/index.d.ts", "exports": { @@ -16,7 +16,8 @@ "types": false }, "publishConfig": { - "access": "public" + "access": "public", + "registry": "https://npm.pkg.github.com" }, "funding": { "type": "opencollective", @@ -24,7 +25,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/parcel-bundler/lightningcss.git" + "url": "https://github.com/fellowapp/lightningcss.git" }, "engines": { "node": ">= 12.0.0" @@ -66,7 +67,7 @@ "parcel": "^2.8.2", "patch-package": "^6.5.0", "path-browserify": "^1.0.1", - "postcss": "^8.3.11", + "postcss": "^8.5.10", "posthtml-include": "^1.7.4", "posthtml-markdownit": "^1.3.1", "posthtml-prism": "^1.0.4", @@ -79,7 +80,7 @@ "uvu": "^0.5.6" }, "resolutions": { - "lightningcss": "link:." + "@fellowapp/lightningcss": "link:." }, "scripts": { "prepare": "patch-package", diff --git a/scripts/build-npm.js b/scripts/build-npm.js index ef447a7e..ade96520 100644 --- a/scripts/build-npm.js +++ b/scripts/build-npm.js @@ -58,7 +58,6 @@ const sysToNodePlatform = { }; let optionalDependencies = {}; -let cliOptionalDependencies = {}; try { fs.mkdirSync(dir + '/npm'); @@ -78,38 +77,17 @@ for (let triple of triples) { } buildNode(triple.name, cpu, os, libc, t); - buildCLI(triple.name, cpu, os, libc, t); } pkg.optionalDependencies = optionalDependencies; fs.writeFileSync(`${dir}/package.json`, JSON.stringify(pkg, false, 2) + '\n'); -let cliPkg = { ...pkg }; -cliPkg.name += '-cli'; -cliPkg.bin = { - 'lightningcss': 'lightningcss' -}; -delete cliPkg.main; -delete cliPkg.napi; -delete cliPkg.exports; -delete cliPkg.devDependencies; -delete cliPkg.targets; -delete cliPkg.types; -cliPkg.files = ['lightningcss', 'postinstall.js']; -cliPkg.optionalDependencies = cliOptionalDependencies; -cliPkg.scripts = { - postinstall: 'node postinstall.js' -}; - -fs.writeFileSync(`${dir}/cli/package.json`, JSON.stringify(cliPkg, false, 2) + '\n'); -fs.copyFileSync(`${dir}/README.md`, `${dir}/cli/README.md`); -fs.copyFileSync(`${dir}/LICENSE`, `${dir}/cli/LICENSE`); - function buildNode(triple, cpu, os, libc, t) { let name = `lightningcss.${t}.node`; let pkg2 = { ...pkg }; - pkg2.name += '-' + t; + // Each platform package is published as @fellowapp/lightningcss-. + pkg2.name = '@fellowapp/lightningcss-' + t; pkg2.os = [os]; pkg2.cpu = [cpu]; if (libc) { @@ -133,38 +111,7 @@ function buildNode(triple, cpu, os, libc, t) { } catch (err) { } fs.writeFileSync(`${dir}/npm/node-${t}/package.json`, JSON.stringify(pkg2, false, 2) + '\n'); fs.copyFileSync(`${dir}/artifacts/bindings-${triple}/${name}`, `${dir}/npm/node-${t}/${name}`); - fs.writeFileSync(`${dir}/npm/node-${t}/README.md`, `This is the ${triple} build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details.`); + fs.writeFileSync(`${dir}/npm/node-${t}/README.md`, `This is the ${triple} build of @fellowapp/lightningcss. See https://github.com/fellowapp/lightningcss for details.`); fs.copyFileSync(`${dir}/LICENSE`, `${dir}/npm/node-${t}/LICENSE`); } -function buildCLI(triple, cpu, os, libc, t) { - let binary = os === 'win32' ? 'lightningcss.exe' : 'lightningcss'; - let pkg2 = { ...pkg }; - pkg2.name += '-cli-' + t; - pkg2.os = [os]; - pkg2.cpu = [cpu]; - pkg2.files = [binary]; - if (libc) { - pkg2.libc = [libc]; - } - delete pkg2.main; - delete pkg2.exports; - delete pkg2.napi; - delete pkg2.devDependencies; - delete pkg2.dependencies; - delete pkg2.optionalDependencies; - delete pkg2.targets; - delete pkg2.scripts; - delete pkg2.types; - - cliOptionalDependencies[pkg2.name] = pkg.version; - - try { - fs.mkdirSync(dir + '/npm/cli-' + t); - } catch (err) { } - fs.writeFileSync(`${dir}/npm/cli-${t}/package.json`, JSON.stringify(pkg2, false, 2) + '\n'); - fs.copyFileSync(`${dir}/artifacts/bindings-${triple}/${binary}`, `${dir}/npm/cli-${t}/${binary}`); - fs.chmodSync(`${dir}/npm/cli-${t}/${binary}`, 0o755); // Ensure execute bit is set. - fs.writeFileSync(`${dir}/npm/cli-${t}/README.md`, `This is the ${triple} build of lightningcss-cli. See https://github.com/parcel-bundler/lightningcss for details.`); - fs.copyFileSync(`${dir}/LICENSE`, `${dir}/npm/cli-${t}/LICENSE`); -} diff --git a/yarn.lock b/yarn.lock index b273df78..2bc9fb56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -348,6 +348,9 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz#c57c8afbb4054a3ab8317591a0b7320360b444ae" integrity sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA== +"@fellowapp/lightningcss@link:.": + version "0.0.0" + "@img/sharp-darwin-arm64@0.33.5": version "0.33.5" resolved "https://registry.yarnpkg.com/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz#ef5b5a07862805f1e8145a377c8ba6e98813ca08" @@ -2744,13 +2747,79 @@ kleur@^4.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780" integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ== -lightningcss@^1.22.1: - version "0.0.0" - uid "" +lightningcss-android-arm64@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz#f033885116dfefd9c6f54787523e3514b61e1968" + integrity sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg== + +lightningcss-darwin-arm64@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz#50b71871b01c8199584b649e292547faea7af9b5" + integrity sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ== + +lightningcss-darwin-x64@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz#35f3e97332d130b9ca181e11b568ded6aebc6d5e" + integrity sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w== + +lightningcss-freebsd-x64@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz#9777a76472b64ed6ff94342ad64c7bafd794a575" + integrity sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig== + +lightningcss-linux-arm-gnueabihf@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz#13ae652e1ab73b9135d7b7da172f666c410ad53d" + integrity sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw== + +lightningcss-linux-arm64-gnu@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz#417858795a94592f680123a1b1f9da8a0e1ef335" + integrity sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ== + +lightningcss-linux-arm64-musl@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz#6be36692e810b718040802fd809623cffe732133" + integrity sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg== + +lightningcss-linux-x64-gnu@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz#0b7803af4eb21cfd38dd39fe2abbb53c7dd091f6" + integrity sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA== + +lightningcss-linux-x64-musl@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz#88dc8ba865ddddb1ac5ef04b0f161804418c163b" + integrity sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg== + +lightningcss-win32-arm64-msvc@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz#4f30ba3fa5e925f5b79f945e8cc0d176c3b1ab38" + integrity sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw== + +lightningcss-win32-x64-msvc@1.32.0: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz#141aa5605645064928902bb4af045fa7d9f4220a" + integrity sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q== -"lightningcss@link:.": - version "0.0.0" - uid "" +lightningcss@^1.22.1: + version "1.32.0" + resolved "https://registry.yarnpkg.com/lightningcss/-/lightningcss-1.32.0.tgz#b85aae96486dcb1bf49a7c8571221273f4f1e4a9" + integrity sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ== + dependencies: + detect-libc "^2.0.3" + optionalDependencies: + lightningcss-android-arm64 "1.32.0" + lightningcss-darwin-arm64 "1.32.0" + lightningcss-darwin-x64 "1.32.0" + lightningcss-freebsd-x64 "1.32.0" + lightningcss-linux-arm-gnueabihf "1.32.0" + lightningcss-linux-arm64-gnu "1.32.0" + lightningcss-linux-arm64-musl "1.32.0" + lightningcss-linux-x64-gnu "1.32.0" + lightningcss-linux-x64-musl "1.32.0" + lightningcss-win32-arm64-msvc "1.32.0" + lightningcss-win32-x64-msvc "1.32.0" lilconfig@^3.1.2: version "3.1.3" @@ -2958,10 +3027,10 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nanoid@^3.3.7: - version "3.3.8" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.8.tgz#b1be3030bee36aaff18bacb375e5cce521684baf" - integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w== +nanoid@^3.3.11: + version "3.3.12" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.12.tgz#ab3d912e217a6d0a514f00a72a16543a28982c05" + integrity sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ== napi-wasm@^1.0.1: version "1.1.3" @@ -3441,12 +3510,12 @@ postcss-value-parser@^4.2.0: resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.3.11: - version "8.4.49" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.49.tgz#4ea479048ab059ab3ae61d082190fabfd994fe19" - integrity sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA== +postcss@^8.5.10: + version "8.5.10" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.10.tgz#8992d8c30acf3f12169e7c09514a12fed7e48356" + integrity sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ== dependencies: - nanoid "^3.3.7" + nanoid "^3.3.11" picocolors "^1.1.1" source-map-js "^1.2.1"