mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 00:32:15 +03:00
feat(plugin): Groundwork for rust plugin system (#1893)
This commit is contained in:
parent
427df9a979
commit
18e2232dbc
3
.github/workflows/cargo.yml
vendored
3
.github/workflows/cargo.yml
vendored
@ -144,6 +144,9 @@ jobs:
|
||||
- swc_macros_common
|
||||
- swc_node_base
|
||||
- swc_node_bundler
|
||||
- swc_plugin
|
||||
- swc_plugin_runner
|
||||
- swc_plugin_testing
|
||||
- swc_stylis
|
||||
- swc_visit
|
||||
- swc_visit_macros
|
||||
|
283
Cargo.lock
generated
283
Cargo.lock
generated
@ -12,6 +12,52 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c14e9b355e56a614082b552bf24c28b9db1ac50325c96125a1f2723575b39653"
|
||||
dependencies = [
|
||||
"abi_stable_derive",
|
||||
"abi_stable_shared",
|
||||
"core_extensions",
|
||||
"crossbeam-channel",
|
||||
"generational-arena",
|
||||
"libloading 0.6.7",
|
||||
"lock_api 0.4.4",
|
||||
"parking_lot 0.11.1",
|
||||
"repr_offset",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable_derive"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3434fe2abd3d4c780fb4c23b747cdb8bc2fc1b52dc2329b7b40c1b62ae9f1ab"
|
||||
dependencies = [
|
||||
"abi_stable_shared",
|
||||
"as_derive_utils",
|
||||
"core_extensions",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn",
|
||||
"typed-arena",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable_shared"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a96112d6a13f37dd1cc2a2f07f7f12b7c3d176b6eec36e7987432a70fece8b48"
|
||||
dependencies = [
|
||||
"core_extensions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.16.0"
|
||||
@ -87,6 +133,18 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "as_derive_utils"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffc3613a62c7b739739a2cb1ee166ac275f16c5b86caf454ba21a2f79f04b025"
|
||||
dependencies = [
|
||||
"core_extensions",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ast_node"
|
||||
version = "0.7.3"
|
||||
@ -294,6 +352,15 @@ version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
|
||||
|
||||
[[package]]
|
||||
name = "core_extensions"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a117e1ca5d83ff939487e48e143c6a642cebd01a88f472a4ec7dc4773690fda"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.1.5"
|
||||
@ -617,6 +684,15 @@ dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generational-arena"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.4"
|
||||
@ -818,6 +894,15 @@ dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.3.1"
|
||||
@ -860,7 +945,7 @@ dependencies = [
|
||||
"dashmap",
|
||||
"nom",
|
||||
"serde",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
@ -903,6 +988,26 @@ version = "0.2.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.1.5"
|
||||
@ -913,6 +1018,15 @@ dependencies = [
|
||||
"scopeguard 0.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
|
||||
dependencies = [
|
||||
"scopeguard 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
@ -1090,7 +1204,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_bundler",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
@ -1298,8 +1412,19 @@ version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
"lock_api 0.1.5",
|
||||
"parking_lot_core 0.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api 0.4.4",
|
||||
"parking_lot_core 0.8.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1315,6 +1440,20 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"instant",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec 1.6.1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "path-clean"
|
||||
version = "0.1.0"
|
||||
@ -1804,6 +1943,15 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "repr_offset"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "422498868d83340d45980a20132f29cbdcf8a84bf6e9e95b151a0b47f1288df4"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.4"
|
||||
@ -2156,7 +2304,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sourcemap",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_bundler",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
@ -2185,13 +2333,23 @@ dependencies = [
|
||||
"string_cache_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_atoms"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "837a3ef86c2817228e733b6f173c821fd76f9eb21a0bc9001a826be48b00b4e7"
|
||||
dependencies = [
|
||||
"string_cache",
|
||||
"string_cache_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_babel_ast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_node_base",
|
||||
]
|
||||
@ -2208,7 +2366,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_babel_ast",
|
||||
"swc_babel_visit",
|
||||
"swc_common",
|
||||
@ -2227,7 +2385,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_babel_ast",
|
||||
"swc_visit",
|
||||
]
|
||||
@ -2254,7 +2412,7 @@ dependencies = [
|
||||
"reqwest",
|
||||
"retain_mut",
|
||||
"sha-1",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2285,7 +2443,7 @@ dependencies = [
|
||||
"num-bigint",
|
||||
"once_cell",
|
||||
"owning_ref",
|
||||
"parking_lot",
|
||||
"parking_lot 0.7.1",
|
||||
"rayon",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
@ -2316,7 +2474,7 @@ dependencies = [
|
||||
"is-macro",
|
||||
"serde",
|
||||
"string_enum",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
]
|
||||
|
||||
@ -2326,7 +2484,7 @@ version = "0.2.0"
|
||||
dependencies = [
|
||||
"auto_impl",
|
||||
"bitflags",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_css_ast",
|
||||
"swc_css_codegen_macros",
|
||||
@ -2354,7 +2512,7 @@ dependencies = [
|
||||
"lexical",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_css_ast",
|
||||
"swc_css_visit",
|
||||
@ -2366,7 +2524,7 @@ dependencies = [
|
||||
name = "swc_css_utils"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_css_ast",
|
||||
"swc_css_visit",
|
||||
@ -2376,7 +2534,7 @@ dependencies = [
|
||||
name = "swc_css_visit"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_css_ast",
|
||||
"swc_visit",
|
||||
@ -2392,7 +2550,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"string_enum",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
]
|
||||
|
||||
@ -2403,7 +2561,7 @@ dependencies = [
|
||||
"bitflags",
|
||||
"num-bigint",
|
||||
"sourcemap",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen_macros",
|
||||
@ -2426,7 +2584,7 @@ dependencies = [
|
||||
name = "swc_ecma_dep_graph"
|
||||
version = "0.35.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
@ -2439,7 +2597,7 @@ name = "swc_ecma_ext_transforms"
|
||||
version = "0.25.0"
|
||||
dependencies = [
|
||||
"phf",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
@ -2461,7 +2619,7 @@ dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_visit",
|
||||
@ -2485,7 +2643,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_regex",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2515,7 +2673,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smallvec 1.6.1",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_visit",
|
||||
@ -2538,7 +2696,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"st-map",
|
||||
"string_enum",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2556,7 +2714,7 @@ version = "0.67.0"
|
||||
dependencies = [
|
||||
"pretty_assertions 0.6.1",
|
||||
"sourcemap",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2586,7 +2744,7 @@ dependencies = [
|
||||
"phf",
|
||||
"scoped-tls",
|
||||
"smallvec 1.6.1",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2600,7 +2758,7 @@ dependencies = [
|
||||
name = "swc_ecma_transforms_classes"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_transforms_base",
|
||||
@ -2620,7 +2778,7 @@ dependencies = [
|
||||
"ordered-float",
|
||||
"serde",
|
||||
"smallvec 1.6.1",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
@ -2654,7 +2812,7 @@ dependencies = [
|
||||
"indexmap",
|
||||
"pathdiff",
|
||||
"serde",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_loader",
|
||||
@ -2678,7 +2836,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"retain_mut",
|
||||
"serde_json",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
@ -2702,7 +2860,7 @@ dependencies = [
|
||||
"fxhash",
|
||||
"serde",
|
||||
"smallvec 1.6.1",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_loader",
|
||||
@ -2728,7 +2886,7 @@ dependencies = [
|
||||
"serde",
|
||||
"sha-1",
|
||||
"string_enum",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2767,7 +2925,7 @@ version = "0.36.0"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"serde",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
@ -2789,7 +2947,7 @@ version = "0.41.3"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"scoped-tls",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_visit",
|
||||
@ -2802,7 +2960,7 @@ name = "swc_ecma_visit"
|
||||
version = "0.35.2"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_visit",
|
||||
@ -2869,7 +3027,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"string_enum",
|
||||
"swc",
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_bundler",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
@ -2885,11 +3043,58 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_plugin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"abi_stable",
|
||||
"anyhow",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_plugin_runner"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"abi_stable",
|
||||
"anyhow",
|
||||
"libloading 0.7.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
"swc_ecma_parser",
|
||||
"swc_plugin",
|
||||
"testing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_plugin_testing"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
"swc_plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_stylis"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swc_atoms",
|
||||
"swc_atoms 0.2.7",
|
||||
"swc_common",
|
||||
"swc_css_ast",
|
||||
"swc_css_codegen",
|
||||
@ -3097,6 +3302,12 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
||||
|
||||
[[package]]
|
||||
name = "typed-arena"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.13.0"
|
||||
|
13
Cargo.toml
13
Cargo.toml
@ -1,5 +1,16 @@
|
||||
[workspace]
|
||||
members = ["css", "css/stylis", "ecmascript", "ecmascript/babel/compat", "ecmascript/jsdoc", "node/binding", "wasm"]
|
||||
members = [
|
||||
"css",
|
||||
"css/stylis",
|
||||
"ecmascript",
|
||||
"ecmascript/babel/compat",
|
||||
"ecmascript/jsdoc",
|
||||
"node/binding",
|
||||
"plugin",
|
||||
"plugin/runner",
|
||||
"plugin/testing",
|
||||
"wasm",
|
||||
]
|
||||
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
|
22
plugin/Cargo.toml
Normal file
22
plugin/Cargo.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Base for swc plugins"
|
||||
documentation = "https://rustdoc.swc.rs/swc_plugin/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_plugin"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
abi_stable = "0.9.3"
|
||||
anyhow = "1.0.41"
|
||||
serde = "1.0.126"
|
||||
serde_json = "1.0.64"
|
||||
swc_atoms = {version = "0.2.7", path = "../atoms"}
|
||||
swc_common = {version = "0.11.6", path = "../common"}
|
||||
swc_ecma_ast = {version = "0.49.5", path = "../ecmascript/ast"}
|
||||
swc_ecma_utils = {version = "0.41.3", path = "../ecmascript/utils"}
|
||||
swc_ecma_visit = {version = "0.35.2", path = "../ecmascript/visit"}
|
3
plugin/README.md
Normal file
3
plugin/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# swc_plugin
|
||||
|
||||
Base runtime for swc plugins, written in rust.
|
14
plugin/build/Cargo.toml
Normal file
14
plugin/build/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Base for swc plugins"
|
||||
documentation = "https://rustdoc.swc.rs/swc_plugin_build/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_plugin_build"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.41"
|
1
plugin/build/src/lib.rs
Normal file
1
plugin/build/src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
pub fn setup() {}
|
26
plugin/runner/Cargo.toml
Normal file
26
plugin/runner/Cargo.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Runner for swc plugins. This crate is INTERRNAL crate and used by swc itself."
|
||||
documentation = "https://rustdoc.swc.rs/swc_plugin_runner/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_plugin_runner"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
abi_stable = "0.9.3"
|
||||
anyhow = "1.0.42"
|
||||
libloading = "0.7.0"
|
||||
serde = {version = "1.0.126", features = ["derive"]}
|
||||
serde_json = "1.0.64"
|
||||
swc_atoms = "0.2.7"
|
||||
swc_common = {version = "0.11.6", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.49.5", path = "../../ecmascript/ast"}
|
||||
swc_ecma_parser = {version = "0.67.1", path = "../../ecmascript/parser"}
|
||||
swc_plugin = {version = "0.1", path = "../"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_codegen = {version = "0.67.2", path = "../../ecmascript/codegen"}
|
||||
testing = {version = "0.12.2", path = "../../testing"}
|
41
plugin/runner/src/lib.rs
Normal file
41
plugin/runner/src/lib.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use abi_stable::{
|
||||
library::RootModule,
|
||||
std_types::{RResult, RStr, RString},
|
||||
};
|
||||
use anyhow::{anyhow, Context, Error};
|
||||
use std::path::Path;
|
||||
use swc_ecma_ast::Program;
|
||||
use swc_plugin::SwcPluginRef;
|
||||
|
||||
pub fn apply_js_plugin(program: &Program, path: &Path) -> Result<Program, Error> {
|
||||
(|| -> Result<_, Error> {
|
||||
let plugin = SwcPluginRef::load_from_file(path).context("failed to load plugin")?;
|
||||
|
||||
let config_json = "{}";
|
||||
let ast_json =
|
||||
serde_json::to_string(&program).context("failed to serialize program as json")?;
|
||||
|
||||
let plugin_fn = plugin
|
||||
.process_js()
|
||||
.ok_or_else(|| anyhow!("the plugin does not support transforming js"))?;
|
||||
|
||||
let new_ast = plugin_fn(RStr::from(config_json), RString::from(ast_json));
|
||||
|
||||
let new = match new_ast {
|
||||
RResult::ROk(v) => v,
|
||||
RResult::RErr(err) => return Err(anyhow!("plugin returned an errror\n{}", err)),
|
||||
};
|
||||
let new = new.into_string();
|
||||
|
||||
let new = serde_json::from_str(&new)
|
||||
.with_context(|| format!("plugin generated invalid ast: `{}`", new))?;
|
||||
|
||||
Ok(new)
|
||||
})()
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to invoke `{}` as js transform plugin",
|
||||
path.display()
|
||||
)
|
||||
})
|
||||
}
|
7
plugin/scripts/cli.sh
Executable file
7
plugin/scripts/cli.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
cargo install --path ./cli
|
||||
|
||||
(cd plugins && swc-dev $@)
|
12
plugin/scripts/test.sh
Executable file
12
plugin/scripts/test.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## This script assumes `plugins` is in `$CDPATH`
|
||||
|
||||
set -eu
|
||||
|
||||
(cd plugins && cargo build && ls -al target/debug)
|
||||
|
||||
export PLUGINS_DIR=$(cd plugins > /dev/null && pwd)
|
||||
echo "Using plugins at $PLUGINS_DIR"
|
||||
|
||||
(cd runner && cargo test)
|
32
plugin/src/lib.rs
Normal file
32
plugin/src/lib.rs
Normal file
@ -0,0 +1,32 @@
|
||||
/// Reexported for convinience.
|
||||
use abi_stable::{
|
||||
library::RootModule,
|
||||
package_version_strings,
|
||||
sabi_types::VersionStrings,
|
||||
std_types::{RResult, RStr, RString},
|
||||
StableAbi,
|
||||
};
|
||||
|
||||
pub mod ecmascript {
|
||||
pub extern crate swc_ecma_ast as ast;
|
||||
pub extern crate swc_ecma_utils as utils;
|
||||
pub extern crate swc_ecma_visit as visit;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(StableAbi)]
|
||||
#[sabi(kind(Prefix(prefix_ref = "SwcPluginRef")))]
|
||||
#[sabi(missing_field(panic))]
|
||||
pub struct SwcPlugin {
|
||||
#[sabi(last_prefix_field)]
|
||||
pub process_js:
|
||||
Option<extern "C" fn(config_str: RStr, ast_json: RString) -> RResult<RString, RString>>,
|
||||
}
|
||||
|
||||
impl RootModule for SwcPluginRef {
|
||||
abi_stable::declare_root_module_statics! {SwcPluginRef}
|
||||
|
||||
const BASE_NAME: &'static str = "swc_plugin";
|
||||
const NAME: &'static str = "swc_plugin";
|
||||
const VERSION_STRINGS: VersionStrings = package_version_strings!();
|
||||
}
|
21
plugin/testing/Cargo.toml
Normal file
21
plugin/testing/Cargo.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Base for swc plugins"
|
||||
documentation = "https://rustdoc.swc.rs/swc_plugin_testing/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_plugin_testing"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.41"
|
||||
swc_atoms = {version = "0.2.7", path = "../../atoms"}
|
||||
swc_common = {version = "0.11.6", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.49.5", path = "../../ecmascript/ast"}
|
||||
swc_ecma_codegen = {version = "0.67.2", path = "../../ecmascript/codegen"}
|
||||
swc_ecma_utils = {version = "0.41.3", path = "../../ecmascript/utils"}
|
||||
swc_ecma_visit = {version = "0.35.2", path = "../../ecmascript/visit"}
|
||||
swc_plugin = {version = "0.1.0", path = "../"}
|
1
plugin/testing/src/lib.rs
Normal file
1
plugin/testing/src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
|
Loading…
Reference in New Issue
Block a user