pub fn compile_bundle(
  bundle_filename: &Path,
  root_names: Vec<PathBuf>,
  extern_crate_modules: Option<ExternCrateModules>,
) -> Result<String, ErrBox> {
  let ts_isolate = TSIsolate::new(true, extern_crate_modules);

  let config_json = serde_json::json!({
    "compilerOptions": {
      "declaration": true,
      // Emit the source alongside the sourcemaps within a single file;
      // requires --inlineSourceMap or --sourceMap to be set.
      // "inlineSources": true,
      "lib": ["esnext"],
      "listEmittedFiles": true,
      "listFiles": true,
      "module": "system",
      "outFile": bundle_filename,
      "removeComments": true,
      "sourceMap": true,
      "strict": true,
      "target": "esnext",
      "typeRoots" : ["$typeRoots$"],
    },
  });

  let root_names_str: Vec<String> = root_names
    .iter()
    .map(|p| {
      if !p.exists() {
        panic!("File not found {}", p.display());
      }

      let module_specifier =
        ModuleSpecifier::resolve_url_or_path(&p.to_string_lossy()).unwrap();
      module_specifier.as_str().to_string()
    })
    .collect();

  // TODO lift js_check to caller?
  let locked_state = js_check(ts_isolate.compile(&config_json, root_names_str));
  let state = locked_state.lock().unwrap();
  // Assuming that TypeScript has emitted the main file last.
  let main = state.written_files.last().unwrap();
  let module_name = main.module_name.clone();
  Ok(module_name)
}
/// Compile provided roots into a single JS bundle.
///
/// This function writes compiled bundle to disk at provided path.
///
/// Source map file and type declaration file are emitted
/// alongside the bundle.
///
/// To instantiate bundle use returned `module_name`.
Compile provided roots into a single JS bundle.
This function writes compiled bundle to disk at provided path.

Source map file and type declaration file are emitted
alongside the bundle.

To instantiate bundle use returned `module_name`.
Compile provided roots into a single JS bundle . This function writes compiled bundle to disk at provided path . Source map file and type declaration file are emitted alongside the bundle . To instantiate bundle use returned ` module_name ` .
pub fn compile_bundle(
  bundle_filename: &Path,
  root_names: Vec<PathBuf>,
  extern_crate_modules: Option<ExternCrateModules>,
) -> Result<String, ErrBox> {
  let ts_isolate = TSIsolate::new(true, extern_crate_modules);
  let config_json = serde_json::json!({
    "compilerOptions": {
      "declaration": true,
      // Emit the source alongside the sourcemaps within a single file;
      // requires --inlineSourceMap or --sourceMap to be set.
      // "inlineSources": true,
      "lib": ["esnext"],
      "listEmittedFiles": true,
      "listFiles": true,
      "module": "system",
      "outFile": bundle_filename,
      "removeComments": true,
      "sourceMap": true,
      "strict": true,
      "target": "esnext",
      "typeRoots" : ["$typeRoots$"],
    },
  });
  let root_names_str: Vec<String> = root_names
    .iter()
    .map(|p| {
      if !p.exists() {
        panic!("File not found {}", p.display());
      }
      let module_specifier =
        ModuleSpecifier::resolve_url_or_path(&p.to_string_lossy()).unwrap();
      module_specifier.as_str().to_string()
    })
    .collect();
  // TODO lift js_check to caller?
  let locked_state = js_check(ts_isolate.compile(&config_json, root_names_str));
  let state = locked_state.lock().unwrap();
  // Assuming that TypeScript has emitted the main file last.
  let main = state.written_files.last().unwrap();
  let module_name = main.module_name.clone();
  Ok(module_name)
}
pub fn compile_bundle ( bundle_filename : & Path , root_names : Vec < PathBuf > , extern_crate_modules : Option < ExternCrateModules > , ) -> Result < String , ErrBox > { let ts_isolate = TSIsolate :: new ( true , extern_crate_modules ) ; let config_json = serde_json :: json ! ( { " " { " " true // Emit the source alongside the sourcemaps within a single file; // requires --inlineSourceMap or --sourceMap to be set. // "inlineSources": true, " " [ " " ] " " true " " true " " " " " " bundle_filename " " true " " true " " true " " " " " " [ " " ] } } ) ; let root_names_str : Vec < String > = root_names . iter ( ) . map ( | p | { if ! p . exists ( ) { panic ! ( " " p display ( ) ) ; } let module_specifier = ModuleSpecifier :: resolve_url_or_path ( & p . to_string_lossy ( ) ) . unwrap ( ) ; module_specifier . as_str ( ) . to_string ( ) } ) . collect ( ) ; // TODO lift js_check to caller? let locked_state = js_check ( ts_isolate . compile ( & config_json , root_names_str ) ) ; let state = locked_state . lock ( ) . unwrap ( ) ; // Assuming that TypeScript has emitted the main file last. let main = state . written_files . last ( ) . unwrap ( ) ; let module_name = main . module_name . clone ( ) ; Ok ( module_name ) }
Compile provided roots into a single JS bundle.
Compile provided roots into a single JS bundle .
bundle_filename
&Path
root_names
Vec<PathBuf>
extern_crate_modules
Option<ExternCrateModules>
bundle_filename
&Path
root_names
Vec<PathBuf>
extern_crate_modules
Option<ExternCrateModules>