Skip to content

When a monorepo uses import maps to reference other modules in the same monorepo, references from other projects can fail #26764

Open
@jpravetz

Description

deno 2.0.2 (stable, release, x86_64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

This may be a question more than a bug. However I am not finding a solution by reading the workspace or import maps documents, and my interpretation of these documents is that this should work.

The issue is

  • if I create a module (repo2)
  • and it references a module in repo1 import * as bmod from "@jpravetz/bmod";
  • and repo1 is a monorepo with workspaces (amod and bmod)
  • and the reference is via a relative path "@jpravetz/bmod": "../repo1/bmod/mod.ts"
  • and the referenced module (bmod) references a different module (amod) in repo1 import { add } from '@scope/amod';
  • and the reference is in the repo1/bmod import map "@scope/amod": "../amod/mod.ts"
  • then when I run deno lint on repo2 I get a relative import path error

To reproduce

git clone https://github.com/jpravetz/repo1.git
git clone https://github.com/jpravetz/repo2.git
cd repo2
deno lint

Error message

error: Relative import path "@scope/amod" not prefixed with / or ./ or ../ and not in import map from "file:///Users/jpravetz/dev/tmp/repo1/bmod/mod.ts"
    at file:///Users/jpravetz/dev/tmp/repo1/bmod/mod.ts:1:21

Lint and testing are working within repo1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions