chore(ci): Expose more crates to JS (#8033)

This commit is contained in:
Donny/강동윤 2023-09-30 05:52:40 +09:00 committed by GitHub
parent 5283e5bf82
commit 186ecfadb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 1999 additions and 64 deletions

83
.github/actions/build-node/action.yml vendored Normal file
View File

@ -0,0 +1,83 @@
name: "Build node.js binding"
description: "Build a binding for node.js by using `settings` matrix"
inputs:
package:
description: "Package name"
required: true
runs:
using: "composite"
steps:
- 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
run: corepack enable
- name: Install node dependencies
shell: bash
working-directory: "./packages/minifier"
run: corepack yarn
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
shell: bash
working-directory: "./packages"
run: |
# curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
echo '/usr/local/cargo/bin' >> $GITHUB_PATH
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
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 &&
${{ matrix.settings.build }}
- name: Build
if: ${{ !matrix.settings.docker }}
run: ${{ matrix.settings.build }}
shell: bash
- run: ls -al ./packages/minifier
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: |
minifier-${{ matrix.settings.target }}
path: |
./packages/minifier/minifier*
if-no-files-found: error

View File

@ -14,17 +14,21 @@ permissions:
id-token: write
on:
push:
branches:
- ci
- ci*
- main
tags:
- v*
workflow_dispatch:
inputs:
package:
type: choice
description: Package name to publish
options:
- minifier
- html
- xml
version:
description: Must be a valid semver version, and should not start with `v`.
required: true
jobs:
build-node:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
strategy:
fail-fast: false
matrix:
@ -32,14 +36,14 @@ jobs:
- host: macos-latest
target: x86_64-apple-darwin
build: |
(cd packages/minifier && corepack yarn build && strip -x *.node)
(cd packages/${{ github.event.inputs.package }} && corepack yarn build && strip -x *.node)
- host: windows-latest
build: |
(cd packages/minifier && yarn build)
(cd packages/${{ github.event.inputs.package }} && yarn build)
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
(cd packages/minifier && corepack yarn build --target i686-pc-windows-msvc)
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target i686-pc-windows-msvc)
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
@ -47,7 +51,7 @@ jobs:
build: >-
set -e &&
unset CC_x86_64_unknown_linux_gnu && unset CC &&
(cd packages/minifier && corepack yarn build --target x86_64-unknown-linux-gnu && strip minifier.linux-x64-gnu.node)
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target x86_64-unknown-linux-gnu && strip ${{ github.event.inputs.package }}.linux-x64-gnu.node)
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
# musl build is slow, let's disable the LTO
@ -55,8 +59,8 @@ jobs:
build: >-
set -e &&
export CARGO_PROFILE_RELEASE_LTO=false &&
(cd packages/minifier && RUSTFLAGS='-C target-feature=+sse2 -C target-feature=-crt-static' corepack yarn build &&
llvm-strip -x minifier.linux-x64-musl.node)
(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)
- host: macos-latest
target: aarch64-apple-darwin
build: |
@ -65,7 +69,7 @@ jobs:
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
(cd packages/minifier && corepack yarn build --target=aarch64-apple-darwin && strip -x *.node)
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target=aarch64-apple-darwin && strip -x *.node)
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
@ -74,8 +78,8 @@ 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/minifier && corepack yarn build --target aarch64-unknown-linux-gnu &&
llvm-strip -x minifier.linux-arm64-gnu.node)
(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: |
@ -83,7 +87,7 @@ jobs:
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/minifier && corepack yarn build --target armv7-unknown-linux-gnueabihf && arm-linux-gnueabihf-strip minifier.linux-arm-gnueabihf.node)
(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)
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
downloadTarget: aarch64-unknown-linux-musl
@ -92,15 +96,15 @@ jobs:
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup toolchain install $(cat ./rust-toolchain) &&
rustup target add aarch64-unknown-linux-musl &&
(cd packages/minifier && env RUSTFLAGS='-C target-feature=-crt-static' corepack yarn build --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip minifier.linux-arm64-musl.node)
(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)
- 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/minifier && corepack yarn build --target aarch64-pc-windows-msvc)
name: stable - ${{ matrix.settings.target }} - node@18
(cd packages/${{ github.event.inputs.package }} && corepack yarn build --target aarch64-pc-windows-msvc)
name: "Build: ${{ matrix.package }} - ${{ matrix.settings.target }}"
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
@ -137,7 +141,7 @@ jobs:
- name: Install node dependencies
shell: bash
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Setup toolchain
@ -164,16 +168,16 @@ jobs:
run: ${{ matrix.settings.build }}
shell: bash
- run: ls -al ./packages/minifier
- run: ls -al ./packages/${{ github.event.inputs.package }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: |
minifier-${{ matrix.settings.target }}
${{ github.event.inputs.package }}-${{ matrix.settings.target }}
path: |
./packages/minifier/minifier*
./packages/${{ github.event.inputs.package }}/${{ github.event.inputs.package }}*
if-no-files-found: error
test-macOS-windows-binding:
@ -199,21 +203,21 @@ jobs:
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: minifier-${{ matrix.settings.target }}
path: "./packages/minifier"
name: ${{ github.event.inputs.package }}-${{ matrix.settings.target }}
path: "./packages/${{ github.event.inputs.package }}"
- name: List packages
run: ls -R ./packages/minifier
run: ls -R ./packages/${{ github.event.inputs.package }}
shell: bash
- name: Build TypeScript
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn build:ts
- name: Test bindings
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn test
test-linux-x64-gnu-binding:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
@ -236,23 +240,23 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: minifier-x86_64-unknown-linux-gnu
path: "./packages/minifier"
name: ${{ github.event.inputs.package }}-x86_64-unknown-linux-gnu
path: "./packages/${{ github.event.inputs.package }}"
- name: List packages
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R .
shell: bash
- name: Build TypeScript
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn build:ts
- name: Test bindings
run: docker run --rm -v $(pwd):/swc -w /swc/packages/minifier node:${{ matrix.node }}-slim env DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test
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
test-linux-x64-musl-binding:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
@ -273,22 +277,22 @@ jobs:
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: minifier-x86_64-unknown-linux-musl
path: "./packages/minifier"
name: ${{ github.event.inputs.package }}-x86_64-unknown-linux-musl
path: "./packages/${{ github.event.inputs.package }}"
- name: List packages
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R .
shell: bash
- name: Build TypeScript
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn build:ts
- name: Test bindings
run: docker run --rm -v $(pwd):/swc -w /swc/packages/minifier node:${{ matrix.node }}-alpine env DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test
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:
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }}
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
@ -300,17 +304,17 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: minifier-aarch64-unknown-linux-musl
path: "./packages/minifier"
name: ${{ github.event.inputs.package }}-aarch64-unknown-linux-musl
path: "./packages/${{ github.event.inputs.package }}"
- name: List packages
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R .
shell: bash
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Build TypeScript
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn build:ts
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
@ -324,7 +328,7 @@ jobs:
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build"
run: >-
set -e &&
(cd "./packages/minifier" && DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test)
(cd "./packages/${{ github.event.inputs.package }}" && DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test)
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 }}
@ -343,17 +347,17 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: minifier-armv7-unknown-linux-gnueabihf
path: "./packages/minifier"
name: ${{ github.event.inputs.package }}-armv7-unknown-linux-gnueabihf
path: "./packages/${{ github.event.inputs.package }}"
- name: List packages
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R .
shell: bash
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Build TypeScript
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn build:ts
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
@ -367,7 +371,7 @@ jobs:
options: "--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build"
run: >-
set -e &&
(cd "./packages/minifier" && DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test &&
(cd "./packages/${{ github.event.inputs.package }}" && DISABLE_PLUGIN_E2E_TESTS=true corepack yarn test &&
ls -la)
publish:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
@ -389,35 +393,35 @@ jobs:
node-version: 18
- name: Set release name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: echo "RELEASE_VERSION=${{ github.event.inputs.package }}@v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Install dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: corepack yarn
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: ./packages/minifier/artifacts
path: ./packages/${{ github.event.inputs.package }}/artifacts
- name: List binaries
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R artifacts
shell: bash
- name: Move binaries
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
shell: bash
run: |
npm run artifacts
- name: List npm
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
run: ls -R ./scripts/npm
shell: bash
- name: Set fallback dependencies
working-directory: "./packages/minifier"
working-directory: "./packages/${{ github.event.inputs.package }}"
shell: bash
run: |
node ./scripts/update_fallback_dependencies.js
@ -426,7 +430,7 @@ jobs:
run: |
npm config set provenance true
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
(cd ./packages/minifier && npm publish --access public)
(cd ./packages/${{ github.event.inputs.package }} && npm publish --access public)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

4
packages/html/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.js
*.d.ts
!binding.js
!binding.d.ts

12
packages/html/.npmignore Normal file
View File

@ -0,0 +1,12 @@
native/target
native/index.node
native/artifacts.json
**/*~
**/node_modules
**/.DS_Store
yarn.lock
package-lock.json
*.log
.idea/
wasm/

View File

@ -0,0 +1,3 @@
# `@swc/html-darwin-arm64`
This is the **aarch64-apple-darwin** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-darwin-arm64",
"version": "1.2.130",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"main": "html.darwin-arm64.node",
"files": [
"html.darwin-arm64.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-darwin-x64`
This is the **x86_64-apple-darwin** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-darwin-x64",
"version": "1.2.130",
"os": [
"darwin"
],
"cpu": [
"x64"
],
"main": "html.darwin-x64.node",
"files": [
"html.darwin-x64.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-linux-arm-gnueabihf`
This is the **armv7-unknown-linux-gnueabihf** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-linux-arm-gnueabihf",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm"
],
"main": "html.linux-arm-gnueabihf.node",
"files": [
"html.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-linux-arm64-gnu`
This is the **aarch64-unknown-linux-gnu** binary for `@swc/html`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/html-linux-arm64-gnu",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "html.linux-arm64-gnu.node",
"files": [
"html.linux-arm64-gnu.node",
"swc"
],
"libc": [
"glibc"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-linux-arm64-musl`
This is the **aarch64-unknown-linux-musl** binary for `@swc/html`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/html-linux-arm64-musl",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "html.linux-arm64-musl.node",
"files": [
"html.linux-arm64-musl.node",
"swc"
],
"libc": [
"musl"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-linux-x64-gnu`
This is the **x86_64-unknown-linux-gnu** binary for `@swc/html`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/html-linux-x64-gnu",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"x64"
],
"main": "html.linux-x64-gnu.node",
"files": [
"html.linux-x64-gnu.node",
"swc"
],
"libc": [
"glibc"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-linux-x64-musl`
This is the **x86_64-unknown-linux-musl** binary for `@swc/html`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/html-linux-x64-musl",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"x64"
],
"main": "html.linux-x64-musl.node",
"files": [
"html.linux-x64-musl.node",
"swc"
],
"libc": [
"musl"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-win32-arm64-msvc`
This is the **aarch64-pc-windows-msvc** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-win32-arm64-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"main": "html.win32-arm64-msvc.node",
"files": [
"html.win32-arm64-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-win32-ia32-msvc`
This is the **i686-pc-windows-msvc** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-win32-ia32-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"ia32"
],
"main": "html.win32-ia32-msvc.node",
"files": [
"html.win32-ia32-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/html-win32-x64-msvc`
This is the **x86_64-pc-windows-msvc** binary for `@swc/html`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/html-win32-x64-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"x64"
],
"main": "html.win32-x64-msvc.node",
"files": [
"html.win32-x64-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,69 @@
{
"name": "@swc-lab/html",
"version": "0.1.0",
"description": "Super-fast alternative for terser",
"homepage": "https://swc.rs",
"main": "./index.js",
"author": "강동윤 <kdy1997.dev@gmail.com>",
"license": "Apache-2.0",
"keywords": [
"swc",
"html"
],
"engines": {
"node": ">=12"
},
"repository": {
"type": "git",
"url": "git+https://github.com/swc-project/swc.git"
},
"bugs": {
"url": "https://github.com/swc-project/swc/issues"
},
"napi": {
"name": "html",
"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"
]
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"types": "./index.d.ts",
"scripts": {
"artifacts": "napi artifacts --dist scripts/npm",
"prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
"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",
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
"version": "napi version -p scripts/npm"
},
"funding": {
"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",
"@types/node": "^20.7.1",
"cross-env": "^7.0.3",
"typescript": "^5.2.2"
}
}

18
packages/html/src/binding.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
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
}

View File

@ -0,0 +1,260 @@
/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
const { join } = require('path')
const { platform, arch } = process
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) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
}
switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'html.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./html.android-arm64.node')
} else {
nativeBinding = require('@swc/html-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'html.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./html.android-arm-eabi.node')
} else {
nativeBinding = require('@swc/html-android-arm-eabi')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'html.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.win32-x64-msvc.node')
} else {
nativeBinding = require('@swc/html-win32-x64-msvc')
}
} catch (e) {
loadError = e
}
break
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'html.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.win32-ia32-msvc.node')
} else {
nativeBinding = require('@swc/html-win32-ia32-msvc')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'html.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.win32-arm64-msvc.node')
} else {
nativeBinding = require('@swc/html-win32-arm64-msvc')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'html.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./html.darwin-universal.node')
} else {
nativeBinding = require('@swc/html-darwin-universal')
}
break
} catch { }
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'html.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./html.darwin-x64.node')
} else {
nativeBinding = require('@swc/html-darwin-x64')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'html.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.darwin-arm64.node')
} else {
nativeBinding = require('@swc/html-darwin-arm64')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'html.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./html.freebsd-x64.node')
} else {
nativeBinding = require('@swc/html-freebsd-x64')
}
} catch (e) {
loadError = e
}
break
case 'linux':
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'html.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.linux-x64-musl.node')
} else {
nativeBinding = require('@swc/html-linux-x64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'html.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.linux-x64-gnu.node')
} else {
nativeBinding = require('@swc/html-linux-x64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'html.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.linux-arm64-musl.node')
} else {
nativeBinding = require('@swc/html-linux-arm64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'html.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.linux-arm64-gnu.node')
} else {
nativeBinding = require('@swc/html-linux-arm64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'html.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./html.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@swc/html-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
if (!nativeBinding) {
if (loadError) {
throw loadError
}
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

View File

@ -0,0 +1,23 @@
import { JsMinifyOptions } from '@swc/types';
import * as binding from './binding'
/**
* TODO
*/
export async function minify(code: Buffer, options: JsMinifyOptions) {
return await binding.minify(code, toBuffer(options))
}
/**
* TODO
*/
export function minifySync(code: Buffer, options: JsMinifyOptions): binding.TransformOutput {
return binding.minifySync(code, toBuffer(options))
}
function toBuffer(t: any): Buffer {
return Buffer.from(JSON.stringify(t))
}

View File

@ -0,0 +1,63 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": false /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
"removeComments": false /* Do not emit comments to output. */,
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
"tsBuildInfoFile": ".tsbuildinfo"
},
"include": [
"src/"
],
"exclude": [
"*.js"
]
}

4
packages/xml/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.js
*.d.ts
!binding.js
!binding.d.ts

12
packages/xml/.npmignore Normal file
View File

@ -0,0 +1,12 @@
native/target
native/index.node
native/artifacts.json
**/*~
**/node_modules
**/.DS_Store
yarn.lock
package-lock.json
*.log
.idea/
wasm/

View File

@ -0,0 +1,3 @@
# `@swc/xml-darwin-arm64`
This is the **aarch64-apple-darwin** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-darwin-arm64",
"version": "1.2.130",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"main": "xml.darwin-arm64.node",
"files": [
"xml.darwin-arm64.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-darwin-x64`
This is the **x86_64-apple-darwin** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-darwin-x64",
"version": "1.2.130",
"os": [
"darwin"
],
"cpu": [
"x64"
],
"main": "xml.darwin-x64.node",
"files": [
"xml.darwin-x64.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-linux-arm-gnueabihf`
This is the **armv7-unknown-linux-gnueabihf** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-linux-arm-gnueabihf",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm"
],
"main": "xml.linux-arm-gnueabihf.node",
"files": [
"xml.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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-linux-arm64-gnu`
This is the **aarch64-unknown-linux-gnu** binary for `@swc/xml`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/xml-linux-arm64-gnu",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "xml.linux-arm64-gnu.node",
"files": [
"xml.linux-arm64-gnu.node",
"swc"
],
"libc": [
"glibc"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-linux-arm64-musl`
This is the **aarch64-unknown-linux-musl** binary for `@swc/xml`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/xml-linux-arm64-musl",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "xml.linux-arm64-musl.node",
"files": [
"xml.linux-arm64-musl.node",
"swc"
],
"libc": [
"musl"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-linux-x64-gnu`
This is the **x86_64-unknown-linux-gnu** binary for `@swc/xml`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/xml-linux-x64-gnu",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"x64"
],
"main": "xml.linux-x64-gnu.node",
"files": [
"xml.linux-x64-gnu.node",
"swc"
],
"libc": [
"glibc"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-linux-x64-musl`
This is the **x86_64-unknown-linux-musl** binary for `@swc/xml`

View File

@ -0,0 +1,45 @@
{
"name": "@swc/xml-linux-x64-musl",
"version": "1.2.130",
"os": [
"linux"
],
"cpu": [
"x64"
],
"main": "xml.linux-x64-musl.node",
"files": [
"xml.linux-x64-musl.node",
"swc"
],
"libc": [
"musl"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-win32-arm64-msvc`
This is the **aarch64-pc-windows-msvc** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-win32-arm64-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"main": "xml.win32-arm64-msvc.node",
"files": [
"xml.win32-arm64-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-win32-ia32-msvc`
This is the **i686-pc-windows-msvc** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-win32-ia32-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"ia32"
],
"main": "xml.win32-ia32-msvc.node",
"files": [
"xml.win32-ia32-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

View File

@ -0,0 +1,3 @@
# `@swc/xml-win32-x64-msvc`
This is the **x86_64-pc-windows-msvc** binary for `@swc/xml`

View File

@ -0,0 +1,42 @@
{
"name": "@swc/xml-win32-x64-msvc",
"version": "1.2.130",
"os": [
"win32"
],
"cpu": [
"x64"
],
"main": "xml.win32-x64-msvc.node",
"files": [
"xml.win32-x64-msvc.node",
"swc.exe"
],
"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 AND MIT",
"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"
}
}

69
packages/xml/package.json Normal file
View File

@ -0,0 +1,69 @@
{
"name": "@swc-lab/xml",
"version": "0.1.0",
"description": "Super-fast alternative for terser",
"homepage": "https://swc.rs",
"main": "./index.js",
"author": "강동윤 <kdy1997.dev@gmail.com>",
"license": "Apache-2.0",
"keywords": [
"swc",
"xml"
],
"engines": {
"node": ">=12"
},
"repository": {
"type": "git",
"url": "git+https://github.com/swc-project/swc.git"
},
"bugs": {
"url": "https://github.com/swc-project/swc/issues"
},
"napi": {
"name": "xml",
"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"
]
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"types": "./index.d.ts",
"scripts": {
"artifacts": "napi artifacts --dist scripts/npm",
"prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
"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",
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
"version": "napi version -p scripts/npm"
},
"funding": {
"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",
"@types/node": "^20.7.1",
"cross-env": "^7.0.3",
"typescript": "^5.2.2"
}
}

18
packages/xml/src/binding.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
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
}

260
packages/xml/src/binding.js Normal file
View File

@ -0,0 +1,260 @@
/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
const { join } = require('path')
const { platform, arch } = process
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) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
}
switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'xml.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./xml.android-arm64.node')
} else {
nativeBinding = require('@swc/xml-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'xml.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./xml.android-arm-eabi.node')
} else {
nativeBinding = require('@swc/xml-android-arm-eabi')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'xml.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.win32-x64-msvc.node')
} else {
nativeBinding = require('@swc/xml-win32-x64-msvc')
}
} catch (e) {
loadError = e
}
break
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'xml.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.win32-ia32-msvc.node')
} else {
nativeBinding = require('@swc/xml-win32-ia32-msvc')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'xml.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.win32-arm64-msvc.node')
} else {
nativeBinding = require('@swc/xml-win32-arm64-msvc')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'xml.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./xml.darwin-universal.node')
} else {
nativeBinding = require('@swc/xml-darwin-universal')
}
break
} catch { }
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'xml.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./xml.darwin-x64.node')
} else {
nativeBinding = require('@swc/xml-darwin-x64')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'xml.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.darwin-arm64.node')
} else {
nativeBinding = require('@swc/xml-darwin-arm64')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'xml.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./xml.freebsd-x64.node')
} else {
nativeBinding = require('@swc/xml-freebsd-x64')
}
} catch (e) {
loadError = e
}
break
case 'linux':
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'xml.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.linux-x64-musl.node')
} else {
nativeBinding = require('@swc/xml-linux-x64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'xml.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.linux-x64-gnu.node')
} else {
nativeBinding = require('@swc/xml-linux-x64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'xml.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.linux-arm64-musl.node')
} else {
nativeBinding = require('@swc/xml-linux-arm64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'xml.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.linux-arm64-gnu.node')
} else {
nativeBinding = require('@swc/xml-linux-arm64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'xml.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./xml.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@swc/xml-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
if (!nativeBinding) {
if (loadError) {
throw loadError
}
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

23
packages/xml/src/index.ts Normal file
View File

@ -0,0 +1,23 @@
import { JsMinifyOptions } from '@swc/types';
import * as binding from './binding'
/**
* TODO
*/
export async function minify(code: Buffer, options: JsMinifyOptions) {
return await binding.minify(code, toBuffer(options))
}
/**
* TODO
*/
export function minifySync(code: Buffer, options: JsMinifyOptions): binding.TransformOutput {
return binding.minifySync(code, toBuffer(options))
}
function toBuffer(t: any): Buffer {
return Buffer.from(JSON.stringify(t))
}

View File

@ -0,0 +1,63 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": false /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
"removeComments": false /* Do not emit comments to output. */,
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
"tsBuildInfoFile": ".tsbuildinfo"
},
"include": [
"src/"
],
"exclude": [
"*.js"
]
}

View File

@ -135,6 +135,19 @@ __metadata:
languageName: unknown
linkType: soft
"@swc/html@workspace:html":
version: 0.0.0-use.local
resolution: "@swc/html@workspace:html"
dependencies:
"@napi-rs/cli": ^2.16.3
"@swc/counter": ^0.1.1
"@swc/types": "workspace:^"
"@types/node": ^20.7.1
cross-env: ^7.0.3
typescript: ^5.2.2
languageName: unknown
linkType: soft
"@swc/minifier@workspace:minifier":
version: 0.0.0-use.local
resolution: "@swc/minifier@workspace:minifier"
@ -164,6 +177,19 @@ __metadata:
languageName: unknown
linkType: soft
"@swc/xml@workspace:xml":
version: 0.0.0-use.local
resolution: "@swc/xml@workspace:xml"
dependencies:
"@napi-rs/cli": ^2.16.3
"@swc/counter": ^0.1.1
"@swc/types": "workspace:^"
"@types/node": ^20.7.1
cross-env: ^7.0.3
typescript: ^5.2.2
languageName: unknown
linkType: soft
"@types/fs-extra@npm:^11.0.1":
version: 11.0.1
resolution: "@types/fs-extra@npm:11.0.1"
@ -748,7 +774,7 @@ __metadata:
"typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=85af82"
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=a1c5e5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver