mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
chore(ci): Add linux arm build back (#8406)
This commit is contained in:
parent
602584dd62
commit
4b8184ca99
57
.github/workflows/CI.yml
vendored
57
.github/workflows/CI.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
env:
|
||||
RUST_LOG: "0"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# We explicitly do this to cache properly.
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@ -42,7 +42,7 @@ jobs:
|
||||
${{ !contains(github.event.head_commit.message, 'chore: ') }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
@ -59,7 +59,7 @@ jobs:
|
||||
${{ !contains(github.event.head_commit.message, 'chore: ') }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
@ -99,7 +99,7 @@ jobs:
|
||||
if: >-
|
||||
${{ !contains(github.event.head_commit.message, 'chore: ') }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
@ -129,7 +129,7 @@ jobs:
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
@ -142,7 +142,7 @@ jobs:
|
||||
# toolchain: stable
|
||||
# override: true
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
cache: "yarn"
|
||||
@ -162,7 +162,7 @@ jobs:
|
||||
${{ !contains(github.event.head_commit.message, 'chore: ') }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# We explicitly do this to cache properly.
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@ -179,7 +179,7 @@ jobs:
|
||||
- name: Install wasm-pack
|
||||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
cache: "yarn"
|
||||
@ -581,12 +581,12 @@ jobs:
|
||||
git config --system core.autocrlf false
|
||||
git config --system core.eol lf
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
# Source map format
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
cache: "yarn"
|
||||
@ -714,17 +714,19 @@ jobs:
|
||||
- windows-latest
|
||||
- macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Corepack
|
||||
shell: bash
|
||||
run: corepack enable
|
||||
|
||||
# We explicitly do this to cache properly.
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
cache: "yarn"
|
||||
|
||||
- name: Patch
|
||||
@ -747,6 +749,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
rustup target add wasm32-wasi
|
||||
corepack enable
|
||||
yarn
|
||||
|
||||
yarn build:dev
|
||||
@ -758,11 +761,15 @@ jobs:
|
||||
${{ !contains(github.event.head_commit.message, 'chore: ') }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
- name: Corepack
|
||||
shell: bash
|
||||
run: corepack enable
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 14
|
||||
node-version: 20
|
||||
cache: "yarn"
|
||||
|
||||
- name: Set platform name
|
||||
@ -784,6 +791,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
rustup target add wasm32-wasi
|
||||
corepack enable
|
||||
yarn
|
||||
|
||||
yarn build:dev
|
||||
@ -792,13 +800,13 @@ jobs:
|
||||
cargo clean
|
||||
(cd ./bindings && cargo clean)
|
||||
|
||||
yarn global add @swc/cli@0.1.56
|
||||
yarn link
|
||||
yarn global add file:$PWD
|
||||
npm install -g @swc/cli@0.1.56
|
||||
npm link
|
||||
npm install -g file:$PWD
|
||||
|
||||
- name: Print info
|
||||
run: |
|
||||
yarn global list
|
||||
npm list -g
|
||||
|
||||
- name: (swc) three.js
|
||||
run: |
|
||||
@ -838,7 +846,8 @@ jobs:
|
||||
# (cd tests/integration/redux/repo && npx jest '.*.js' --modulePathIgnorePatterns 'typescript')
|
||||
- name: (swcpack) example react app
|
||||
run: |
|
||||
(cd crates/swc_node_bundler/tests/integration/react && yarn && npx spack)
|
||||
export NODE_OPTIONS="--unhandled-rejections=warn"
|
||||
(cd crates/swc_node_bundler/tests/integration/react && npm install && npx spack)
|
||||
|
||||
done:
|
||||
needs:
|
||||
|
278
.github/workflows/publish-core.yml
vendored
278
.github/workflows/publish-core.yml
vendored
@ -47,25 +47,24 @@ jobs:
|
||||
cp ./bindings/target/release/swc .
|
||||
target: x86_64-pc-windows-msvc
|
||||
- host: windows-latest
|
||||
# use npm to run test, because of corepack link the yarn with x64 Node.js
|
||||
build: |
|
||||
export DISABLE_PLUGIN_E2E_TESTS=true
|
||||
export CARGO_PROFILE_RELEASE_LTO=false
|
||||
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --target i686-pc-windows-msvc
|
||||
cp bindings/target/i686-pc-windows-msvc/release/swc .
|
||||
yarn build --target i686-pc-windows-msvc --cargo-flags="--no-default-features" --features swc_v1
|
||||
yarn test
|
||||
yarn build --target i686-pc-windows-msvc --no-default-features --features swc_v1
|
||||
npm run test
|
||||
target: i686-pc-windows-msvc
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
|
||||
build: >-
|
||||
set -e &&
|
||||
yarn policies set-version 1.22.19 &&
|
||||
unset CC_x86_64_unknown_linux_gnu && unset CC && RUSTFLAGS='-C target-feature=+sse2' cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin &&
|
||||
rm -rf bindings/target/target/x86_64-unknown-linux-gnu/release/.cargo-lock &&
|
||||
cp bindings/target/x86_64-unknown-linux-gnu/release/swc . && chmod +x ./swc &&
|
||||
yarn build --target x86_64-unknown-linux-gnu &&
|
||||
strip swc.linux-x64-gnu.node
|
||||
yarn build --target x86_64-unknown-linux-gnu
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
# musl build is slow, let's disable the LTO
|
||||
@ -76,8 +75,7 @@ jobs:
|
||||
RUSTFLAGS='-C target-feature=+sse2' cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin &&
|
||||
rm -rf target/release/.cargo-lock &&
|
||||
cp bindings/target/release/swc . && chmod +x ./swc &&
|
||||
RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' yarn build &&
|
||||
llvm-strip -x swc.linux-x64-musl.node
|
||||
RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' yarn build
|
||||
- host: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
build: |
|
||||
@ -89,33 +87,25 @@ jobs:
|
||||
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target=aarch64-apple-darwin
|
||||
cp ./bindings/target/aarch64-apple-darwin/release/swc .
|
||||
chmod +x ./swc
|
||||
yarn build --target=aarch64-apple-darwin
|
||||
strip -x *.node
|
||||
yarn build --target aarch64-apple-darwin
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
|
||||
build: >-
|
||||
set -e &&
|
||||
yarn policies set-version 1.22.19 &&
|
||||
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
|
||||
rustup target add aarch64-unknown-linux-gnu &&
|
||||
RUSTFLAGS='' cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target aarch64-unknown-linux-gnu &&
|
||||
cp ./bindings/target/aarch64-unknown-linux-gnu/release/swc . && chmod +x ./swc &&
|
||||
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
|
||||
yarn build --target aarch64-unknown-linux-gnu &&
|
||||
llvm-strip -x swc.linux-arm64-gnu.node
|
||||
# - host: ubuntu-latest
|
||||
# target: armv7-unknown-linux-gnueabihf
|
||||
# setup: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
|
||||
# # Use napi to build cli binary here to use zig as linker
|
||||
# build: |
|
||||
# export DISABLE_PLUGIN_E2E_TESTS=true
|
||||
# yarn napi build --bin swc --release --target armv7-unknown-linux-gnueabihf --cargo-cwd ./bindings/swc_cli --cargo-name swc --zig --zig-link-only
|
||||
# chmod +x ./swc
|
||||
# yarn build --target armv7-unknown-linux-gnueabihf --cargo-flags='--no-default-features --features swc_v1'
|
||||
# arm-linux-gnueabihf-strip swc.linux-arm-gnueabihf.node
|
||||
yarn build --target aarch64-unknown-linux-gnu
|
||||
- host: ubuntu-latest
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
build: |
|
||||
export DISABLE_PLUGIN_E2E_TESTS=true
|
||||
yarn napi build --bin swc --release --target armv7-unknown-linux-gnueabihf --manifest-path ./bindings/swc_cli/Cargo.toml -x --target-dir ../release -o .
|
||||
chmod +x ./swc
|
||||
yarn build --target armv7-unknown-linux-gnueabihf --no-default-features --features swc_v1 --use-napi-cross
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
downloadTarget: aarch64-unknown-linux-musl
|
||||
@ -127,8 +117,7 @@ jobs:
|
||||
RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-lgcc' cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target aarch64-unknown-linux-musl &&
|
||||
rm -rf target/release/.cargo-lock &&
|
||||
cp bindings/target/aarch64-unknown-linux-musl/release/swc . && chmod +x ./swc &&
|
||||
env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl &&
|
||||
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip swc.linux-arm64-musl.node
|
||||
env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl
|
||||
- host: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
# Disable `LTO` and increase `codegen-units` to avoid llvm `OOM` on GitHub Actions.
|
||||
@ -138,65 +127,69 @@ jobs:
|
||||
export CARGO_PROFILE_RELEASE_LTO=false
|
||||
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --target aarch64-pc-windows-msvc
|
||||
cp bindings/target/aarch64-pc-windows-msvc/release/swc.exe .
|
||||
yarn build --target aarch64-pc-windows-msvc --cargo-flags='--no-default-features --features swc_v1'
|
||||
name: stable - ${{ matrix.settings.target }} - node@18
|
||||
yarn build --target aarch64-pc-windows-msvc --no-default-features --features swc_v1
|
||||
name: stable - ${{ matrix.settings.target }} - node@20
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Corepack
|
||||
shell: bash
|
||||
run: corepack enable
|
||||
- name: Setup node x64
|
||||
uses: actions/setup-node@v3
|
||||
if: matrix.settings.target != 'i686-pc-windows-msvc'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
architecture: x64
|
||||
- name: Setup node x86
|
||||
uses: actions/setup-node@v3
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
with:
|
||||
node-version: 18
|
||||
cache: yarn
|
||||
architecture: x86
|
||||
- name: Output toolchain
|
||||
id: toolchain
|
||||
shell: bash
|
||||
run: echo "version=$(cat ./rust-toolchain)" >> "$GITHUB_OUTPUT"
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
with:
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.settings.target }}
|
||||
targets: ${{ matrix.settings.target }}
|
||||
toolchain: ${{ steps.toolchain.outputs.version }}
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
|
||||
with:
|
||||
version: 0.10.1
|
||||
- name: Install node dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
yarn
|
||||
version: 0.11.0
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ matrix.settings.target }}-node@18-cargo-registry-trimmed
|
||||
key: ${{ matrix.settings.target }}-node@20-cargo-registry-trimmed
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ matrix.settings.target }}-node@18-cargo-index-trimmed
|
||||
|
||||
key: ${{ matrix.settings.target }}-node@20-cargo-index-trimmed
|
||||
if: ${{ matrix.settings.docker }}
|
||||
- name: Setup toolchain
|
||||
run: ${{ matrix.settings.setup }}
|
||||
if: ${{ matrix.settings.setup }}
|
||||
shell: bash
|
||||
# use x64 Node.js to install dependencies because of ia32 version will fail with `Error: Couldn't allocate enough memory`
|
||||
- name: Setup install target x86
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
run: yarn config set supportedArchitectures.cpu "ia32"
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
# run corepack enable again
|
||||
# because on Windows, yarn will use `cmd` to run `yarn install`
|
||||
shell: bash
|
||||
run: |
|
||||
# Workaround for
|
||||
# https://github.com/yarnpkg/yarn/issues/9015#issuecomment-1831229617
|
||||
yarn policies set-version 1.22.19
|
||||
|
||||
yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
|
||||
corepack enable
|
||||
yarn install
|
||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
echo '/usr/local/cargo/bin' >> $GITHUB_PATH
|
||||
- name: Setup node x86
|
||||
uses: actions/setup-node@v4
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
with:
|
||||
node-version: 20
|
||||
architecture: x86
|
||||
- name: Build in docker
|
||||
uses: addnab/docker-run-action@v3
|
||||
if: ${{ matrix.settings.docker }}
|
||||
@ -204,7 +197,8 @@ jobs:
|
||||
image: ${{ matrix.settings.docker }}
|
||||
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
|
||||
run: >-
|
||||
yarn global add wasm-pack &&
|
||||
corepack enable &&
|
||||
npm i -g wasm-pack &&
|
||||
${{ matrix.settings.build }}
|
||||
- name: Build
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
@ -228,14 +222,16 @@ jobs:
|
||||
settings:
|
||||
- host: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
- host: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
@ -262,23 +258,20 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
- name: Cache NPM dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}
|
||||
- name: Install dependencies
|
||||
run: yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: yarn install
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -300,18 +293,20 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
- name: Install dependencies
|
||||
run: yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: |
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn install
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -326,12 +321,14 @@ jobs:
|
||||
run: docker run --rm -v $(pwd):/swc -w /swc node:${{ matrix.node }}-alpine env DISABLE_PLUGIN_E2E_TESTS=true yarn test
|
||||
test-linux-aarch64-musl-binding:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
|
||||
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
|
||||
name: Test bindings on aarch64-unknown-linux-musl - node@lts
|
||||
needs:
|
||||
- build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -340,13 +337,11 @@ jobs:
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Cache NPM dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: npm-cache-test-linux-aarch64-musl-${{ matrix.node }}
|
||||
- name: Install dependencies
|
||||
run: yarn install --ignore-scripts --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: |
|
||||
yarn config set supportedArchitectures.cpu "arm64"
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn install
|
||||
- name: Build TypeScript
|
||||
run: yarn build:ts
|
||||
- name: Set up QEMU
|
||||
@ -362,53 +357,51 @@ jobs:
|
||||
run: >-
|
||||
set -e &&
|
||||
DISABLE_PLUGIN_E2E_TESTS=true yarn test
|
||||
# https://github.com/ziglang/zig/issues/16152
|
||||
#
|
||||
# test-linux-arm-gnueabihf-binding:
|
||||
# if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
|
||||
# name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
|
||||
# needs:
|
||||
# - build
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# node:
|
||||
# - "16"
|
||||
# - "18"
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - name: Download artifacts
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: bindings-armv7-unknown-linux-gnueabihf
|
||||
# path: .
|
||||
# - name: List packages
|
||||
# run: ls -R .
|
||||
# shell: bash
|
||||
# - name: Cache NPM dependencies
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: node_modules
|
||||
# key: npm-cache-test-linux-arm-gnueabihf-${{ matrix.node }}
|
||||
# - name: Install dependencies
|
||||
# run: yarn install --ignore-scripts --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
# - name: Build TypeScript
|
||||
# run: yarn build:ts
|
||||
# - name: Set up QEMU
|
||||
# uses: docker/setup-qemu-action@v2
|
||||
# with:
|
||||
# platforms: arm
|
||||
# - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
# - name: Setup and run tests
|
||||
# uses: addnab/docker-run-action@v3
|
||||
# with:
|
||||
# image: node:${{ matrix.node }}-bullseye-slim
|
||||
# options: "--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build"
|
||||
# run: >-
|
||||
# set -e &&
|
||||
# DISABLE_PLUGIN_E2E_TESTS=true yarn test &&
|
||||
# ls -la
|
||||
|
||||
test-linux-arm-gnueabihf-binding:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
|
||||
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: bindings-armv7-unknown-linux-gnueabihf
|
||||
path: .
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
yarn config set supportedArchitectures.cpu "arm"
|
||||
yarn install
|
||||
- name: Build TypeScript
|
||||
run: yarn build:ts
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: arm
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- name: Setup and run tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: node:${{ matrix.node }}-slim
|
||||
options: "--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build"
|
||||
run: >-
|
||||
set -e &&
|
||||
DISABLE_PLUGIN_E2E_TESTS=true yarn test &&
|
||||
ls -la
|
||||
publish:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
|
||||
@ -417,14 +410,17 @@ jobs:
|
||||
needs:
|
||||
- test-linux-x64-gnu-binding
|
||||
- test-linux-x64-musl-binding
|
||||
# - test-linux-arm-gnueabihf-binding
|
||||
- test-linux-arm-gnueabihf-binding
|
||||
- test-macOS-windows-binding
|
||||
- test-linux-aarch64-musl-binding
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
cache: yarn
|
||||
@ -440,7 +436,7 @@ jobs:
|
||||
run: echo "NPM_TAG=nightly" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: yarn install
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
@ -490,7 +486,10 @@ jobs:
|
||||
name: Build - wasm for node.js
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Tag npm release (default, latest)
|
||||
run: echo "NPM_TAG=latest" >> $GITHUB_ENV
|
||||
@ -500,9 +499,9 @@ jobs:
|
||||
run: echo "NPM_TAG=nightly" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v3
|
||||
@ -539,7 +538,10 @@ jobs:
|
||||
name: Build - wasm for web
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Tag npm release (default, latest)
|
||||
run: echo "NPM_TAG=latest" >> $GITHUB_ENV
|
||||
@ -549,9 +551,9 @@ jobs:
|
||||
run: echo "NPM_TAG=nightly" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v3
|
||||
|
188
.github/workflows/publish-extra-bindings.yml
vendored
188
.github/workflows/publish-extra-bindings.yml
vendored
@ -35,14 +35,14 @@ jobs:
|
||||
- host: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
build: |
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build && strip -x *.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build)
|
||||
- host: windows-latest
|
||||
build: |
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build)
|
||||
target: x86_64-pc-windows-msvc
|
||||
- host: windows-latest
|
||||
build: |
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target i686-pc-windows-msvc)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target i686-pc-windows-msvc)
|
||||
target: i686-pc-windows-msvc
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
@ -50,7 +50,7 @@ jobs:
|
||||
build: >-
|
||||
set -e &&
|
||||
unset CC_x86_64_unknown_linux_gnu && unset CC &&
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target x86_64-unknown-linux-gnu && strip ${{ github.event.inputs.package }}.linux-x64-gnu.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target x86_64-unknown-linux-gnu)
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
# musl build is slow, let's disable the LTO
|
||||
@ -58,8 +58,7 @@ jobs:
|
||||
build: >-
|
||||
set -e &&
|
||||
export CARGO_PROFILE_RELEASE_LTO=false &&
|
||||
(cd packages/${{ github.event.inputs.package }} && RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' corepack yarn build &&
|
||||
llvm-strip -x ${{ github.event.inputs.package }}.linux-x64-musl.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' yarn build)
|
||||
- host: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
build: |
|
||||
@ -68,7 +67,7 @@ jobs:
|
||||
export CXX=$(xcrun -f clang++);
|
||||
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
|
||||
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target=aarch64-apple-darwin && strip -x *.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target=aarch64-apple-darwin)
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
|
||||
@ -77,16 +76,14 @@ jobs:
|
||||
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
|
||||
rustup target add aarch64-unknown-linux-gnu &&
|
||||
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target aarch64-unknown-linux-gnu &&
|
||||
llvm-strip -x ${{ github.event.inputs.package }}.linux-arm64-gnu.node)
|
||||
# - host: ubuntu-latest
|
||||
# target: armv7-unknown-linux-gnueabihf
|
||||
# setup: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
|
||||
# # Use napi to build cli binary here to use zig as linker
|
||||
# build: |
|
||||
# (cd packages/${{ github.event.inputs.package }} && corepack yarn build --target armv7-unknown-linux-gnueabihf && arm-linux-gnueabihf-strip ${{ github.event.inputs.package }}.linux-arm-gnueabihf.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target aarch64-unknown-linux-gnu)
|
||||
- host: ubuntu-latest
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
|
||||
build: |
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target armv7-unknown-linux-gnueabihf --use-napi-cross)
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
downloadTarget: aarch64-unknown-linux-musl
|
||||
@ -95,64 +92,67 @@ jobs:
|
||||
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
|
||||
rustup toolchain install $(cat ./rust-toolchain) &&
|
||||
rustup target add aarch64-unknown-linux-musl &&
|
||||
(cd packages/${{ github.event.inputs.package }} && env RUSTFLAGS='-C target-feature=-crt-static' corepack yarn build --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip ${{ github.event.inputs.package }}.linux-arm64-musl.node)
|
||||
(cd packages/${{ github.event.inputs.package }} && env RUSTFLAGS='-C target-feature=-crt-static' yarn build --target=aarch64-unknown-linux-musl)
|
||||
- host: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
# Disable `LTO` and increase `codegen-units` to avoid llvm `OOM` on GitHub Actions.
|
||||
build: |
|
||||
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
|
||||
export CARGO_PROFILE_RELEASE_LTO=false
|
||||
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target aarch64-pc-windows-msvc)
|
||||
(cd packages/${{ github.event.inputs.package }} && yarn build --target aarch64-pc-windows-msvc)
|
||||
name: "Build: ${{ github.event.inputs.package }} - ${{ matrix.settings.target }}"
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup node x64
|
||||
uses: actions/setup-node@v3
|
||||
if: matrix.settings.target != 'i686-pc-windows-msvc'
|
||||
with:
|
||||
node-version: 18
|
||||
architecture: x64
|
||||
|
||||
- name: Setup node x86
|
||||
uses: actions/setup-node@v3
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
with:
|
||||
node-version: 18
|
||||
architecture: x86
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
with:
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.settings.target }}
|
||||
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
|
||||
with:
|
||||
version: 0.10.1
|
||||
|
||||
- shell: bash
|
||||
- name: Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install node dependencies
|
||||
shell: bash
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
|
||||
- name: Setup node x64
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
architecture: x64
|
||||
|
||||
- name: Output toolchain
|
||||
id: toolchain
|
||||
shell: bash
|
||||
run: echo "version=$(cat ./rust-toolchain)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
with:
|
||||
targets: ${{ matrix.settings.target }}
|
||||
toolchain: ${{ steps.toolchain.outputs.version }}
|
||||
|
||||
- name: Setup toolchain
|
||||
run: ${{ matrix.settings.setup }}
|
||||
if: ${{ matrix.settings.setup }}
|
||||
shell: bash
|
||||
|
||||
# use x64 Node.js to install dependencies because of ia32 version will fail with `Error: Couldn't allocate enough memory`
|
||||
- name: Setup install target x86
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
run: yarn config set supportedArchitectures.cpu "ia32"
|
||||
shell: bash
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages"
|
||||
run: |
|
||||
corepack enable
|
||||
yarn
|
||||
# curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
echo '/usr/local/cargo/bin' >> $GITHUB_PATH
|
||||
|
||||
- name: Setup node x86
|
||||
uses: actions/setup-node@v4
|
||||
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
||||
with:
|
||||
node-version: 20
|
||||
architecture: x86
|
||||
- name: Build in docker
|
||||
uses: addnab/docker-run-action@v3
|
||||
if: ${{ matrix.settings.docker }}
|
||||
@ -160,7 +160,8 @@ jobs:
|
||||
image: ${{ matrix.settings.docker }}
|
||||
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
|
||||
run: >-
|
||||
yarn global add wasm-pack &&
|
||||
corepack enable &&
|
||||
npm i -g wasm-pack &&
|
||||
${{ matrix.settings.build }}
|
||||
- name: Build
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
@ -189,19 +190,25 @@ jobs:
|
||||
settings:
|
||||
- host: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
- host: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: "yarn"
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: yarn
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -212,10 +219,10 @@ jobs:
|
||||
shell: bash
|
||||
- name: Build TypeScript
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn build:ts
|
||||
run: yarn build:ts
|
||||
- name: Test bindings
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn test
|
||||
run: yarn test
|
||||
test-linux-x64-gnu-binding:
|
||||
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
|
||||
needs:
|
||||
@ -224,19 +231,23 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: "yarn"
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: yarn
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -248,7 +259,7 @@ jobs:
|
||||
shell: bash
|
||||
- name: Build TypeScript
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn build:ts
|
||||
run: yarn build:ts
|
||||
|
||||
- name: Test bindings
|
||||
run: docker run --rm -v $(pwd):/swc -w /swc/packages/${{ github.event.inputs.package }} node:${{ matrix.node }}-slim env DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test
|
||||
@ -260,18 +271,24 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: "yarn"
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: |
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -287,12 +304,15 @@ jobs:
|
||||
- name: Test bindings
|
||||
run: docker run --rm -v $(pwd):/swc -w /swc/packages/${{ github.event.inputs.package }} node:${{ matrix.node }}-alpine env DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test
|
||||
test-linux-aarch64-musl-binding:
|
||||
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
|
||||
name: Test bindings on aarch64-unknown-linux-musl - node@lts
|
||||
needs:
|
||||
- build-node
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -304,7 +324,10 @@ jobs:
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: |
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn config set supportedArchitectures.arch "arm64"
|
||||
yarn
|
||||
- name: Build TypeScript
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn build:ts
|
||||
@ -321,7 +344,7 @@ jobs:
|
||||
run: >-
|
||||
set -e &&
|
||||
(cd "./packages/${{ github.event.inputs.package }}" && DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test)
|
||||
# test-linux-arm-gnueabihf-binding:
|
||||
test-linux-arm-gnueabihf-binding:
|
||||
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build-node
|
||||
@ -329,11 +352,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- "16"
|
||||
- "18"
|
||||
- "20"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
@ -345,7 +371,9 @@ jobs:
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: |
|
||||
yarn config set supportedArchitectures.arch "arm"
|
||||
yarn
|
||||
- name: Build TypeScript
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn build:ts
|
||||
@ -369,20 +397,24 @@ jobs:
|
||||
needs:
|
||||
- test-linux-x64-gnu-binding
|
||||
- test-linux-x64-musl-binding
|
||||
# - test-linux-arm-gnueabihf-binding
|
||||
- test-linux-arm-gnueabihf-binding
|
||||
- test-macOS-windows-binding
|
||||
- test-linux-aarch64-musl-binding
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: enable corepack
|
||||
run: corepack enable
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: "./packages/${{ github.event.inputs.package }}"
|
||||
run: corepack yarn
|
||||
run: yarn
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
|
@ -1 +1,5 @@
|
||||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
@ -5,14 +5,14 @@ describe("transform", () => {
|
||||
const output = swc.transformSync("class Foo {}", {});
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "function _class_call_check(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError(\\"Cannot call a class as a function\\");
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
var Foo = function Foo() {
|
||||
\\"use strict\\";
|
||||
"use strict";
|
||||
_class_call_check(this, Foo);
|
||||
};
|
||||
",
|
||||
@ -24,14 +24,14 @@ describe("transform", () => {
|
||||
const output = await swc.transform("class Foo {}", {});
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "function _class_call_check(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError(\\"Cannot call a class as a function\\");
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
var Foo = function Foo() {
|
||||
\\"use strict\\";
|
||||
"use strict";
|
||||
_class_call_check(this, Foo);
|
||||
};
|
||||
",
|
||||
@ -47,14 +47,14 @@ describe("transform", () => {
|
||||
|
||||
const output = await swc.transform(input, {});
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "function _class_call_check(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError(\\"Cannot call a class as a function\\");
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
var Foo = function Foo() {
|
||||
\\"use strict\\";
|
||||
"use strict";
|
||||
_class_call_check(this, Foo);
|
||||
};
|
||||
",
|
||||
@ -99,15 +99,15 @@ describe("parse", () => {
|
||||
});
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Array [
|
||||
Object {
|
||||
"body": Array [],
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"body": [],
|
||||
"declare": false,
|
||||
"decorators": Array [],
|
||||
"identifier": Object {
|
||||
"decorators": [],
|
||||
"identifier": {
|
||||
"optional": false,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 2,
|
||||
"end": 289,
|
||||
"start": 286,
|
||||
@ -115,9 +115,9 @@ describe("parse", () => {
|
||||
"type": "Identifier",
|
||||
"value": "Foo",
|
||||
},
|
||||
"implements": Array [],
|
||||
"implements": [],
|
||||
"isAbstract": false,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 0,
|
||||
"end": 292,
|
||||
"start": 280,
|
||||
@ -129,7 +129,7 @@ describe("parse", () => {
|
||||
},
|
||||
],
|
||||
"interpreter": null,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 0,
|
||||
"end": 292,
|
||||
"start": 280,
|
||||
@ -146,15 +146,15 @@ describe("parse", () => {
|
||||
});
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Array [
|
||||
Object {
|
||||
"body": Array [],
|
||||
{
|
||||
"body": [
|
||||
{
|
||||
"body": [],
|
||||
"declare": false,
|
||||
"decorators": Array [],
|
||||
"identifier": Object {
|
||||
"decorators": [],
|
||||
"identifier": {
|
||||
"optional": false,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 2,
|
||||
"end": 302,
|
||||
"start": 299,
|
||||
@ -162,9 +162,9 @@ describe("parse", () => {
|
||||
"type": "Identifier",
|
||||
"value": "Foo",
|
||||
},
|
||||
"implements": Array [],
|
||||
"implements": [],
|
||||
"isAbstract": false,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 0,
|
||||
"end": 305,
|
||||
"start": 293,
|
||||
@ -176,7 +176,7 @@ describe("parse", () => {
|
||||
},
|
||||
],
|
||||
"interpreter": null,
|
||||
"span": Object {
|
||||
"span": {
|
||||
"ctxt": 0,
|
||||
"end": 305,
|
||||
"start": 293,
|
||||
@ -194,7 +194,7 @@ describe("minify", () => {
|
||||
);
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "let somename=1;console.log(1);",
|
||||
}
|
||||
`);
|
||||
@ -206,7 +206,7 @@ describe("minify", () => {
|
||||
);
|
||||
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "let somename=1;console.log(1);",
|
||||
}
|
||||
`);
|
||||
@ -222,7 +222,7 @@ describe("print", () => {
|
||||
|
||||
const output = swc.printSync(input);
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "class Foo {
|
||||
}
|
||||
",
|
||||
@ -238,7 +238,7 @@ describe("print", () => {
|
||||
|
||||
const output = await swc.print(input);
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"code": "class Foo {
|
||||
}
|
||||
",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"jest": "^25.1.0"
|
||||
"jest": "^29.7.0"
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ it("should compress", async () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"import o from\\"@src/app\\";console.log(o);"`
|
||||
`"import o from"@src/app";console.log(o);"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@ it("should accept object", async () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"import o from\\"@src/app\\";console.log(o);"`
|
||||
`"import o from"@src/app";console.log(o);"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -46,7 +46,7 @@ it("should accept { mangle = true }", async () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"import o from\\"@src/app\\";console.log(o);"`
|
||||
`"import o from"@src/app";console.log(o);"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -66,7 +66,7 @@ it("should accept { mangle = object }", async () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"import o from\\"@src/app\\";console.log(o);"`
|
||||
`"import o from"@src/app";console.log(o);"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -92,7 +92,7 @@ it("should mangle locals", async () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"(function(){const o=Math.random()+\\"_\\"+Math.random();console.log(o);console.log(o);console.log(o);console.log(o);console.log(o);console.log(o)})();"`
|
||||
`"(function(){const o=Math.random()+"_"+Math.random();console.log(o);console.log(o);console.log(o);console.log(o);console.log(o);console.log(o)})();"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -170,7 +170,7 @@ describe("transform apis", () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"(function(){var o=Math.random()+\\"_\\"+Math.random();console.log(o);console.log(o);console.log(o);console.log(o);console.log(o);console.log(o)})();"`
|
||||
`"(function(){var o=Math.random()+"_"+Math.random();console.log(o);console.log(o);console.log(o);console.log(o);console.log(o);console.log(o)})();"`
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -196,7 +196,7 @@ describe("should remove comments", () => {
|
||||
);
|
||||
|
||||
expect(code).toMatchInlineSnapshot(
|
||||
`"(function(){const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();"`
|
||||
`"(function(){const o=Math.random()+"_"+Math.random();console.log(o)})();"`
|
||||
);
|
||||
});
|
||||
|
||||
@ -222,7 +222,7 @@ describe("should remove comments", () => {
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"(function(){/**
|
||||
* @license
|
||||
*/const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();"
|
||||
*/const o=Math.random()+"_"+Math.random();console.log(o)})();"
|
||||
`);
|
||||
});
|
||||
it("should remove comment near to license", async () => {
|
||||
@ -250,7 +250,7 @@ describe("should remove comments", () => {
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"(function(){/**
|
||||
* @license
|
||||
*/const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();"
|
||||
*/const o=Math.random()+"_"+Math.random();console.log(o)})();"
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe("when jsc.experimentalDisableBuiltinTransforms is true", () => {
|
||||
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"const hello: Type = ()=>{
|
||||
console.log(\\"hello\\");
|
||||
console.log("hello");
|
||||
};
|
||||
"
|
||||
`);
|
||||
|
@ -32,10 +32,10 @@ it("should override react", async () => {
|
||||
}
|
||||
);
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"import { jsx as _jsx } from \\"react/jsx-runtime\\";
|
||||
"import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default function foo() {
|
||||
return /*#__PURE__*/ _jsx(\\"div\\", {
|
||||
children: \\"Hello\\"
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
children: "Hello"
|
||||
});
|
||||
}
|
||||
"
|
||||
@ -68,10 +68,10 @@ it("should merge correctly", async () => {
|
||||
});
|
||||
// It should transpile react jsx with automatic runtime
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"import { jsx as _jsx } from \\"react/jsx-runtime\\";
|
||||
"import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default function foo() {
|
||||
return /*#__PURE__*/ _jsx(\\"div\\", {
|
||||
children: \\"Hello\\"
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
children: "Hello"
|
||||
});
|
||||
}
|
||||
"
|
||||
@ -96,20 +96,20 @@ it("module config should merged correctly", async () => {
|
||||
});
|
||||
// It should transpile react jsx with automatic runtime
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"\\"use strict\\";
|
||||
Object.defineProperty(exports, \\"__esModule\\", {
|
||||
""use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, \\"default\\", {
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return foo;
|
||||
}
|
||||
});
|
||||
const _jsxruntime = require(\\"react/jsx-runtime\\");
|
||||
const _jsxruntime = require("react/jsx-runtime");
|
||||
function foo() {
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)(\\"div\\", {
|
||||
children: \\"Hello\\"
|
||||
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
||||
children: "Hello"
|
||||
});
|
||||
}
|
||||
"
|
||||
|
@ -26,10 +26,10 @@ it("should allow using tsx", async () => {
|
||||
},
|
||||
});
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"import { jsx as _jsx } from \\"react/jsx-runtime\\";
|
||||
"import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default function foo() {
|
||||
return /*#__PURE__*/ _jsx(\\"div\\", {
|
||||
children: \\"Hello\\"
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
children: "Hello"
|
||||
});
|
||||
}
|
||||
"
|
||||
@ -53,10 +53,10 @@ it("should respect .swcrc without parser option", async () => {
|
||||
},
|
||||
});
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"import { jsx as _jsx } from \\"react/jsx-runtime\\";
|
||||
"import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export default function foo() {
|
||||
return /*#__PURE__*/ _jsx(\\"div\\", {
|
||||
children: \\"Hello\\"
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
children: "Hello"
|
||||
});
|
||||
}
|
||||
"
|
||||
|
@ -33,14 +33,14 @@ it("should work", async () => {
|
||||
},
|
||||
});
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"\\"use strict\\";
|
||||
Object.defineProperty(exports, \\"__esModule\\", {
|
||||
""use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
const _interop_require_wildcard = require(\\"@swc/helpers/_/_interop_require_wildcard\\");
|
||||
const _b = require(\\"../packages/b/src\\");
|
||||
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
||||
const _b = require("../packages/b/src");
|
||||
async function display() {
|
||||
const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(\\"../packages/a/src\\"))).then((c)=>c.displayA);
|
||||
const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("../packages/a/src"))).then((c)=>c.displayA);
|
||||
console.log(displayA());
|
||||
console.log((0, _b.displayB)());
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ it("should transpile decorators", async () => {
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"function _ts_decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === \\"object\\" && typeof Reflect.decorate === \\"function\\") r = Reflect.decorate(decorators, target, key, desc);
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
@ -29,7 +29,7 @@ it("should transpile decorators", async () => {
|
||||
}
|
||||
_ts_decorate([
|
||||
foo
|
||||
], TestClass.prototype, \\"abc\\", null);
|
||||
], TestClass.prototype, "abc", null);
|
||||
function foo(target, propertyKey) {
|
||||
console.log(\`Decorating \${target}.\${String(propertyKey)}\`);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import swc from "../../..";
|
||||
it("should transpile decorators", async () => {
|
||||
const source = "`${100}testing`";
|
||||
expect(swc.transformSync(source).code).toMatchInlineSnapshot(`
|
||||
"\\"\\".concat(100, \\"testing\\");
|
||||
""".concat(100, "testing");
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
@ -33,11 +33,11 @@ describe("jsc.paths", () => {
|
||||
})
|
||||
).code
|
||||
).toMatchInlineSnapshot(`
|
||||
"\\"use strict\\";
|
||||
Object.defineProperty(exports, \\"__esModule\\", {
|
||||
""use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
const _helloworldutils = require(\\"src/utils/hello-world.utils.js\\");
|
||||
const _helloworldutils = require("src/utils/hello-world.utils.js");
|
||||
console.log((0, _helloworldutils.helloWorld)());
|
||||
"
|
||||
`);
|
||||
@ -68,11 +68,11 @@ describe("jsc.paths", () => {
|
||||
})
|
||||
).code
|
||||
).toMatchInlineSnapshot(`
|
||||
"\\"use strict\\";
|
||||
Object.defineProperty(exports, \\"__esModule\\", {
|
||||
""use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
const _helloworldutils = require(\\"src/utils/hello-world.utils.js\\");
|
||||
const _helloworldutils = require("src/utils/hello-world.utils.js");
|
||||
console.log((0, _helloworldutils.helloWorld)());
|
||||
"
|
||||
`);
|
||||
|
@ -47,10 +47,10 @@ it("should respect custom transform option", async () => {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"next\\", value);
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"throw\\", err);
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
@ -68,9 +68,9 @@ it("should respect custom transform option", async () => {
|
||||
};
|
||||
return g = {
|
||||
next: verb(0),
|
||||
\\"throw\\": verb(1),
|
||||
\\"return\\": verb(2)
|
||||
}, typeof Symbol === \\"function\\" && (g[Symbol.iterator] = function() {
|
||||
"throw": verb(1),
|
||||
"return": verb(2)
|
||||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), g;
|
||||
function verb(n) {
|
||||
@ -82,9 +82,9 @@ it("should respect custom transform option", async () => {
|
||||
};
|
||||
}
|
||||
function step(op) {
|
||||
if (f) throw new TypeError(\\"Generator is already executing.\\");
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while(_)try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y[\\"return\\"] : op[0] ? y[\\"throw\\"] || ((t = y[\\"return\\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [
|
||||
op[0] & 2,
|
||||
t.value
|
||||
|
@ -99,7 +99,7 @@ describe("Published plugins", () => {
|
||||
console.log("After transformSync");
|
||||
|
||||
expect(code).toMatchInlineSnapshot(`
|
||||
"console.log(\\"hello world\\");
|
||||
"console.log("hello world");
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
58
node-swc/src/binding.d.ts
vendored
58
node-swc/src/binding.d.ts
vendored
@ -1,33 +1,49 @@
|
||||
/* tslint:disable */
|
||||
/* auto-generated by NAPI-RS */
|
||||
/* eslint-disable */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
export class Compiler {
|
||||
constructor()
|
||||
}
|
||||
export type JsCompiler = Compiler
|
||||
|
||||
export function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
|
||||
|
||||
export function getTargetTriple(): string
|
||||
|
||||
export function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
||||
|
||||
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
|
||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||
|
||||
export function parse(src: string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>
|
||||
|
||||
export function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
|
||||
|
||||
export function parseFileSync(path: string, opts: Buffer): string
|
||||
|
||||
export function parseSync(src: string, opts: Buffer, filename?: string | undefined | null): string
|
||||
|
||||
export function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
|
||||
export function printSync(program: string, options: Buffer): TransformOutput
|
||||
|
||||
export function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
|
||||
export function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
|
||||
export function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
||||
|
||||
export interface TransformOutput {
|
||||
code: string
|
||||
map?: string
|
||||
}
|
||||
export function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
|
||||
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||
export function parse(src: string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>
|
||||
export function parseSync(src: string, opts: Buffer, filename?: string | undefined | null): string
|
||||
export function parseFileSync(path: string, opts: Buffer): string
|
||||
export function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
|
||||
export function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function printSync(program: string, options: Buffer): TransformOutput
|
||||
export function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
||||
export function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
||||
export function getTargetTriple(): string
|
||||
export function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
||||
|
||||
/** Hack for `Type Generation` */
|
||||
export interface TransformOutput {
|
||||
code: string
|
||||
map?: string
|
||||
}
|
||||
export type JsCompiler = Compiler
|
||||
export class Compiler {
|
||||
constructor()
|
||||
}
|
||||
|
||||
export function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* tslint:disable */
|
||||
// prettier-ignore
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
@ -13,18 +11,52 @@ let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let loadError = null
|
||||
|
||||
function isMusl() {
|
||||
// For Node 10
|
||||
if (!process.report || typeof process.report.getReport !== 'function') {
|
||||
try {
|
||||
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
||||
return readFileSync(lddPath, 'utf8').includes('musl')
|
||||
} catch (e) {
|
||||
const isMusl = () => {
|
||||
let musl = false
|
||||
if (process.platform === 'linux') {
|
||||
musl = isMuslFromFilesystem()
|
||||
if (musl === null) {
|
||||
musl = isMuslFromReport()
|
||||
}
|
||||
if (musl === null) {
|
||||
musl = isMuslFromChildProcess()
|
||||
}
|
||||
}
|
||||
return musl
|
||||
}
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
||||
|
||||
const isMuslFromFilesystem = () => {
|
||||
try {
|
||||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const isMuslFromReport = () => {
|
||||
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
||||
if (!report) {
|
||||
return null
|
||||
}
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return false
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
const { glibcVersionRuntime } = process.report.getReport().header
|
||||
return !glibcVersionRuntime
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const isMuslFromChildProcess = () => {
|
||||
try {
|
||||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
||||
} catch (e) {
|
||||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,21 +284,20 @@ if (!nativeBinding) {
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { bundle, minify, minifySync, parse, parseSync, parseFileSync, parseFile, print, printSync, transform, transformSync, transformFile, transformFileSync, getTargetTriple, initCustomTraceSubscriber, Compiler } = nativeBinding
|
||||
|
||||
module.exports.bundle = bundle
|
||||
module.exports.minify = minify
|
||||
module.exports.minifySync = minifySync
|
||||
module.exports.parse = parse
|
||||
module.exports.parseSync = parseSync
|
||||
module.exports.parseFileSync = parseFileSync
|
||||
module.exports.parseFile = parseFile
|
||||
module.exports.print = print
|
||||
module.exports.printSync = printSync
|
||||
module.exports.transform = transform
|
||||
module.exports.transformSync = transformSync
|
||||
module.exports.transformFile = transformFile
|
||||
module.exports.transformFileSync = transformFileSync
|
||||
module.exports.getTargetTriple = getTargetTriple
|
||||
module.exports.initCustomTraceSubscriber = initCustomTraceSubscriber
|
||||
module.exports.Compiler = Compiler
|
||||
module.exports.Compiler = nativeBinding.Compiler
|
||||
module.exports.JsCompiler = nativeBinding.JsCompiler
|
||||
module.exports.bundle = nativeBinding.bundle
|
||||
module.exports.getTargetTriple = nativeBinding.getTargetTriple
|
||||
module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber
|
||||
module.exports.minify = nativeBinding.minify
|
||||
module.exports.minifySync = nativeBinding.minifySync
|
||||
module.exports.parse = nativeBinding.parse
|
||||
module.exports.parseFile = nativeBinding.parseFile
|
||||
module.exports.parseFileSync = nativeBinding.parseFileSync
|
||||
module.exports.parseSync = nativeBinding.parseSync
|
||||
module.exports.print = nativeBinding.print
|
||||
module.exports.printSync = nativeBinding.printSync
|
||||
module.exports.transform = nativeBinding.transform
|
||||
module.exports.transformFile = nativeBinding.transformFile
|
||||
module.exports.transformFileSync = nativeBinding.transformFileSync
|
||||
module.exports.transformSync = nativeBinding.transformSync
|
||||
|
30
package.json
30
package.json
@ -26,12 +26,13 @@
|
||||
"url": "https://github.com/swc-project/swc/issues"
|
||||
},
|
||||
"napi": {
|
||||
"name": "swc",
|
||||
"binaryName": "swc",
|
||||
"triples": {
|
||||
"defaults": true,
|
||||
"additional": [
|
||||
"x86_64-unknown-linux-musl",
|
||||
"i686-pc-windows-msvc",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-musl",
|
||||
@ -53,8 +54,8 @@
|
||||
"pack": "wasm-pack",
|
||||
"build:ts": "tsc -d",
|
||||
"build:wasm": "npm-run-all \"pack -- build ./bindings/binding_core_wasm --scope swc {1} -t {2} --features plugin\" --",
|
||||
"build": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --cargo-cwd ./bindings -p binding_core_node --release",
|
||||
"build:dev": "tsc -d && napi build --platform --cargo-name binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --cargo-cwd ./bindings -p binding_core_node",
|
||||
"build": "tsc -d && napi build --manifest-path bindings/Cargo.toml --platform -p binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts --release -o .",
|
||||
"build:dev": "tsc -d && napi build --manifest-path bindings/Cargo.toml --platform -p binding_core_node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -o .",
|
||||
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --config ./node-swc/jest.config.js",
|
||||
"version": "napi version -p scripts/npm"
|
||||
},
|
||||
@ -92,12 +93,13 @@
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"@babel/types": "^7.14.0",
|
||||
"@napi-rs/cli": "^2.16.5",
|
||||
"@napi-rs/cli": "^3.0.0-alpha.15",
|
||||
"@napi-rs/cross-toolchain": "^0.0.12",
|
||||
"@swc/core": "=1.2.220",
|
||||
"@swc/helpers": "^0.5.0",
|
||||
"@swc/plugin-jest": "latest",
|
||||
"@taplo/cli": "^0.3.2",
|
||||
"@types/jest": "^28.1.4",
|
||||
"@taplo/cli": "^0.5.2",
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/node": "^20.5.0",
|
||||
"@types/terser": "^3.12.0",
|
||||
"acorn": "^8.6.0",
|
||||
@ -114,7 +116,7 @@
|
||||
"expect": "^27.4.2",
|
||||
"glob": "^8.0.3",
|
||||
"husky": "^7.0.2",
|
||||
"jest": "^28.1.2",
|
||||
"jest": "^29.7.0",
|
||||
"js-beautify": "^1.14.3",
|
||||
"lint-staged": "^12.3.6",
|
||||
"lodash": "^4.17.21",
|
||||
@ -146,18 +148,6 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/swc"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@swc/core-darwin-arm64": "1.2.146",
|
||||
"@swc/core-darwin-x64": "1.2.146",
|
||||
"@swc/core-linux-arm-gnueabihf": "1.2.146",
|
||||
"@swc/core-linux-arm64-gnu": "1.2.146",
|
||||
"@swc/core-linux-arm64-musl": "1.2.146",
|
||||
"@swc/core-linux-x64-gnu": "1.2.146",
|
||||
"@swc/core-linux-x64-musl": "1.2.146",
|
||||
"@swc/core-win32-arm64-msvc": "1.2.146",
|
||||
"@swc/core-win32-ia32-msvc": "1.2.146",
|
||||
"@swc/core-win32-x64-msvc": "1.2.146"
|
||||
},
|
||||
"files": [
|
||||
"CHANGELOG.md",
|
||||
"Visitor.d.ts",
|
||||
@ -178,7 +168,7 @@
|
||||
"postinstall.js",
|
||||
"bindings/binding_core_wasm/pkg/binding_core_wasm.d.ts"
|
||||
],
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"packageManager": "yarn@4.0.2",
|
||||
"dependencies": {
|
||||
"@swc/counter": "^0.1.1",
|
||||
"@swc/types": "^0.1.5"
|
||||
|
@ -45,8 +45,8 @@
|
||||
"pack": "wasm-pack",
|
||||
"build:ts": "tsc -d",
|
||||
"build:wasm": "npm-run-all \"pack -- build ../../bindings/binding_html_wasm --scope swc {1} -t {2}\" --",
|
||||
"build": "tsc -d && napi build --platform --cargo-name binding_html_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_html_node --release",
|
||||
"build:dev": "tsc -d && napi build --platform --cargo-name binding_html_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_html_node",
|
||||
"build": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_html_node --output-dir . --release",
|
||||
"build:dev": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_html_node --output-dir .",
|
||||
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
|
||||
"version": "napi version -p scripts/npm"
|
||||
},
|
||||
@ -54,13 +54,12 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/swc"
|
||||
},
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"dependencies": {
|
||||
"@swc/counter": "^0.1.1",
|
||||
"@swc/types": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.16.3",
|
||||
"@napi-rs/cli": "^3.0.0-alpha.15",
|
||||
"@types/node": "^20.7.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"typescript": "^5.2.2"
|
||||
|
@ -22,13 +22,14 @@
|
||||
"url": "https://github.com/swc-project/swc/issues"
|
||||
},
|
||||
"napi": {
|
||||
"name": "minifier",
|
||||
"binaryName": "minifier",
|
||||
"triples": {
|
||||
"defaults": true,
|
||||
"additional": [
|
||||
"x86_64-unknown-linux-musl",
|
||||
"i686-pc-windows-msvc",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"aarch64-pc-windows-msvc"
|
||||
@ -46,8 +47,8 @@
|
||||
"pack": "wasm-pack",
|
||||
"build:ts": "tsc -d",
|
||||
"build:wasm": "npm-run-all \"pack -- build ../../bindings/binding_minifier_wasm --scope swc {1} -t {2}\" --",
|
||||
"build": "tsc -d && napi build --platform --cargo-name binding_minifier_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_minifier_node --release",
|
||||
"build:dev": "tsc -d && napi build --platform --cargo-name binding_minifier_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_minifier_node",
|
||||
"build": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_minifier_node --output-dir . --release",
|
||||
"build:dev": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_minifier_node --output-dir .",
|
||||
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
|
||||
"version": "napi version -p scripts/npm"
|
||||
},
|
||||
@ -55,13 +56,12 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/swc"
|
||||
},
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"dependencies": {
|
||||
"@swc/counter": "workspace:^",
|
||||
"@swc/types": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.16.3",
|
||||
"@napi-rs/cli": "^3.0.0-alpha.15",
|
||||
"@types/node": "^20.7.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"typescript": "^5.2.2"
|
||||
|
@ -0,0 +1,3 @@
|
||||
# `@swc/minifier-linux-arm-gnueabihf`
|
||||
|
||||
This is the **armv7-unknown-linux-gnueabihf** binary for `@swc/minifier`
|
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@swc/minifier-linux-arm-gnueabihf",
|
||||
"version": "1.3.100",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"main": "minifier.linux-arm-gnueabihf.node",
|
||||
"files": [
|
||||
"minifier.linux-arm-gnueabihf.node",
|
||||
"swc"
|
||||
],
|
||||
"description": "Super-fast alternative for terser",
|
||||
"keywords": [
|
||||
"swc",
|
||||
"terser",
|
||||
"minifier"
|
||||
],
|
||||
"author": "강동윤 <kdy1997.dev@gmail.com>",
|
||||
"homepage": "https://swc.rs",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/swc-project/swc.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/swc-project/swc/issues"
|
||||
}
|
||||
}
|
16
packages/minifier/src/binding.d.ts
vendored
16
packages/minifier/src/binding.d.ts
vendored
@ -1,18 +1,22 @@
|
||||
/* tslint:disable */
|
||||
/* auto-generated by NAPI-RS */
|
||||
/* eslint-disable */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
export function getTargetTriple(): string
|
||||
|
||||
export function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
||||
|
||||
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
|
||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||
|
||||
export interface TransformOutput {
|
||||
code: string
|
||||
map?: string
|
||||
}
|
||||
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||
export function getTargetTriple(): string
|
||||
export function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
||||
|
||||
/** Hack for `Type Generation` */
|
||||
export interface TransformOutput {
|
||||
code: string
|
||||
map?: string
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* tslint:disable */
|
||||
// prettier-ignore
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
@ -13,18 +11,52 @@ let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let loadError = null
|
||||
|
||||
function isMusl() {
|
||||
// For Node 10
|
||||
if (!process.report || typeof process.report.getReport !== 'function') {
|
||||
try {
|
||||
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
||||
return readFileSync(lddPath, 'utf8').includes('musl')
|
||||
} catch (e) {
|
||||
const isMusl = () => {
|
||||
let musl = false
|
||||
if (process.platform === 'linux') {
|
||||
musl = isMuslFromFilesystem()
|
||||
if (musl === null) {
|
||||
musl = isMuslFromReport()
|
||||
}
|
||||
if (musl === null) {
|
||||
musl = isMuslFromChildProcess()
|
||||
}
|
||||
}
|
||||
return musl
|
||||
}
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
||||
|
||||
const isMuslFromFilesystem = () => {
|
||||
try {
|
||||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const isMuslFromReport = () => {
|
||||
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
||||
if (!report) {
|
||||
return null
|
||||
}
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return false
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
const { glibcVersionRuntime } = process.report.getReport().header
|
||||
return !glibcVersionRuntime
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const isMuslFromChildProcess = () => {
|
||||
try {
|
||||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
||||
} catch (e) {
|
||||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,9 +284,7 @@ if (!nativeBinding) {
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { minify, minifySync, getTargetTriple, initCustomTraceSubscriber } = nativeBinding
|
||||
|
||||
module.exports.minify = minify
|
||||
module.exports.minifySync = minifySync
|
||||
module.exports.getTargetTriple = getTargetTriple
|
||||
module.exports.initCustomTraceSubscriber = initCustomTraceSubscriber
|
||||
module.exports.getTargetTriple = nativeBinding.getTargetTriple
|
||||
module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber
|
||||
module.exports.minify = nativeBinding.minify
|
||||
module.exports.minifySync = nativeBinding.minifySync
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@swc/workspace",
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"packageManager": "yarn@4.0.2",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"./*"
|
||||
|
@ -45,8 +45,8 @@
|
||||
"pack": "wasm-pack",
|
||||
"build:ts": "tsc -d",
|
||||
"build:wasm": "npm-run-all \"pack -- build ../../bindings/binding_xml_wasm --scope swc {1} -t {2}\" --",
|
||||
"build": "tsc -d && napi build --platform --cargo-name binding_xml_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_xml_node --release",
|
||||
"build:dev": "tsc -d && napi build --platform --cargo-name binding_xml_node --js ./src/binding.js --dts ./src/binding.d.ts --cargo-cwd ../../bindings -p binding_xml_node",
|
||||
"build": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_xml_node --output-dir . --release",
|
||||
"build:dev": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_xml_node --output-dir .",
|
||||
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
|
||||
"version": "napi version -p scripts/npm"
|
||||
},
|
||||
@ -54,13 +54,12 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/swc"
|
||||
},
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"dependencies": {
|
||||
"@swc/counter": "^0.1.1",
|
||||
"@swc/types": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.16.3",
|
||||
"@napi-rs/cli": "^3.0.0-alpha.15",
|
||||
"@types/node": "^20.7.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"typescript": "^5.2.2"
|
||||
|
1484
packages/yarn.lock
1484
packages/yarn.lock
File diff suppressed because it is too large
Load Diff
300
postinstall.js
300
postinstall.js
@ -1,91 +1,36 @@
|
||||
"use strict";
|
||||
var __createBinding =
|
||||
(this && this.__createBinding) ||
|
||||
(Object.create
|
||||
? function (o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (
|
||||
!desc ||
|
||||
("get" in desc
|
||||
? !m.__esModule
|
||||
: desc.writable || desc.configurable)
|
||||
) {
|
||||
desc = {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return m[k];
|
||||
},
|
||||
};
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}
|
||||
: function (o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
});
|
||||
var __setModuleDefault =
|
||||
(this && this.__setModuleDefault) ||
|
||||
(Object.create
|
||||
? function (o, v) {
|
||||
Object.defineProperty(o, "default", {
|
||||
enumerable: true,
|
||||
value: v,
|
||||
});
|
||||
}
|
||||
: function (o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar =
|
||||
(this && this.__importStar) ||
|
||||
function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null)
|
||||
for (var k in mod)
|
||||
if (
|
||||
k !== "default" &&
|
||||
Object.prototype.hasOwnProperty.call(mod, k)
|
||||
)
|
||||
__createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter =
|
||||
(this && this.__awaiter) ||
|
||||
function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) {
|
||||
return value instanceof P
|
||||
? value
|
||||
: new P(function (resolve) {
|
||||
resolve(value);
|
||||
});
|
||||
}
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
function rejected(value) {
|
||||
try {
|
||||
step(generator["throw"](value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
function step(result) {
|
||||
result.done
|
||||
? resolve(result.value)
|
||||
: adopt(result.value).then(fulfilled, rejected);
|
||||
}
|
||||
step(
|
||||
(generator = generator.apply(thisArg, _arguments || [])).next()
|
||||
);
|
||||
});
|
||||
};
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* A postinstall script runs after `@swc/core` is installed.
|
||||
@ -104,123 +49,98 @@ function removeRecursive(dir) {
|
||||
let stats;
|
||||
try {
|
||||
stats = fs.lstatSync(entryPath);
|
||||
} catch (_a) {
|
||||
}
|
||||
catch (_a) {
|
||||
continue; // Guard against https://github.com/nodejs/node/issues/4760
|
||||
}
|
||||
if (stats.isDirectory()) removeRecursive(entryPath);
|
||||
else fs.unlinkSync(entryPath);
|
||||
if (stats.isDirectory())
|
||||
removeRecursive(entryPath);
|
||||
else
|
||||
fs.unlinkSync(entryPath);
|
||||
}
|
||||
fs.rmdirSync(dir);
|
||||
}
|
||||
/**
|
||||
* Trying to validate @swc/core's native binary installation, then installs if it is not supported.
|
||||
*/
|
||||
const validateBinary = () =>
|
||||
__awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
try {
|
||||
const { name } = require(path.resolve(
|
||||
process.env.INIT_CWD,
|
||||
"package.json"
|
||||
));
|
||||
if (name === "@swc/core") {
|
||||
return;
|
||||
}
|
||||
} catch (_) {
|
||||
const validateBinary = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
try {
|
||||
const { name } = require(path.resolve(process.env.INIT_CWD, 'package.json'));
|
||||
if (name === '@swc/core') {
|
||||
return;
|
||||
}
|
||||
// TODO: We do not take care of the case if user try to install with `--no-optional`.
|
||||
// For now, it is considered as deliberate decision.
|
||||
let binding;
|
||||
try {
|
||||
binding = require("./binding");
|
||||
// Check if binding binary actually works.
|
||||
// For the latest version, checks target triple. If it's old version doesn't have target triple, use parseSync instead.
|
||||
const triple = binding.getTargetTriple
|
||||
? binding.getTargetTriple()
|
||||
: binding.parseSync(
|
||||
"console.log()",
|
||||
Buffer.from(JSON.stringify({ syntax: "ecmascript" }))
|
||||
);
|
||||
assert.ok(
|
||||
triple,
|
||||
"Failed to read target triple from native binary."
|
||||
);
|
||||
} catch (error) {
|
||||
// if error is unsupported architecture, ignore to display.
|
||||
if (
|
||||
!((_a = error.message) === null || _a === void 0
|
||||
? void 0
|
||||
: _a.includes("Unsupported architecture"))
|
||||
) {
|
||||
console.warn(error);
|
||||
}
|
||||
console.warn(
|
||||
`@swc/core was not able to resolve native bindings installation. It'll try to use @swc/wasm as fallback instead.`
|
||||
);
|
||||
}
|
||||
catch (_) {
|
||||
return;
|
||||
}
|
||||
// TODO: We do not take care of the case if user try to install with `--no-optional`.
|
||||
// For now, it is considered as deliberate decision.
|
||||
let binding;
|
||||
try {
|
||||
binding = require('./binding');
|
||||
// Check if binding binary actually works.
|
||||
// For the latest version, checks target triple. If it's old version doesn't have target triple, use parseSync instead.
|
||||
const triple = binding.getTargetTriple ? binding.getTargetTriple() : binding.parseSync('console.log()', Buffer.from(JSON.stringify({ syntax: "ecmascript" })));
|
||||
assert.ok(triple, 'Failed to read target triple from native binary.');
|
||||
}
|
||||
catch (error) {
|
||||
// if error is unsupported architecture, ignore to display.
|
||||
if (!((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Unsupported architecture'))) {
|
||||
console.warn(error);
|
||||
}
|
||||
if (!!binding) {
|
||||
return;
|
||||
}
|
||||
// User choose to override the binary installation. Skip remanining validation.
|
||||
if (!!process.env["SWC_BINARY_PATH"]) {
|
||||
console.warn(
|
||||
`@swc/core could not resolve native bindings installation, but found manual override config SWC_BINARY_PATH specified. Skipping remaning validation.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Check if top-level package.json installs @swc/wasm separately already
|
||||
let wasmBinding;
|
||||
try {
|
||||
wasmBinding = require.resolve(`@swc/wasm`);
|
||||
} catch (_) {}
|
||||
if (!!wasmBinding && (0, fs_1.existsSync)(wasmBinding)) {
|
||||
return;
|
||||
}
|
||||
const env = Object.assign(Object.assign({}, process.env), {
|
||||
npm_config_global: undefined,
|
||||
});
|
||||
const { version } = require(path.join(
|
||||
path.dirname(require.resolve("@swc/core")),
|
||||
"package.json"
|
||||
));
|
||||
// We want to place @swc/wasm next to the @swc/core as if normal installation was done,
|
||||
// but can't directly set cwd to INIT_CWD as npm seems to acquire lock to the working dir.
|
||||
// Instead, create a temporary inner and move it out.
|
||||
const coreDir = path.dirname(require.resolve("@swc/core"));
|
||||
const installDir = path.join(coreDir, "npm-install");
|
||||
try {
|
||||
fs.mkdirSync(installDir);
|
||||
fs.writeFileSync(path.join(installDir, "package.json"), "{}");
|
||||
// Instead of carrying over own dependencies to download & resolve package which increases installation sizes of `@swc/core`,
|
||||
// assume & relies on system's npm installation.
|
||||
child_process.execSync(
|
||||
`npm install --no-save --loglevel=error --prefer-offline --no-audit --progress=false @swc/wasm@${version}`,
|
||||
{ cwd: installDir, stdio: "pipe", env }
|
||||
);
|
||||
const installedBinPath = path.join(
|
||||
installDir,
|
||||
"node_modules",
|
||||
`@swc/wasm`
|
||||
);
|
||||
// INIT_CWD is injected via npm. If it doesn't exists, can't proceed.
|
||||
fs.renameSync(
|
||||
installedBinPath,
|
||||
path.resolve(process.env.INIT_CWD, "node_modules", `@swc/wasm`)
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(`Failed to install fallback @swc/wasm@${version}. @swc/core will not properly.
|
||||
console.warn(`@swc/core was not able to resolve native bindings installation. It'll try to use @swc/wasm as fallback instead.`);
|
||||
}
|
||||
if (!!binding) {
|
||||
return;
|
||||
}
|
||||
// User choose to override the binary installation. Skip remanining validation.
|
||||
if (!!process.env["SWC_BINARY_PATH"]) {
|
||||
console.warn(`@swc/core could not resolve native bindings installation, but found manual override config SWC_BINARY_PATH specified. Skipping remaning validation.`);
|
||||
return;
|
||||
}
|
||||
// Check if top-level package.json installs @swc/wasm separately already
|
||||
let wasmBinding;
|
||||
try {
|
||||
wasmBinding = require.resolve(`@swc/wasm`);
|
||||
}
|
||||
catch (_) {
|
||||
}
|
||||
if (!!wasmBinding && (0, fs_1.existsSync)(wasmBinding)) {
|
||||
return;
|
||||
}
|
||||
const env = Object.assign(Object.assign({}, process.env), { npm_config_global: undefined });
|
||||
const { version } = require(path.join(path.dirname(require.resolve('@swc/core')), 'package.json'));
|
||||
// We want to place @swc/wasm next to the @swc/core as if normal installation was done,
|
||||
// but can't directly set cwd to INIT_CWD as npm seems to acquire lock to the working dir.
|
||||
// Instead, create a temporary inner and move it out.
|
||||
const coreDir = path.dirname(require.resolve('@swc/core'));
|
||||
const installDir = path.join(coreDir, 'npm-install');
|
||||
try {
|
||||
fs.mkdirSync(installDir);
|
||||
fs.writeFileSync(path.join(installDir, 'package.json'), '{}');
|
||||
// Instead of carrying over own dependencies to download & resolve package which increases installation sizes of `@swc/core`,
|
||||
// assume & relies on system's npm installation.
|
||||
child_process.execSync(`npm install --no-save --loglevel=error --prefer-offline --no-audit --progress=false @swc/wasm@${version}`, { cwd: installDir, stdio: 'pipe', env });
|
||||
const installedBinPath = path.join(installDir, 'node_modules', `@swc/wasm`);
|
||||
// INIT_CWD is injected via npm. If it doesn't exists, can't proceed.
|
||||
fs.renameSync(installedBinPath, path.resolve(process.env.INIT_CWD, 'node_modules', `@swc/wasm`));
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
console.error(`Failed to install fallback @swc/wasm@${version}. @swc/core will not properly.
|
||||
Please install @swc/wasm manually, or retry whole installation.
|
||||
If there are unexpected errors, please report at https://github.com/swc-project/swc/issues`);
|
||||
} finally {
|
||||
try {
|
||||
removeRecursive(installDir);
|
||||
} catch (_) {
|
||||
// Gracefully ignore any failures. This'll make few leftover files but it shouldn't block installation.
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
removeRecursive(installDir);
|
||||
}
|
||||
});
|
||||
catch (_) {
|
||||
// Gracefully ignore any failures. This'll make few leftover files but it shouldn't block installation.
|
||||
}
|
||||
}
|
||||
});
|
||||
validateBinary().catch((error) => {
|
||||
// for now just throw the error as-is.
|
||||
throw error;
|
||||
|
3
scripts/npm/linux-arm-gnueabihf/README.md
Normal file
3
scripts/npm/linux-arm-gnueabihf/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# `@swc/core-linux-arm-gnueabihf`
|
||||
|
||||
This is the **armv7-unknown-linux-gnueabihf** binary for `@swc/core`
|
42
scripts/npm/linux-arm-gnueabihf/package.json
Normal file
42
scripts/npm/linux-arm-gnueabihf/package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@swc/core-linux-arm-gnueabihf",
|
||||
"version": "1.3.100",
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"main": "swc.linux-arm-gnueabihf.node",
|
||||
"files": [
|
||||
"swc.linux-arm-gnueabihf.node",
|
||||
"swc"
|
||||
],
|
||||
"description": "Super-fast alternative for babel",
|
||||
"keywords": [
|
||||
"swc",
|
||||
"swcpack",
|
||||
"babel",
|
||||
"typescript",
|
||||
"rust",
|
||||
"webpack",
|
||||
"tsc"
|
||||
],
|
||||
"author": "강동윤 <kdy1997.dev@gmail.com>",
|
||||
"homepage": "https://swc.rs",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/swc-project/swc.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/swc-project/swc/issues"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user