Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(bindings): Make @swc/core a subpackage #8625

Merged
merged 81 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
d4d7338
move package.json
kdy1 Feb 8, 2024
97f3cd4
Move lint-staged
kdy1 Feb 8, 2024
81ee629
Remove packages/yarn.lock
kdy1 Feb 8, 2024
8d3118d
fixup for rebase
kdy1 May 16, 2024
5b8b6b7
yarn lockifle
kdy1 May 16, 2024
b222bc7
scripts
kdy1 May 16, 2024
10891fd
typo
kdy1 May 16, 2024
6044c57
yarn lockfile
kdy1 May 16, 2024
3a1d079
postinstall
kdy1 May 16, 2024
ff9ce20
path
kdy1 May 16, 2024
6a2ddc7
dep
kdy1 May 16, 2024
3905548
yarn lockfile
kdy1 May 16, 2024
bfd9159
dep
kdy1 May 16, 2024
64b79a0
yarn lockfile
kdy1 May 16, 2024
04c0469
move
kdy1 May 16, 2024
9cb0232
rootDir
kdy1 May 16, 2024
a91c686
util.ts
kdy1 May 16, 2024
008e66e
binding
kdy1 May 16, 2024
80f009e
path
kdy1 May 16, 2024
def0e79
postinstall
kdy1 May 16, 2024
5039b6e
tsconfig
kdy1 May 16, 2024
01439a8
tsc -d
kdy1 May 16, 2024
6d0358b
allowjs
kdy1 May 16, 2024
691a293
- run: corepack enable
kdy1 May 16, 2024
a589675
publish
kdy1 May 16, 2024
1429885
fix
kdy1 May 16, 2024
f1b8ee8
yarn lockfile
kdy1 May 16, 2024
49684a2
binding
kdy1 May 16, 2024
3e2d9f7
yarn
kdy1 May 16, 2024
8eeca2d
import path
kdy1 May 16, 2024
ca67600
cancel
kdy1 May 16, 2024
cffe0c9
bindings.js
kdy1 May 16, 2024
0856efd
yarn
kdy1 May 16, 2024
f80540e
publish
kdy1 May 16, 2024
bf4cdad
corepack
kdy1 May 16, 2024
47e888b
helpers
kdy1 May 16, 2024
e16986d
yarn lockfile
kdy1 May 16, 2024
0502877
yarbn
kdy1 May 16, 2024
2d8ef3a
package
kdy1 May 16, 2024
617a4d6
yarn lockfile
kdy1 May 16, 2024
057528d
corepack enable
kdy1 May 16, 2024
bf34db3
yarn
kdy1 May 16, 2024
9ad9299
cd ./packages/core &&
kdy1 May 16, 2024
d121be4
(cd packages/core && yarn test)
kdy1 May 16, 2024
31179c4
dep
kdy1 May 16, 2024
e305e42
yarn lockfile
kdy1 May 16, 2024
3dbda83
rust-toolchain
kdy1 May 16, 2024
7825753
exec
kdy1 May 16, 2024
deefc18
f9x path
kdy1 May 16, 2024
688ea8a
move dep jes
kdy1 May 16, 2024
3bc4276
yarn lockfile
kdy1 May 16, 2024
572e5a8
move
kdy1 May 16, 2024
645f3da
dep
kdy1 May 16, 2024
b198869
yarn lockfile
kdy1 May 16, 2024
928133a
binding
kdy1 May 16, 2024
6aea90a
Fix index.ts
kdy1 May 16, 2024
d8741ac
Paths
kdy1 May 16, 2024
4439b97
path
kdy1 May 16, 2024
e0c0872
path
kdy1 May 16, 2024
85068dd
path
kdy1 May 16, 2024
ba5d990
test
kdy1 May 16, 2024
bd4f3db
move dep jest
kdy1 May 17, 2024
c6cc4b2
yarn lockfile
kdy1 May 17, 2024
6c83d95
scripts/npm
kdy1 May 17, 2024
19b077d
order
kdy1 May 17, 2024
6bfd27e
move
kdy1 May 17, 2024
db89918
swc crate
kdy1 May 17, 2024
e410d38
version
kdy1 May 17, 2024
ac04e16
split
kdy1 May 17, 2024
fd75867
cancel
kdy1 May 17, 2024
9242d21
PATH
kdy1 May 17, 2024
195403e
upload path
kdy1 May 17, 2024
0f03253
corepack
kdy1 May 17, 2024
c1367d5
yarn script
kdy1 May 17, 2024
c064f3a
CI*
kdy1 May 17, 2024
c1fa07b
cwd
kdy1 May 17, 2024
7a1c0b7
test
kdy1 May 17, 2024
4df6580
download path
kdy1 May 17, 2024
1295fc0
Move cli_artifcats
kdy1 May 17, 2024
c7ee7bf
./packages/core/
kdy1 May 17, 2024
1bc5d60
working-directory: ./packages/core
kdy1 May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ jobs:
# toolchain: stable
# override: true

