js.rs 507 字节
Newer Older
R
Ry Dahl 已提交
1
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2 3
use crate::compilers::CompiledModule;
use crate::file_fetcher::SourceFile;
4
use deno_core::ErrBox;
5 6 7 8 9
use std::str;

pub struct JsCompiler {}

impl JsCompiler {
10
  pub async fn compile(
11
    &self,
12
    source_file: SourceFile,
13 14
  ) -> Result<CompiledModule, ErrBox> {
    Ok(CompiledModule {
15 16 17 18
      code: str::from_utf8(&source_file.source_code)
        .unwrap()
        .to_string(),
      name: source_file.url.to_string(),
19
    })
20 21
  }
}