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::compilers::CompiledModuleFuture;
|
|
|
|
use crate::file_fetcher::SourceFile;
|
2019-11-22 12:14:34 -05:00
|
|
|
use futures::future::FutureExt;
|
2019-11-16 19:17:47 -05:00
|
|
|
use std::pin::Pin;
|
2019-07-31 13:16:03 -04:00
|
|
|
use std::str;
|
|
|
|
|
|
|
|
pub struct JsCompiler {}
|
|
|
|
|
|
|
|
impl JsCompiler {
|
|
|
|
pub fn compile_async(
|
2020-01-04 05:20:52 -05:00
|
|
|
&self,
|
2020-02-03 18:08:44 -05:00
|
|
|
source_file: SourceFile,
|
2019-11-16 19:17:47 -05:00
|
|
|
) -> Pin<Box<CompiledModuleFuture>> {
|
2019-07-31 13:16:03 -04:00
|
|
|
let module = CompiledModule {
|
|
|
|
code: str::from_utf8(&source_file.source_code)
|
|
|
|
.unwrap()
|
|
|
|
.to_string(),
|
|
|
|
name: source_file.url.to_string(),
|
|
|
|
};
|
|
|
|
|
2019-11-16 19:17:47 -05:00
|
|
|
futures::future::ok(module).boxed()
|
2019-07-31 13:16:03 -04:00
|
|
|
}
|
|
|
|
}
|