- run: corepack enable

- uses: actions/setup-node@v4
with:
node-version: "18"
Expand All @@ -154,6 +156,7 @@ jobs:
- name: Install node dependencies
shell: bash
run: |
corepack enable
yarn

# Ensure that all components are compilable.
Expand All @@ -168,6 +171,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- shell: bash
run: corepack enable

# We explicitly do this to cache properly.
- uses: actions-rs/toolchain@v1
with:
Expand All @@ -191,6 +197,7 @@ jobs:
- name: Install node dependencies
shell: bash
run: |
corepack enable
yarn

- name: Build
Expand Down Expand Up @@ -589,6 +596,8 @@ jobs:
with:
submodules: true

- run: corepack enable

# Source map format
- uses: actions/setup-node@v4
with:
Expand All @@ -613,6 +622,7 @@ jobs:
- name: Install node dependencies
shell: bash
run: |
corepack enable
yarn
# I don't want to think deeply about this
yarn global add jest@27 mocha || \
Expand All @@ -633,7 +643,7 @@ jobs:
- name: Verify dependencies
shell: bash
run: |
jest --version && mocha --version
yarn jest --version && yarn mocha --version

- name: Configure execution cache
shell: bash
Expand Down Expand Up @@ -725,8 +735,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Corepack
shell: bash
- shell: bash
run: corepack enable

# We explicitly do this to cache properly.
Expand All @@ -735,7 +744,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
cache: "yarn"

- name: Patch
Expand All @@ -761,7 +770,14 @@ jobs:
corepack enable
yarn

- name: Build
working-directory: packages/core
run: |
yarn build:dev

- name: Test
working-directory: packages/core
run: |
yarn test

integration-test:
Expand All @@ -772,8 +788,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Corepack
shell: bash
- shell: bash
run: corepack enable

- uses: actions/setup-node@v4
Expand Down Expand Up @@ -878,14 +893,19 @@ jobs:
with:
submodules: true

- shell: bash
run: corepack enable

- uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"

- name: Install node dependencies
shell: bash
run: yarn
run: |
corepack enable
yarn

- name: Print rustup toolchain version
shell: bash
Expand Down
64 changes: 39 additions & 25 deletions .github/workflows/publish-core.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Publish (core)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

