Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression when using relative import map in deno.json #23057

Closed
NeKzor opened this issue Mar 24, 2024 · 2 comments
Closed

Regression when using relative import map in deno.json #23057

NeKzor opened this issue Mar 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@NeKzor
Copy link

NeKzor commented Mar 24, 2024

Version: Deno 1.41.3

A single ../ in the path value for "importMap" inside deno.json config file will output error: Loading unprepared module when using deno run.

Minimal reproducible example:

$ cat main.ts
import '~/shared/models.ts';

$ cat deno.json 
{
  "importMap": "../import_map.json"
}

$ cat ../import_map.json 
{
    "imports": {
        "~/shared/": "./shared/"
    }
}

$ cat ../shared/models.ts 
export class Model {}

This happens since 1.41.1 but I decided to build Deno from source to find the exact commit that caused this: 6567dc9

Running the debug build will trigger a panic at this location:

debug_assert!(
!specifier.as_str().contains("../"),
"Import map specifier incorrectly contained ../: {}",
specifier.as_str()
);

The current workaround is to use "imports" in the config file or to use the --import-map flag.

@bartlomieju bartlomieju added the bug Something isn't working label Mar 24, 2024
@k-paxian
Copy link

Thank you so much @NeKzor for workaround 🎉 ❤️
It saved me literally hours 🍺

@dsherret
Copy link
Member

Fixed a couple weeks ago in #23602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants