Skip to content

Commit 5c451a6

Browse files
link to swc repo that works with stable rust
1 parent a863cc3 commit 5c451a6

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ license = "MIT"
99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010

1111
[dependencies]
12-
swc = {version = "0.20.0"}
13-
swc_ecma_parser = {version = "0.57.1"}
14-
swc_common = {version="0.10.20", features=["tty-emitter"]}
12+
#swc = {version = "0.20.0"}
13+
#swc = {path="../swc"}
14+
swc = {git="https://github.com/HiRoFa/swc"}
15+
#swc_ecma_parser = {version = "0.57.1"}
16+
#swc_ecma_parser = {path="../swc/ecmascript/parser"}
17+
swc_ecma_parser = {git="https://github.com/HiRoFa/swc"}
18+
#swc_common = {version="0.10.20", features=["tty-emitter"]}
19+
#swc_common = {path="../swc/common", features=["tty-emitter"]}
20+
swc_common = {git="https://github.com/HiRoFa/swc", features=["tty-emitter"]}
21+
1522
hirofa_utils = {git = "https://github.com/HiRoFa/utils"}
1623
log = "0.4"
1724

rust-toolchain.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[toolchain]
2-
channel = "nightly"
2+
#channel = "nightly"
3+
channel = "stable"

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use hirofa_utils::js_utils::{JsError, Script, ScriptPreProcessor};
22
use std::sync::Arc;
33

4-
use swc::config::Config;
4+
use swc::config::{Config, JscTarget};
55
use swc_common::errors::{ColorConfig, Handler};
66
use swc_common::{FileName, SourceMap};
7-
use swc_ecma_parser::{JscTarget, Syntax};
7+
use swc_ecma_parser::{Syntax, TsConfig};
88

99
pub struct TypeScriptPreProcessor {}
1010

@@ -17,6 +17,7 @@ impl TypeScriptPreProcessor {
1717
pub fn transpile(&self, code: &str) -> Result<String, JsError> {
1818
let cm = Arc::<SourceMap>::default();
1919
let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(cm.clone()));
20+
2021
let c = swc::Compiler::new(cm.clone(), Arc::new(handler));
2122

2223
//let fm = cm
@@ -25,7 +26,7 @@ impl TypeScriptPreProcessor {
2526

2627
let fm = cm.new_source_file(FileName::Custom("test.ts".into()), code.into());
2728

28-
let ts_cfg = swc_ecma_parser::TsConfig {
29+
let ts_cfg = TsConfig {
2930
dynamic_import: true,
3031
decorators: true,
3132
..Default::default()

0 commit comments

Comments
 (0)