env:
DEBUG: napi:*
APP_NAME: swc
Expand Down Expand Up @@ -34,25 +37,25 @@ jobs:
- host: macos-latest
target: x86_64-apple-darwin
build: |
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-apple-darwin
cp ./bindings/target/x86_64-apple-darwin/release/swc .
cargo build --manifest-path ../../bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-apple-darwin
cp ../../bindings/target/x86_64-apple-darwin/release/swc .
chmod +x ./swc
yarn build --target x86_64-apple-darwin
strip -x *.node
- host: windows-latest
build: |
export CARGO_PROFILE_RELEASE_LTO=false
yarn build --target x86_64-pc-windows-msvc
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-pc-windows-msvc
cp ./bindings/target/x86_64-pc-windows-msvc/release/swc .
cargo build --manifest-path ../../bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-pc-windows-msvc
cp ../../bindings/target/x86_64-pc-windows-msvc/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 .
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 --no-default-features --features swc_v1
npm run test
target: i686-pc-windows-msvc
Expand All @@ -61,9 +64,9 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: >-
set -e &&
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 --target x86_64-unknown-linux-gnu &&
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 &&
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 --target x86_64-unknown-linux-gnu &&
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
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
Expand All @@ -72,9 +75,9 @@ jobs:
build: >-
set -e &&
export CARGO_PROFILE_RELEASE_LTO=false &&
RUSTFLAGS='-C target-feature=+sse2' cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-unknown-linux-musl &&
RUSTFLAGS='-C target-feature=+sse2' cargo build --manifest-path ../../bindings/swc_cli/Cargo.toml --release --features plugin --target x86_64-unknown-linux-musl &&
rm -rf target/release/.cargo-lock &&
cp bindings/target/x86_64-unknown-linux-musl/release/swc . && chmod +x ./swc &&
cp ../../bindings/target/x86_64-unknown-linux-musl/release/swc . && chmod +x ./swc &&
RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' yarn build --target x86_64-unknown-linux-musl
- host: macos-latest
target: aarch64-apple-darwin
Expand All @@ -84,8 +87,8 @@ jobs:
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
cargo build --manifest-path ./bindings/swc_cli/Cargo.toml --release --features plugin --target aarch64-apple-darwin
cp ./bindings/target/aarch64-apple-darwin/release/swc .
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
- host: ubuntu-latest
Expand All @@ -95,15 +98,15 @@ jobs:
set -e &&
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 &&
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
- 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 .
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
Expand All @@ -112,11 +115,11 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup toolchain install $(cat ./rust-toolchain) &&
rustup toolchain install $(cat ../../rust-toolchain) &&
rustup target add aarch64-unknown-linux-musl &&
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 &&
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 &&
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
- host: windows-latest
target: aarch64-pc-windows-msvc
Expand All @@ -125,8 +128,8 @@ jobs:
export DISABLE_PLUGIN_E2E_TESTS=true
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
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 .
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 --no-default-features --features swc_v1
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
Expand Down Expand Up @@ -197,10 +200,12 @@ 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: >-
cd ./packages/core &&
corepack enable &&
npm i -g wasm-pack &&
${{ matrix.settings.build }}
- name: Build
working-directory: ./packages/core
if: ${{ !matrix.settings.docker }}
run: ${{ matrix.settings.build }}
shell: bash
Expand All @@ -209,7 +214,7 @@ jobs:
with:
name: bindings-${{ matrix.settings.target }}
path: |
swc*
packages/core/swc*
if-no-files-found: error
test-macOS-windows-binding:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
Expand All @@ -230,14 +235,16 @@ jobs:
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- run: corepack enable
shell: bash
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
architecture: x64
- name: Install dependencies
run: yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
run: corepack enable && yarn install --network-timeout 300000
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand All @@ -247,8 +254,10 @@ jobs:
run: ls -R .
shell: bash
- name: Build TypeScript
working-directory: ./packages/core
run: yarn build:ts
- name: Test bindings
working-directory: ./packages/core
run: yarn test
test-linux-x64-gnu-binding:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
Expand All @@ -272,7 +281,7 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: yarn install
run: corepack enable && yarn install
- name: Download artifacts
uses: actions/download-artifact@v3
with:
Expand All @@ -299,13 +308,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
shell: bash
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: |
corepack enable
yarn config set supportedArchitectures.libc "musl"
yarn install
- name: Download artifacts
Expand Down Expand Up @@ -340,6 +352,7 @@ jobs:
shell: bash
- name: Install dependencies
run: |
corepack enable
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "musl"
yarn install
Expand Down Expand Up @@ -385,6 +398,7 @@ jobs:
shell: bash
- name: Install dependencies
run: |
corepack enable
yarn config set supportedArchitectures.cpu "arm"
yarn install
- name: Build TypeScript
Expand Down Expand Up @@ -435,7 +449,7 @@ jobs:
run: echo "NPM_TAG=nightly" >> $GITHUB_ENV

- name: Install dependencies
run: yarn install
run: corepack enable && yarn install

- name: Download all artifacts
uses: actions/download-artifact@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/publish-extra-bindings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Publish (extra-bindings)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: "${{ github.event_name == 'pull_request' }}"

env:
DEBUG: napi:*
APP_NAME: swc
Expand Down
20 changes: 0 additions & 20 deletions crates/swc/tests/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ fn init_helpers() -> Arc<PathBuf> {
}

let yarn = find_executable("yarn").expect("failed to find yarn");
let npm = find_executable("npm").expect("failed to find npm");
{
let mut cmd = if cfg!(target_os = "windows") {
let mut c = Command::new("cmd");
Expand All @@ -90,25 +89,6 @@ fn init_helpers() -> Arc<PathBuf> {
assert!(status.success());
}

{
let mut cmd = if cfg!(target_os = "windows") {
let mut c = Command::new("cmd");
c.arg("/C").arg(&npm);
c
} else {
Command::new(&npm)
};
cmd.current_dir(&project_root)
.arg("install")
.arg("--no-save")
.arg("--no-package-lock")
.arg("./packages/helpers");
let status = cmd
.status()
.expect("failed to install helper package from root");
assert!(status.success());
}

Arc::new(helper_dir)
});

Expand Down