diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 2 | ||||
-rw-r--r-- | cli/build.rs | 27 | ||||
-rw-r--r-- | cli/rt/40_error_stack.js | 2 | ||||
-rw-r--r-- | cli/tests/error_009_op_crates_error.js | 2 | ||||
-rw-r--r-- | cli/tests/error_009_op_crates_error.js.out | 3 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 6 | ||||
-rw-r--r-- | cli/tsc.rs | 13 |
7 files changed, 39 insertions, 16 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6d4ca7793..063f53753 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -21,7 +21,7 @@ path = "./bench/main.rs" [build-dependencies] deno_core = { path = "../core", version = "0.56.0" } -deno_web = { path = "../op_crates/web", version = "0.7.0" } +deno_web = { path = "../op_crates/web", version = "0.7.1" } [target.'cfg(windows)'.build-dependencies] winres = "0.1.11" diff --git a/cli/build.rs b/cli/build.rs index dcc6b4187..422bc1759 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -15,12 +15,20 @@ use std::path::PathBuf; fn create_snapshot( mut isolate: JsRuntime, snapshot_path: &Path, - files: Vec<String>, + files: Vec<PathBuf>, ) { deno_web::init(&mut isolate); + // TODO(nayeemrmn): https://github.com/rust-lang/cargo/issues/3946 to get the + // workspace root. + let display_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); for file in files { - println!("cargo:rerun-if-changed={}", file); - js_check(isolate.execute(&file, &std::fs::read_to_string(&file).unwrap())); + println!("cargo:rerun-if-changed={}", file.display()); + let display_path = file.strip_prefix(display_root).unwrap(); + let display_path_str = display_path.display().to_string(); + js_check(isolate.execute( + &("deno:".to_string() + &display_path_str.replace('\\', "/")), + &std::fs::read_to_string(&file).unwrap(), + )); } let snapshot = isolate.snapshot(); @@ -30,7 +38,7 @@ fn create_snapshot( println!("Snapshot written to: {} ", snapshot_path.display()); } -fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<String>) { +fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) { let state = BasicState::new(); let isolate = JsRuntime::new(state, StartupData::None, true); create_snapshot(isolate, snapshot_path, files); @@ -38,7 +46,7 @@ fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<String>) { fn create_compiler_snapshot( snapshot_path: &Path, - files: Vec<String>, + files: Vec<PathBuf>, cwd: &Path, ) { let mut custom_libs: HashMap<String, PathBuf> = HashMap::new(); @@ -134,15 +142,16 @@ fn main() { } } -fn get_js_files(d: &str) -> Vec<String> { +fn get_js_files(d: &str) -> Vec<PathBuf> { + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let mut js_files = std::fs::read_dir(d) .unwrap() .map(|dir_entry| { let file = dir_entry.unwrap(); - file.path().to_string_lossy().to_string() + manifest_dir.join(file.path()) }) - .filter(|filename| filename.ends_with(".js")) - .collect::<Vec<String>>(); + .filter(|path| path.extension().unwrap_or_default() == "js") + .collect::<Vec<PathBuf>>(); js_files.sort(); js_files } diff --git a/cli/rt/40_error_stack.js b/cli/rt/40_error_stack.js index 80f4fc5ed..5d1a077ad 100644 --- a/cli/rt/40_error_stack.js +++ b/cli/rt/40_error_stack.js @@ -240,7 +240,7 @@ }); for (const callSite of mappedCallSites) { error.__callSiteEvals.push(Object.freeze(evaluateCallSite(callSite))); - const isInternal = callSite.getFileName()?.startsWith("$deno$") ?? false; + const isInternal = callSite.getFileName()?.startsWith("deno:") ?? false; error.__formattedFrames.push(callSiteToString(callSite, isInternal)); } Object.freeze(error.__callSiteEvals); diff --git a/cli/tests/error_009_op_crates_error.js b/cli/tests/error_009_op_crates_error.js new file mode 100644 index 000000000..01b97ea38 --- /dev/null +++ b/cli/tests/error_009_op_crates_error.js @@ -0,0 +1,2 @@ +// Missing arg. +new Event(); diff --git a/cli/tests/error_009_op_crates_error.js.out b/cli/tests/error_009_op_crates_error.js.out new file mode 100644 index 000000000..fd428b28e --- /dev/null +++ b/cli/tests/error_009_op_crates_error.js.out @@ -0,0 +1,3 @@ +[WILDCARD]error: Uncaught TypeError: Event requires at least 1 argument, but only 0 present[WILDCARD] + at new Event (deno:op_crates/web/[WILDCARD]) + at [WILDCARD] diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 4b1b67f7f..2f70cf050 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1811,6 +1811,12 @@ itest!(error_008_checkjs { output: "error_008_checkjs.js.out", }); +itest!(error_009_op_crates_error { + args: "run error_009_op_crates_error.js", + output: "error_009_op_crates_error.js.out", + exit_code: 1, +}); + itest!(error_011_bad_module_specifier { args: "run --reload error_011_bad_module_specifier.ts", exit_code: 1, diff --git a/cli/tsc.rs b/cli/tsc.rs index ae2db6978..90a1a31b5 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -1103,6 +1103,9 @@ impl TsCompiler { script_name: &str, ) -> Option<Vec<u8>> { if let Some(module_specifier) = self.try_to_resolve(script_name) { + if module_specifier.as_url().scheme() == "deno" { + return None; + } return match self.get_source_map_file(&module_specifier) { Ok(out) => Some(out.source_code.into_bytes()), Err(_) => { @@ -1848,11 +1851,11 @@ mod tests { (r#"{ "compilerOptions": { "checkJs": true } } "#, true), // JSON with comment ( - r#"{ - "compilerOptions": { - // force .js file compilation by Deno - "checkJs": true - } + r#"{ + "compilerOptions": { + // force .js file compilation by Deno + "checkJs": true + } }"#, true, ), |