Skip to content

Commit

Permalink
fix: handle specifying an import map in an ancestor dir of deno.json (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Apr 29, 2024
1 parent e6f4c8f commit 4384a12
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Expand Up @@ -65,7 +65,7 @@ winres.workspace = true
[dependencies]
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_cache_dir = { workspace = true }
deno_config = "=0.16.1"
deno_config = "=0.16.2"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "=0.128.1", features = ["html", "syntect"] }
deno_emit = "=0.40.1"
Expand Down
2 changes: 1 addition & 1 deletion cli/args/mod.rs
Expand Up @@ -943,7 +943,7 @@ impl CliOptions {
&self,
) -> Result<Option<ModuleSpecifier>, AnyError> {
match self.overrides.import_map_specifier.clone() {
Some(maybe_path) => Ok(maybe_path),
Some(maybe_url) => Ok(maybe_url),
None => resolve_import_map_specifier(
self.flags.import_map_path.as_deref(),
self.maybe_config_file.as_ref(),
Expand Down
9 changes: 9 additions & 0 deletions tests/specs/run/import_map_parent_dir/__test__.jsonc
@@ -0,0 +1,9 @@
{
"steps": [{
"args": "info --config=sub/deno.json sub/main.ts",
"output": "info.out"
}, {
"args": "run --check sub/main.ts",
"output": "run.out"
}]
}
5 changes: 5 additions & 0 deletions tests/specs/run/import_map_parent_dir/import_map.json
@@ -0,0 +1,5 @@
{
"imports": {
"~/shared/": "./shared/"
}
}
7 changes: 7 additions & 0 deletions tests/specs/run/import_map_parent_dir/info.out
@@ -0,0 +1,7 @@
local: [WILDLINE]main.ts
type: TypeScript
dependencies: 1 unique
size: [WILDLINE]

file:///[WILDLINE]/sub/main.ts ([WILDLINE])
└── file:///[WILDLINE]/shared/models.ts ([WILDLINE])
1 change: 1 addition & 0 deletions tests/specs/run/import_map_parent_dir/run.out
@@ -0,0 +1 @@
Check file:///[WILDLINE]/main.ts
1 change: 1 addition & 0 deletions tests/specs/run/import_map_parent_dir/shared/models.ts
@@ -0,0 +1 @@
export class Model {}
3 changes: 3 additions & 0 deletions tests/specs/run/import_map_parent_dir/sub/deno.json
@@ -0,0 +1,3 @@
{
"importMap": "../import_map.json"
}
1 change: 1 addition & 0 deletions tests/specs/run/import_map_parent_dir/sub/main.ts
@@ -0,0 +1 @@
import "~/shared/models.ts";

0 comments on commit 4384a12

Please sign in to comment.