Skip to content

Commit

Permalink
fix import maps
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Dec 22, 2020
1 parent fd46c80 commit 5c32d3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cli/ops/runtime_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use deno_core::error::AnyError;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::url::Url;
use deno_core::BufVec;
use deno_core::ModuleSpecifier;
use deno_core::OpState;
Expand Down Expand Up @@ -75,10 +74,11 @@ async fn op_emit(
)?))
};
let maybe_import_map = if let Some(import_map_str) = args.import_map_path {
let import_map_url =
Url::from_file_path(&import_map_str).map_err(|_| {
let import_map_specifier =
ModuleSpecifier::resolve_url_or_path(&import_map_str).map_err(|_| {
anyhow!("Bad file path (\"{}\") for import map.", import_map_str)
})?;
let import_map_url = import_map_specifier.as_url();
let import_map = if let Some(value) = args.import_map {
ImportMap::from_json(&import_map_url.to_string(), &value.to_string())?
} else {
Expand Down
10 changes: 4 additions & 6 deletions cli/tests/compiler_api_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,18 @@ Deno.test({
name: "Deno.emit() - import maps",
async fn() {
const { diagnostics, files, ignoredOptions, stats } = await Deno.emit(
"/a.ts",
"file:///a.ts",
{
importMap: {
imports: {
"b": "./b.ts",
},
},
importMapPath: Deno.build.os == "windows"
? "C:\\import-map.json"
: "/import-map.json",
importMapPath: "file:///import-map.json",
sources: {
"/a.ts": `import * as b from "b"
"file:///a.ts": `import * as b from "b"
console.log(b);`,
"/b.ts": `export const b = "b";`,
"file:///b.ts": `export const b = "b";`,
},
},
);
Expand Down

0 comments on commit 5c32d3e

Please sign in to comment.