mirror of
https://github.com/swc-project/swc.git
synced 2024-11-25 22:34:04 +03:00
build(bindings): Fix build of typescript binding (#9125)
This commit is contained in:
parent
50c0eaf4de
commit
f409bc09d5
@ -24,8 +24,11 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
serde-wasm-bindgen = "0.4.5"
|
serde-wasm-bindgen = "0.4.5"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
swc_core = { version = "0.96.1", features = [
|
swc_core = { version = "0.96.1", features = [
|
||||||
"ecma_ast_serde",
|
"common",
|
||||||
|
"common_sourcemap",
|
||||||
|
"ecma_ast",
|
||||||
"ecma_codegen",
|
"ecma_codegen",
|
||||||
|
"ecma_parser",
|
||||||
"ecma_transforms",
|
"ecma_transforms",
|
||||||
"ecma_transforms_typescript",
|
"ecma_transforms_typescript",
|
||||||
"ecma_visit",
|
"ecma_visit",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use anyhow::{Context, Error};
|
use anyhow::{Context, Error};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use swc_core::{
|
use swc_core::{
|
||||||
base::{config::ErrorFormat, HandlerOpts},
|
|
||||||
common::{
|
common::{
|
||||||
comments::SingleThreadedComments, errors::ColorConfig, source_map::SourceMapGenConfig,
|
comments::SingleThreadedComments, errors::ColorConfig, source_map::SourceMapGenConfig,
|
||||||
sync::Lrc, FileName, Mark, SourceMap, GLOBALS,
|
sync::Lrc, FileName, Mark, SourceMap, GLOBALS,
|
||||||
@ -21,7 +20,7 @@ use swc_core::{
|
|||||||
visit::VisitMutWith,
|
visit::VisitMutWith,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use swc_error_reporters::handler::try_with_handler;
|
use swc_error_reporters::handler::{try_with_handler, HandlerOpts};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen_futures::{
|
use wasm_bindgen_futures::{
|
||||||
future_to_promise,
|
future_to_promise,
|
||||||
@ -79,7 +78,7 @@ pub fn transform_sync(input: JsString, options: JsValue) -> Result<JsValue, JsVa
|
|||||||
|
|
||||||
let result = GLOBALS
|
let result = GLOBALS
|
||||||
.set(&Default::default(), || operate(input, options))
|
.set(&Default::default(), || operate(input, options))
|
||||||
.map_err(|err| convert_err(err, None))?;
|
.map_err(convert_err)?;
|
||||||
|
|
||||||
Ok(serde_wasm_bindgen::to_value(&result)?)
|
Ok(serde_wasm_bindgen::to_value(&result)?)
|
||||||
}
|
}
|
||||||
@ -208,14 +207,8 @@ fn operate(input: String, options: Options) -> Result<TransformOutput, Error> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_err(
|
pub fn convert_err(err: Error) -> wasm_bindgen::prelude::JsValue {
|
||||||
err: Error,
|
format!("{:?}", err).into()
|
||||||
error_format: Option<ErrorFormat>,
|
|
||||||
) -> wasm_bindgen::prelude::JsValue {
|
|
||||||
error_format
|
|
||||||
.unwrap_or(ErrorFormat::Normal)
|
|
||||||
.format(&err)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TsSourceMapGenConfig;
|
struct TsSourceMapGenConfig;
|
||||||
|
Loading…
Reference in New Issue
Block a user