-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/transforms): Add experimental output API for transforms (#9000)
**Description:** This interface will provide a way to emit some outputs from transforms. This data will be emitted back to the JS caller.
- Loading branch information
Showing
12 changed files
with
106 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[package] | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "Debug utilities" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "dbg-swc" | ||
repository = "https://github.com/kdy1/dbg-swc.git" | ||
version = "0.93.5" | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "Debug utilities" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "dbg-swc" | ||
repository.workspace = true | ||
version = "0.93.5" | ||
|
||
[[bin]] | ||
bench = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
[package] | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "JsDoc parser writen in rust" | ||
documentation = "https://rustdoc.swc.rs/jsdoc/" | ||
edition = "2021" | ||
include = ["Cargo.toml", "src/**/*.rs"] | ||
license = "Apache-2.0" | ||
name = "jsdoc" | ||
version = "0.113.1" | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "JsDoc parser writen in rust" | ||
documentation = "https://rustdoc.swc.rs/jsdoc/" | ||
edition = "2021" | ||
include = ["Cargo.toml", "src/**/*.rs"] | ||
license = "Apache-2.0" | ||
name = "jsdoc" | ||
repository.workspace = true | ||
version = "0.113.1" | ||
|
||
[lib] | ||
bench = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
[package] | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "Common logic for targetting vairous browsers" | ||
documentation = "https://rustdoc.swc.rs/preset_env_base/" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "preset_env_base" | ||
version = "0.4.13" | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "Common logic for targetting vairous browsers" | ||
documentation = "https://rustdoc.swc.rs/preset_env_base/" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "preset_env_base" | ||
repository.workspace = true | ||
version = "0.4.13" | ||
|
||
[lib] | ||
bench = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
[package] | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "preset-env for the swc" | ||
documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/" | ||
edition = "2021" | ||
include = ["Cargo.toml", "src/**/*.rs", "src/**/*.json", "data/**/*.json"] | ||
license = "Apache-2.0" | ||
name = "swc_ecma_preset_env" | ||
repository = "https://github.com/swc-project/swc" | ||
version = "0.207.1" | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "preset-env for the swc" | ||
documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/" | ||
edition = "2021" | ||
include = ["Cargo.toml", "src/**/*.rs", "src/**/*.json", "data/**/*.json"] | ||
license = "Apache-2.0" | ||
name = "swc_ecma_preset_env" | ||
repository.workspace = true | ||
version = "0.207.1" | ||
|
||
[lib] | ||
bench = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
authors = ["강동윤 <[email protected]>"] | ||
description = "Common utilities for swc transforms for any language" | ||
documentation = "https://rustdoc.swc.rs/swc_transform_common/" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "swc_transform_common" | ||
repository = "https://github.com/swc-project/swc.git" | ||
version = "0.1.0" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[dependencies] | ||
once_cell = { workspace = true } | ||
rustc-hash = { workspace = true } | ||
serde = { workspace = true } | ||
serde_json = { workspace = true } | ||
|
||
better_scoped_tls = { version = "0.1.1", path = "../better_scoped_tls" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# swc_transform_common | ||
|
||
Common utilities for the author of a swc transform. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod output; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::cell::RefCell; | ||
|
||
use better_scoped_tls::scoped_tls; | ||
use rustc_hash::FxHashMap; | ||
use serde_json::Value; | ||
|
||
scoped_tls!(static OUTPUT: RefCell<FxHashMap<String, Value>>); | ||
|
||
pub fn capture<Ret>(f: impl FnOnce() -> Ret) -> (Ret, FxHashMap<String, Value>) { | ||
let output = RefCell::new(FxHashMap::default()); | ||
|
||
let ret = OUTPUT.set(&output, f); | ||
|
||
(ret, output.into_inner()) | ||
} | ||
|
||
pub fn emit(key: String, value: Value) { | ||
OUTPUT.with(|output| { | ||
let previous = output.borrow_mut().insert(key, value); | ||
|
||
if let Some(previous) = previous { | ||
panic!("Key already set. Previous value: {previous:?}"); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters