Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
1bc9b1ac
Unverified
Commit
1bc9b1ac
authored
Nov 24, 2021
by
Maia Teegarden
Committed by
GitHub
Nov 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wasm loading (#31772)
* Fix wasm loading * Remove consoles
parent
719fe529
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
246 additions
and
144 deletions
+246
-144
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+19
-19
pull_request_stats.yml
.github/workflows/pull_request_stats.yml
+2
-2
Cargo.lock
packages/next-swc/Cargo.lock
+120
-33
Cargo.toml
packages/next-swc/crates/core/Cargo.toml
+3
-3
lib.rs
packages/next-swc/crates/core/src/lib.rs
+1
-1
full.rs
packages/next-swc/crates/core/tests/full.rs
+1
-1
Cargo.toml
packages/next-swc/crates/napi/Cargo.toml
+2
-2
Cargo.toml
packages/next-swc/crates/wasm/Cargo.toml
+2
-2
rust-toolchain
packages/next-swc/rust-toolchain
+1
-1
index.js
packages/next/build/swc/index.js
+95
-80
No files found.
.github/workflows/build_test_deploy.yml
View file @
1bc9b1ac
...
@@ -570,7 +570,7 @@ jobs:
...
@@ -570,7 +570,7 @@ jobs:
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
-
name
:
Cache cargo registry
-
name
:
Cache cargo registry
uses
:
actions/cache@v1
uses
:
actions/cache@v1
...
@@ -592,7 +592,7 @@ jobs:
...
@@ -592,7 +592,7 @@ jobs:
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-x64-gnu.node
path
:
packages/next-swc/native/next-swc.linux-x64-gnu.node
key
:
dev-next-swc-nightly-2021-
08-12
-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
dev-next-swc-nightly-2021-
11-15
-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
# We use restore-key to pick latest cache.
# We use restore-key to pick latest cache.
# We will not get exact match, but doc says
# We will not get exact match, but doc says
...
@@ -643,7 +643,7 @@ jobs:
...
@@ -643,7 +643,7 @@ jobs:
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
profile
:
minimal
profile
:
minimal
-
run
:
cd packages/next-swc && cargo test
-
run
:
cd packages/next-swc && cargo test
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
...
@@ -704,7 +704,7 @@ jobs:
...
@@ -704,7 +704,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
target
:
${{ matrix.target }}
target
:
${{ matrix.target }}
-
name
:
Cache cargo registry
-
name
:
Cache cargo registry
...
@@ -724,7 +724,7 @@ jobs:
...
@@ -724,7 +724,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.${{ matrix.name }}.node
path
:
packages/next-swc/native/next-swc.${{ matrix.name }}.node
key
:
next-swc-nightly-2021-
08-12
-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Cross build aarch64 setup
-
name
:
Cross build aarch64 setup
if
:
${{ matrix.target == 'aarch64-apple-darwin' }}
if
:
${{ matrix.target == 'aarch64-apple-darwin' }}
...
@@ -798,7 +798,7 @@ jobs:
...
@@ -798,7 +798,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
i686-pc-windows-msvc
target
:
i686-pc-windows-msvc
...
@@ -807,7 +807,7 @@ jobs:
...
@@ -807,7 +807,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.win32-ia32-msvc.node
path
:
packages/next-swc/native/next-swc.win32-ia32-msvc.node
key
:
next-swc-nightly-2021-
08-12
-win32-ia32-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-win32-ia32-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Build
-
name
:
Build
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -844,7 +844,7 @@ jobs:
...
@@ -844,7 +844,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
aarch64-pc-windows-msvc
target
:
aarch64-pc-windows-msvc
...
@@ -853,7 +853,7 @@ jobs:
...
@@ -853,7 +853,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.win32-arm64-msvc.node
path
:
packages/next-swc/native/next-swc.win32-arm64-msvc.node
key
:
next-swc-nightly-2021-
08-12
-win32-arm64-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-win32-arm64-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Build
-
name
:
Build
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -902,7 +902,7 @@ jobs:
...
@@ -902,7 +902,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-x64-musl.node
path
:
packages/next-swc/native/next-swc.linux-x64-musl.node
key
:
next-swc-nightly-2021-
08-12
-linux-x64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-linux-x64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
'
Build'
-
name
:
'
Build'
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -940,7 +940,7 @@ jobs:
...
@@ -940,7 +940,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
aarch64-unknown-linux-gnu
target
:
aarch64-unknown-linux-gnu
...
@@ -961,7 +961,7 @@ jobs:
...
@@ -961,7 +961,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-arm64-gnu.node
path
:
packages/next-swc/native/next-swc.linux-arm64-gnu.node
key
:
next-swc-nightly-2021-
08-12
-linux-arm64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-linux-arm64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Cross build aarch64
-
name
:
Cross build aarch64
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -997,7 +997,7 @@ jobs:
...
@@ -997,7 +997,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
aarch64-unknown-linux-musl
target
:
aarch64-unknown-linux-musl
...
@@ -1018,7 +1018,7 @@ jobs:
...
@@ -1018,7 +1018,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-arm64-musl.node
path
:
packages/next-swc/native/next-swc.linux-arm64-musl.node
key
:
next-swc-nightly-2021-
08-12
-linux-arm64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-linux-arm64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Cross build aarch64
-
name
:
Cross build aarch64
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -1056,7 +1056,7 @@ jobs:
...
@@ -1056,7 +1056,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
armv7-unknown-linux-gnueabihf
target
:
armv7-unknown-linux-gnueabihf
...
@@ -1077,7 +1077,7 @@ jobs:
...
@@ -1077,7 +1077,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-arm-gnueabihf.node
path
:
packages/next-swc/native/next-swc.linux-arm-gnueabihf.node
key
:
next-swc-nightly-2021-
08-12
-linux-arm-gnueabihf-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-linux-arm-gnueabihf-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Cross build aarch64
-
name
:
Cross build aarch64
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -1113,7 +1113,7 @@ jobs:
...
@@ -1113,7 +1113,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
aarch64-linux-android
target
:
aarch64-linux-android
...
@@ -1122,7 +1122,7 @@ jobs:
...
@@ -1122,7 +1122,7 @@ jobs:
uses
:
actions/cache@v2
uses
:
actions/cache@v2
with
:
with
:
path
:
packages/next-swc/native/next-swc.android-arm64.node
path
:
packages/next-swc/native/next-swc.android-arm64.node
key
:
next-swc-nightly-2021-
08-12
-android-arm64-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
next-swc-nightly-2021-
11-15
-android-arm64-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
-
name
:
Build
-
name
:
Build
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
if
:
${{ steps.binary-cache.outputs.cache-hit != 'true' }}
...
@@ -1161,7 +1161,7 @@ jobs:
...
@@ -1161,7 +1161,7 @@ jobs:
uses
:
actions-rs/toolchain@v1
uses
:
actions-rs/toolchain@v1
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
override
:
true
override
:
true
target
:
wasm32-unknown-unknown
target
:
wasm32-unknown-unknown
...
...
.github/workflows/pull_request_stats.yml
View file @
1bc9b1ac
...
@@ -32,7 +32,7 @@ jobs:
...
@@ -32,7 +32,7 @@ jobs:
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with
:
with
:
profile
:
minimal
profile
:
minimal
toolchain
:
nightly-2021-
08-12
toolchain
:
nightly-2021-
11-15
-
name
:
Cache cargo registry
-
name
:
Cache cargo registry
uses
:
actions/cache@v1
uses
:
actions/cache@v1
...
@@ -54,7 +54,7 @@ jobs:
...
@@ -54,7 +54,7 @@ jobs:
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with
:
with
:
path
:
packages/next-swc/native/next-swc.linux-x64-gnu.node
path
:
packages/next-swc/native/next-swc.linux-x64-gnu.node
key
:
dev-next-swc-nightly-2021-
08-12
-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
key
:
dev-next-swc-nightly-2021-
11-15
-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }}
# We use restore-key to pick latest cache.
# We use restore-key to pick latest cache.
# We will not get exact match, but doc says
# We will not get exact match, but doc says
...
...
packages/next-swc/Cargo.lock
View file @
1bc9b1ac
...
@@ -171,6 +171,24 @@ dependencies = [
...
@@ -171,6 +171,24 @@ dependencies = [
"generic-array",
"generic-array",
]
]
[[package]]
name = "browserslist-rs"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa428c5a7369965603314e5fbfa5ae1755159bce2c35880d80ea84a866213b20"
dependencies = [
"chrono",
"itertools",
"js-sys",
"once_cell",
"regex",
"serde",
"serde-wasm-bindgen",
"serde_json",
"thiserror",
"wasm-bindgen",
]
[[package]]
[[package]]
name = "build_const"
name = "build_const"
version = "0.2.2"
version = "0.2.2"
...
@@ -213,10 +231,12 @@ version = "0.4.19"
...
@@ -213,10 +231,12 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
dependencies = [
"js-sys",
"libc",
"libc",
"num-integer",
"num-integer",
"num-traits",
"num-traits",
"time",
"time",
"wasm-bindgen",
"winapi",
"winapi",
]
]
...
@@ -590,6 +610,15 @@ dependencies = [
...
@@ -590,6 +610,15 @@ dependencies = [
"syn",
"syn",
]
]
[[package]]
name = "itertools"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
dependencies = [
"either",
]
[[package]]
[[package]]
name = "itoa"
name = "itoa"
version = "0.4.8"
version = "0.4.8"
...
@@ -803,7 +832,7 @@ dependencies = [
...
@@ -803,7 +832,7 @@ dependencies = [
"swc_ecma_loader",
"swc_ecma_loader",
"swc_ecma_preset_env",
"swc_ecma_preset_env",
"swc_ecma_transforms_testing",
"swc_ecma_transforms_testing",
"swc_ecmascript",
"swc_ecmascript
0.88.1
",
"swc_node_base",
"swc_node_base",
"swc_stylis",
"swc_stylis",
"testing",
"testing",
...
@@ -830,7 +859,7 @@ dependencies = [
...
@@ -830,7 +859,7 @@ dependencies = [
"swc_bundler",
"swc_bundler",
"swc_common",
"swc_common",
"swc_ecma_loader",
"swc_ecma_loader",
"swc_ecmascript",
"swc_ecmascript
0.88.1
",
"swc_node_base",
"swc_node_base",
]
]
...
@@ -1520,6 +1549,18 @@ dependencies = [
...
@@ -1520,6 +1549,18 @@ dependencies = [
"serde_derive",
"serde_derive",
]
]
[[package]]
name = "serde-wasm-bindgen"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "618365e8e586c22123d692b72a7d791d5ee697817b65a218cdf12a98870af0f7"
dependencies = [
"fnv",
"js-sys",
"serde",
"wasm-bindgen",
]
[[package]]
[[package]]
name = "serde_derive"
name = "serde_derive"
version = "1.0.130"
version = "1.0.130"
...
@@ -1702,15 +1743,15 @@ dependencies = [
...
@@ -1702,15 +1743,15 @@ dependencies = [
"serde",
"serde",
"swc_atoms",
"swc_atoms",
"swc_common",
"swc_common",
"swc_ecmascript",
"swc_ecmascript
0.87.0
",
"tracing",
"tracing",
]
]
[[package]]
[[package]]
name = "swc"
name = "swc"
version = "0.8
5.0
"
version = "0.8
7.1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
fe58bc90f561ccca81f4e8098c4387252c7c19d1673ecdfa0986a60446162848
"
checksum = "
b5c9ae049ceaf2e35296ab947aee725454ca2f80b80049deb74d4d0387a320fe
"
dependencies = [
dependencies = [
"ahash",
"ahash",
"anyhow",
"anyhow",
...
@@ -1740,7 +1781,8 @@ dependencies = [
...
@@ -1740,7 +1781,8 @@ dependencies = [
"swc_ecma_transforms_optimization",
"swc_ecma_transforms_optimization",
"swc_ecma_utils",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_ecma_visit",
"swc_ecmascript",
"swc_ecmascript 0.88.1",
"swc_node_comments",
"swc_visit",
"swc_visit",
"tracing",
"tracing",
]
]
...
@@ -1957,9 +1999,9 @@ dependencies = [
...
@@ -1957,9 +1999,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_ext_transforms"
name = "swc_ecma_ext_transforms"
version = "0.38.
0
"
version = "0.38.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
8e98c2e40c3b106c89d87a107b1af561a171c9f819ab3e1dd101fe6d129b67e2
"
checksum = "
74246f8ffabdb1272e94043ed7446b65b1964e95a07111406d7d6cd68588abd3
"
dependencies = [
dependencies = [
"phf",
"phf",
"swc_atoms",
"swc_atoms",
...
@@ -1993,9 +2035,9 @@ dependencies = [
...
@@ -1993,9 +2035,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_minifier"
name = "swc_ecma_minifier"
version = "0.51.
1
"
version = "0.51.
3
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
3403abf2d19dc33ba72f8aed71b1ebfd5ae55a03149e8fa7b73b8c054b17571b
"
checksum = "
819dd9de73580b79c015eeb91ccc07745c7cdb55304afaab38639d224e15bcef
"
dependencies = [
dependencies = [
"ahash",
"ahash",
"indexmap",
"indexmap",
...
@@ -2042,11 +2084,13 @@ dependencies = [
...
@@ -2042,11 +2084,13 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_preset_env"
name = "swc_ecma_preset_env"
version = "0.6
6.0
"
version = "0.6
7.1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
5ebfebde76a89d4ee64c76bb511bf5c924c366912b4611ec09483d580892eaa
1"
checksum = "
df02dc414b3b851f5ab5cde057414aa828ce640004900ca649ea9219e316552
1"
dependencies = [
dependencies = [
"ahash",
"ahash",
"anyhow",
"browserslist-rs",
"dashmap",
"dashmap",
"indexmap",
"indexmap",
"once_cell",
"once_cell",
...
@@ -2066,9 +2110,9 @@ dependencies = [
...
@@ -2066,9 +2110,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms"
name = "swc_ecma_transforms"
version = "0.95.
0
"
version = "0.95.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
05b0a841f223cea0c5832a5431cd7b71a5c3ecfd81259608016e92479f359542
"
checksum = "
c011f89eef93ee994e0c7181e0816b6623f860182228a607cab11e3d9c958d51
"
dependencies = [
dependencies = [
"swc_atoms",
"swc_atoms",
"swc_common",
"swc_common",
...
@@ -2088,9 +2132,9 @@ dependencies = [
...
@@ -2088,9 +2132,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_base"
name = "swc_ecma_transforms_base"
version = "0.44.
0
"
version = "0.44.
3
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
9d9d453fc5025563ea75c2a40154cef06583d44e41df22284286719c4f1c52b4
"
checksum = "
18e0f787be734204a739fb774d0c00b15dcf0f8a3040f993ac18f6b8e47cc50e
"
dependencies = [
dependencies = [
"once_cell",
"once_cell",
"phf",
"phf",
...
@@ -2108,9 +2152,9 @@ dependencies = [
...
@@ -2108,9 +2152,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_classes"
name = "swc_ecma_transforms_classes"
version = "0.30.
1
"
version = "0.30.
2
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
709296c35b892ad9973789f27ec522afb92e790d5db7f6378c7ef669616b8288
"
checksum = "
59d4aa36016acc3da3f42036f5c6fdab84b0e6200a49b84280dd852bbae256a3
"
dependencies = [
dependencies = [
"swc_atoms",
"swc_atoms",
"swc_common",
"swc_common",
...
@@ -2122,9 +2166,9 @@ dependencies = [
...
@@ -2122,9 +2166,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_compat"
name = "swc_ecma_transforms_compat"
version = "0.52.
9
"
version = "0.52.
11
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7
04f6bf26236ddc569c553b00057832925fc8f741521f578b24f716808a68b19
"
checksum = "7
3d6517ee2704012512597db5b5a9d14689457aaae961b2efb03d8c47935cb55
"
dependencies = [
dependencies = [
"ahash",
"ahash",
"arrayvec",
"arrayvec",
...
@@ -2159,9 +2203,9 @@ dependencies = [
...
@@ -2159,9 +2203,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_module"
name = "swc_ecma_transforms_module"
version = "0.58.
0
"
version = "0.58.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
e2caeabc77971a09246634ce954450b7088645eba46d98461cfa580533e01af5
"
checksum = "
47d1658854475530d0e258c527b2226e94563dadf06c6bdf692c69153ffda583
"
dependencies = [
dependencies = [
"Inflector",
"Inflector",
"ahash",
"ahash",
...
@@ -2181,9 +2225,9 @@ dependencies = [
...
@@ -2181,9 +2225,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_optimization"
name = "swc_ecma_transforms_optimization"
version = "0.65.
0
"
version = "0.65.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
0fceea7548e8dd9bfea423d4ebbe6a444696fd0a7c1e19be7685bdb93d0a16f9
"
checksum = "
bcd8f861cef30f9b3bd262828249cd32df4bbe5000d250fe63de2888d79ff08f
"
dependencies = [
dependencies = [
"ahash",
"ahash",
"dashmap",
"dashmap",
...
@@ -2205,9 +2249,9 @@ dependencies = [
...
@@ -2205,9 +2249,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_proposal"
name = "swc_ecma_transforms_proposal"
version = "0.58.
0
"
version = "0.58.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
265ed86ce755fe0506ac95b457de609c3d06151fa9bac4da1bbf4d139d8439c5
"
checksum = "
954e89a6b90b36719530624b9607fe62f783e04b7f368d526ac0038e9d646faa
"
dependencies = [
dependencies = [
"either",
"either",
"serde",
"serde",
...
@@ -2225,9 +2269,9 @@ dependencies = [
...
@@ -2225,9 +2269,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_react"
name = "swc_ecma_transforms_react"
version = "0.60.
0
"
version = "0.60.
1
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
83095530b047a35e98395abc6fe6aa00a1a76b7d54d36d563bdc9c4239bb78fd
"
checksum = "
380dc7c6617b4866f295baf4c41a0e64f5c265a734ac457008723fca18235765
"
dependencies = [
dependencies = [
"ahash",
"ahash",
"base64 0.13.0",
"base64 0.13.0",
...
@@ -2273,9 +2317,9 @@ dependencies = [
...
@@ -2273,9 +2317,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_transforms_typescript"
name = "swc_ecma_transforms_typescript"
version = "0.61.
0
"
version = "0.61.
2
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
64681fa9ed7c5b6bbce3be142ab25ca089aaf86c7ae14403fbf7845d77a28281
"
checksum = "
92de92acef99e2e3cbd38eb0d864d46dbae66d45eb04cb64792d2aec5e8cf622
"
dependencies = [
dependencies = [
"serde",
"serde",
"swc_atoms",
"swc_atoms",
...
@@ -2290,9 +2334,9 @@ dependencies = [
...
@@ -2290,9 +2334,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_utils"
name = "swc_ecma_utils"
version = "0.52.
0
"
version = "0.52.
3
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
bc871840407f0303e0b93e0a2517d885892e1da8a11a0e344ca06b70b4ecd68f
"
checksum = "
74224ff2ec4e4cc94e11303e4f6a87e13f5b00d92b273ee5821e116e8df7992b
"
dependencies = [
dependencies = [
"once_cell",
"once_cell",
"rayon",
"rayon",
...
@@ -2321,6 +2365,18 @@ name = "swc_ecmascript"
...
@@ -2321,6 +2365,18 @@ name = "swc_ecmascript"
version = "0.87.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e766b0ce800f14c983fdeb2d6fb81880e341321841afd4ad1469d9f2ac79ecd"
checksum = "9e766b0ce800f14c983fdeb2d6fb81880e341321841afd4ad1469d9f2ac79ecd"
dependencies = [
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_utils",
"swc_ecma_visit",
]
[[package]]
name = "swc_ecmascript"
version = "0.88.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee4ef782d87d479ffdc3283575703a332d2cf9f3ac9b141beba08ad15f717048"
dependencies = [
dependencies = [
"swc_ecma_ast",
"swc_ecma_ast",
"swc_ecma_codegen",
"swc_ecma_codegen",
...
@@ -2389,6 +2445,17 @@ dependencies = [
...
@@ -2389,6 +2445,17 @@ dependencies = [
"mimalloc-rust",
"mimalloc-rust",
]
]
[[package]]
name = "swc_node_comments"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52fd186eff1e6fd5639966b1caf460e13141ddf9d956f0bbfe8ec7b83730d3ff"
dependencies = [
"ahash",
"dashmap",
"swc_common",
]
[[package]]
[[package]]
name = "swc_stylis"
name = "swc_stylis"
version = "0.28.0"
version = "0.28.0"
...
@@ -2493,6 +2560,26 @@ dependencies = [
...
@@ -2493,6 +2560,26 @@ dependencies = [
"syn",
"syn",
]
]
[[package]]
name = "thiserror"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
[[package]]
name = "thread_local"
name = "thread_local"
version = "1.1.3"
version = "1.1.3"
...
@@ -2696,7 +2783,7 @@ dependencies = [
...
@@ -2696,7 +2783,7 @@ dependencies = [
"serde_json",
"serde_json",
"swc",
"swc",
"swc_common",
"swc_common",
"swc_ecmascript",
"swc_ecmascript
0.88.1
",
"tracing",
"tracing",
"wasm-bindgen",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-futures",
...
...
packages/next-swc/crates/core/Cargo.toml
View file @
1bc9b1ac
...
@@ -15,13 +15,13 @@ pathdiff = "0.2.0"
...
@@ -15,13 +15,13 @@ pathdiff = "0.2.0"
serde
=
"1"
serde
=
"1"
serde_json
=
"1"
serde_json
=
"1"
styled_components
=
"0.2.0"
styled_components
=
"0.2.0"
swc
=
"0.8
5
.0"
swc
=
"0.8
7
.0"
swc_atoms
=
"0.2.7"
swc_atoms
=
"0.2.7"
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_css
=
"0.31.0"
swc_css
=
"0.31.0"
swc_ecma_loader
=
{
version
=
"0.24.2"
,
features
=
[
"node"
,
"lru"
]
}
swc_ecma_loader
=
{
version
=
"0.24.2"
,
features
=
[
"node"
,
"lru"
]
}
swc_ecma_preset_env
=
"0.6
6
.0"
swc_ecma_preset_env
=
"0.6
7
.0"
swc_ecmascript
=
{
version
=
"0.8
7.0
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
swc_ecmascript
=
{
version
=
"0.8
8.1
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
swc_node_base
=
"0.5.1"
swc_node_base
=
"0.5.1"
swc_stylis
=
"0.28.0"
swc_stylis
=
"0.28.0"
tracing
=
{version
=
"0.1.28"
,
features
=
["release_max_level_off"]
}
tracing
=
{version
=
"0.1.28"
,
features
=
["release_max_level_off"]
}
...
...
packages/next-swc/crates/core/src/lib.rs
View file @
1bc9b1ac
...
@@ -46,8 +46,8 @@ use swc_ecmascript::{
...
@@ -46,8 +46,8 @@ use swc_ecmascript::{
};
};
pub
mod
amp_attributes
;
pub
mod
amp_attributes
;
pub
mod
disallow_re_export_all_in_page
;
mod
auto_cjs
;
mod
auto_cjs
;
pub
mod
disallow_re_export_all_in_page
;
pub
mod
hook_optimizer
;
pub
mod
hook_optimizer
;
pub
mod
next_dynamic
;
pub
mod
next_dynamic
;
pub
mod
next_ssg
;
pub
mod
next_ssg
;
...
...
packages/next-swc/crates/core/tests/full.rs
View file @
1bc9b1ac
...
@@ -30,7 +30,7 @@ fn test(input: &Path, minify: bool) {
...
@@ -30,7 +30,7 @@ fn test(input: &Path, minify: bool) {
let
options
=
TransformOptions
{
let
options
=
TransformOptions
{
swc
:
swc
::
config
::
Options
{
swc
:
swc
::
config
::
Options
{
swcrc
:
true
,
swcrc
:
true
,
is_module
:
true
,
is_module
:
swc
::
config
::
IsModule
::
Bool
(
true
)
,
output_path
:
Some
(
output
.to_path_buf
()),
output_path
:
Some
(
output
.to_path_buf
()),
config
:
swc
::
config
::
Config
{
config
:
swc
::
config
::
Config
{
...
...
packages/next-swc/crates/napi/Cargo.toml
View file @
1bc9b1ac
...
@@ -16,12 +16,12 @@ once_cell = "1.8.0"
...
@@ -16,12 +16,12 @@ once_cell = "1.8.0"
serde
=
"1"
serde
=
"1"
serde_json
=
"1"
serde_json
=
"1"
next-swc
=
{
version
=
"0.0.0"
,
path
=
"../core"
}
next-swc
=
{
version
=
"0.0.0"
,
path
=
"../core"
}
swc
=
"0.8
5
.0"
swc
=
"0.8
7
.0"
swc_atoms
=
"0.2.7"
swc_atoms
=
"0.2.7"
swc_bundler
=
{
version
=
"0.82.0"
,
features
=
["concurrent"]
}
swc_bundler
=
{
version
=
"0.82.0"
,
features
=
["concurrent"]
}
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_ecma_loader
=
{
version
=
"0.24.2"
,
features
=
[
"node"
,
"lru"
]
}
swc_ecma_loader
=
{
version
=
"0.24.2"
,
features
=
[
"node"
,
"lru"
]
}
swc_ecmascript
=
{
version
=
"0.8
7.0
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
swc_ecmascript
=
{
version
=
"0.8
8.1
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
swc_node_base
=
"0.5.1"
swc_node_base
=
"0.5.1"
[build-dependencies]
[build-dependencies]
...
...
packages/next-swc/crates/wasm/Cargo.toml
View file @
1bc9b1ac
...
@@ -16,9 +16,9 @@ path-clean = "0.1"
...
@@ -16,9 +16,9 @@ path-clean = "0.1"
serde
=
{version
=
"1"
,
features
=
["derive"]
}
serde
=
{version
=
"1"
,
features
=
["derive"]
}
serde_json
=
"1"
serde_json
=
"1"
next-swc
=
{
version
=
"0.0.0"
,
path
=
"../core"
}
next-swc
=
{
version
=
"0.0.0"
,
path
=
"../core"
}
swc
=
"0.8
5
.0"
swc
=
"0.8
7
.0"
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_common
=
{version
=
"0.14.2"
,
features
=
[
"concurrent"
,
"sourcemap"
]
}
swc_ecmascript
=
{
version
=
"0.8
7.0
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
swc_ecmascript
=
{
version
=
"0.8
8.1
"
,
features
=
[
"codegen"
,
"minifier"
,
"optimization"
,
"parser"
,
"react"
,
"transforms"
,
"typescript"
,
"utils"
,
"visit"
]
}
tracing
=
{version
=
"0.1.28"
,
features
=
["release_max_level_off"]
}
tracing
=
{version
=
"0.1.28"
,
features
=
["release_max_level_off"]
}
wasm-bindgen
=
{version
=
"0.2"
,
features
=
["serde-serialize"]
}
wasm-bindgen
=
{version
=
"0.2"
,
features
=
["serde-serialize"]
}
wasm-bindgen-futures
=
"0.4.8"
wasm-bindgen-futures
=
"0.4.8"
packages/next-swc/rust-toolchain
View file @
1bc9b1ac
nightly-2021-08-12
nightly-2021-11-15
\ No newline at end of file
\ No newline at end of file
packages/next/build/swc/index.js
View file @
1bc9b1ac
const
fs
=
require
(
'fs'
)
import
{
platform
,
arch
}
from
'os'
const
{
platform
,
arch
}
=
require
(
'os'
)
import
{
platformArchTriples
}
from
'@napi-rs/triples'
const
path
=
require
(
'path'
)
import
Log
from
'../output/log'
const
{
platformArchTriples
}
=
require
(
'@napi-rs/triples'
)
const
Log
=
require
(
'../output/log'
)
const
ArchName
=
arch
()
const
ArchName
=
arch
()
const
PlatformName
=
platform
()
const
PlatformName
=
platform
()
const
triples
=
platformArchTriples
[
PlatformName
][
ArchName
]
let
bindings
=
loadBindings
()
async
function
loadBindings
()
{
let
isWasm
=
false
return
(
await
loadWasm
())
||
loadNative
()
}
function
loadBindings
()
{
let
loadError
async
function
loadWasm
()
{
// Try to load wasm bindings
// Try to load wasm bindings
for
(
let
specifier
of
[
'@next/swc-wasm-web'
,
'@next/swc-wasm-nodejs'
])
{
for
(
let
specifier
of
[
'@next/swc-wasm-web'
,
'@next/swc-wasm-nodejs'
])
{
try
{
try
{
bindings
=
require
(
specifier
)
let
bindings
=
await
import
(
specifier
)
isWasm
=
true
if
(
specifier
===
'@next/swc-wasm-web'
)
{
return
bindings
bindings
=
await
bindings
.
default
()
}
catch
(
e
)
{
if
(
e
?.
code
!==
'MODULE_NOT_FOUND'
)
{
loadError
=
e
}
}
}
return
{
transform
(
src
,
options
)
{
return
Promise
.
resolve
(
bindings
.
transformSync
(
src
.
toString
(),
options
)
)
},
minify
(
src
,
options
)
{
return
Promise
.
resolve
(
bindings
.
minifySync
(
src
.
toString
(),
options
))
},
}
}
catch
(
e
)
{}
}
}
}
// Try to load native bindings
function
loadNative
()
{
const
triples
=
platformArchTriples
[
PlatformName
][
ArchName
]
let
bindings
for
(
const
triple
of
triples
)
{
let
loadError
const
localFilePath
=
path
.
join
(
__dirname
,
'../../../../next-swc/native'
,
`next-swc.
${
triple
.
platformArchABI
}
.node`
)
if
(
fs
.
existsSync
(
localFilePath
))
{
Log
.
info
(
'Using locally built binary of next-swc'
)
try
{
return
require
(
localFilePath
)
}
catch
(
e
)
{
loadError
=
e
}
}
for
(
const
triple
of
triples
)
{
try
{
try
{
return
require
(
`@next/swc-
${
triple
.
platformArchABI
}
`
)
bindings
=
require
(
`@next/swc/native/next-swc.
${
triple
.
platformArchABI
}
.node`
)
Log
.
info
(
'Using locally built binary of @next/swc'
)
break
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
e
?.
code
!==
'MODULE_NOT_FOUND'
)
{
if
(
e
?.
code
!==
'MODULE_NOT_FOUND'
)
{
loadError
=
e
loadError
=
e
}
}
}
}
}
// PR stats location/isolated tests location
for
(
const
triple
of
triples
)
{
try
{
try
{
Log
.
info
(
'Using locally built binary of @next/swc'
)
bindings
=
require
(
`@next/swc-
${
triple
.
platformArchABI
}
`
)
return
require
(
`@next/swc/native/next-swc.
${
triple
.
platformArchABI
}
.node`
)
break
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
e
?.
code
!==
'MODULE_NOT_FOUND'
)
{
if
(
e
?.
code
!==
'MODULE_NOT_FOUND'
)
{
loadError
=
e
loadError
=
e
...
@@ -62,6 +59,52 @@ function loadBindings() {
...
@@ -62,6 +59,52 @@ function loadBindings() {
}
}
}
}
if
(
bindings
)
{
return
{
transform
(
src
,
options
)
{
const
isModule
=
typeof
src
!==
'string'
&&
!
Buffer
.
isBuffer
(
src
)
options
=
options
||
{}
if
(
options
?.
jsc
?.
parser
)
{
options
.
jsc
.
parser
.
syntax
=
options
.
jsc
.
parser
.
syntax
??
'ecmascript'
}
return
bindings
.
transform
(
isModule
?
JSON
.
stringify
(
src
)
:
src
,
isModule
,
toBuffer
(
options
)
)
},
transformSync
(
src
,
options
)
{
const
isModule
=
typeof
src
!==
'string'
&&
!
Buffer
.
isBuffer
(
src
)
options
=
options
||
{}
if
(
options
?.
jsc
?.
parser
)
{
options
.
jsc
.
parser
.
syntax
=
options
.
jsc
.
parser
.
syntax
??
'ecmascript'
}
return
bindings
.
transformSync
(
isModule
?
JSON
.
stringify
(
src
)
:
src
,
isModule
,
toBuffer
(
options
)
)
},
minify
(
src
,
options
)
{
return
bindings
.
minify
(
toBuffer
(
src
),
toBuffer
(
options
??
{}))
},
minifySync
(
src
,
options
)
{
return
bindings
.
minifySync
(
toBuffer
(
src
),
toBuffer
(
options
??
{}))
},
bundle
(
options
)
{
return
bindings
.
bundle
(
toBuffer
(
options
))
},
}
}
if
(
loadError
)
{
if
(
loadError
)
{
console
.
error
(
loadError
)
console
.
error
(
loadError
)
}
}
...
@@ -72,59 +115,31 @@ function loadBindings() {
...
@@ -72,59 +115,31 @@ function loadBindings() {
process
.
exit
(
1
)
process
.
exit
(
1
)
}
}
async
function
transform
(
src
,
options
)
{
function
toBuffer
(
t
)
{
const
isModule
=
typeof
src
!==
'string'
&&
!
Buffer
.
isBuffer
(
src
)
return
Buffer
.
from
(
JSON
.
stringify
(
t
))
options
=
options
||
{}
if
(
options
?.
jsc
?.
parser
)
{
options
.
jsc
.
parser
.
syntax
=
options
.
jsc
.
parser
.
syntax
??
'ecmascript'
}
const
result
=
bindings
.
transform
(
isModule
?
JSON
.
stringify
(
src
)
:
src
,
isModule
,
toBuffer
(
options
)
)
return
isWasm
?
Promise
.
resolve
(
result
)
:
result
}
}
function
transformSync
(
src
,
options
)
{
export
async
function
transform
(
src
,
options
)
{
const
isModule
=
typeof
src
!==
'string'
&&
!
Buffer
.
isBuffer
(
src
)
let
bindings
=
await
loadBindings
()
options
=
options
||
{}
return
bindings
.
transform
(
src
,
options
)
if
(
options
?.
jsc
?.
parser
)
{
options
.
jsc
.
parser
.
syntax
=
options
.
jsc
.
parser
.
syntax
??
'ecmascript'
}
return
bindings
.
transformSync
(
isModule
?
JSON
.
stringify
(
src
)
:
src
,
isModule
,
toBuffer
(
options
)
)
}
}
function
toBuffer
(
t
)
{
export
function
transformSync
(
src
,
options
)
{
return
Buffer
.
from
(
JSON
.
stringify
(
t
))
let
bindings
=
loadNative
()
return
bindings
.
transformSync
(
src
,
options
)
}
}
export
async
function
minify
(
src
,
opts
)
{
export
async
function
minify
(
src
,
opt
ion
s
)
{
const
result
=
bindings
.
minify
(
toBuffer
(
src
),
toBuffer
(
opts
??
{})
)
let
bindings
=
await
loadBindings
(
)
return
isWasm
?
Promise
.
resolve
(
result
)
:
result
return
bindings
.
minify
(
src
,
options
)
}
}
export
function
minifySync
(
src
,
opts
)
{
export
function
minifySync
(
src
,
options
)
{
return
bindings
.
minifySync
(
toBuffer
(
src
),
toBuffer
(
opts
??
{}))
let
bindings
=
loadNative
()
return
bindings
.
minifySync
(
src
,
options
)
}
}
export
async
function
bundle
(
options
)
{
export
async
function
bundle
(
options
)
{
if
(
isWasm
)
{
let
bindings
=
loadNative
()
Log
.
error
(
`SWC bundle() method is not supported in wasm environments yet.`
)
process
.
exit
(
1
)
}
return
bindings
.
bundle
(
toBuffer
(
options
))
return
bindings
.
bundle
(
toBuffer
(
options
))
}
}
module
.
exports
.
transform
=
transform
module
.
exports
.
transformSync
=
transformSync
module
.
exports
.
minify
=
minify
module
.
exports
.
minifySync
=
minifySync
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment