2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-07-31 13:16:03 -04:00
|
|
|
use crate::compilers::CompiledModule;
|
|
|
|
use crate::file_fetcher::SourceFile;
|
2020-02-06 21:24:51 -05:00
|
|
|
use deno_core::ErrBox;
|
2019-07-31 13:16:03 -04:00
|
|
|
use std::str;
|
|
|
|
|
|
|
|
pub struct JsCompiler {}
|
|
|
|
|
|
|
|
impl JsCompiler {
|
2020-02-25 14:42:00 -05:00
|
|
|
pub async fn compile(
|
2020-01-04 05:20:52 -05:00
|
|
|
&self,
|
2020-02-03 18:08:44 -05:00
|
|
|
source_file: SourceFile,
|
2020-02-06 21:24:51 -05:00
|
|
|
) -> Result<CompiledModule, ErrBox> {
|
|
|
|
Ok(CompiledModule {
|
2019-07-31 13:16:03 -04:00
|
|
|
code: str::from_utf8(&source_file.source_code)
|
|
|
|
.unwrap()
|
|
|
|
.to_string(),
|
|
|
|
name: source_file.url.to_string(),
|
2020-02-06 21:24:51 -05:00
|
|
|
})
|
2019-07-31 13:16:03 -04:00
|
|
|
}
|
|
|
|
}
|