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

Fails to traverse directories in importMap #420

Open
dylanpyle opened this issue Jul 18, 2024 · 1 comment
Open

Fails to traverse directories in importMap #420

dylanpyle opened this issue Jul 18, 2024 · 1 comment

Comments

@dylanpyle
Copy link
Contributor

This is a bit hard to understand without seeing the actual directory structure, so I've put a reproduction together here:

https://github.com/dylanpyle/dnt-repro

dnt fails to traverse directories/identify the correct base directory across folders specified in a deno.json import map, if the import used is more than one directory deep.

So, if your deno.json contains:

{
  "imports": {
    "project-two/": "../project-two/"
  }
}

— and you import something e.g.

import { thing } from "project-two/one-more-folder/mod.ts";

— it fails with the following error:

[dnt] Transforming...
error: Uncaught (in promise) "Error stripping prefix of /Users/dylan/dev/scratchpad/dnt-repro/project-two/one-more-folder/mod.ts with base /Users/dylan/dev/scratchpad/dnt-repro/project-one"

Reproduction steps:

Expected output:

  • It works (which it does without the extra nested directory, and in most other similar cases)

Actual output:

$ deno run -A compile.ts
[dnt] Transforming...
error: Uncaught (in promise) "Error stripping prefix of /Users/dylan/dev/scratchpad/dnt-repro/project-two/deeper/mod.ts with base /Users/dylan/dev/scratchpad/dnt-repro/project-one"
@hesxenon
Copy link

hesxenon commented Aug 18, 2024

for me it also fails without the nested structure, i.e.:

{
  "imports": {
    "project-two": "../project-two/mod.ts"
  }
}

Seems to me (with my very limited rust knowledge) that this line in mappings.rs fails because the whole "context" assumes that importmaps won't reference paths outside of the project directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants