Skip to content

Unable to publish when importing module from current member in a Deno workspace #1220

@tugrulates

Description

@tugrulates

This has been always like this, but I couldn't find the exact issue reported.

Problem

Workspaces allow importing other members without an import map.

./deno.json

{
  "workspace": [
    "./current",
    "./other",
  ]
}

./current/deno.json

{
  "name": "@scope/current",
  "version": "0.0.1",
  "exports": {
    ".": "./current.ts",
    "./module": "./module.ts"
  }
}

./other/deno.json

{
  "name": "@scope/other",
  "version": "0.0.1",
  "exports": {
    ".": "./other.ts",
  }
}
// current/current.ts
import { symbol } from "@scope/other";

This works great locally and JSR handles resolution automagically.

Things get wrong when importing from the current member.

// current/current.ts
import { symbol } from "@scope/current/module";

Deno accepts this syntax at runtime, and publish --dry-run doesn't fail. However, publishing fails with failed to build module graph: export 'module' not found in jsr:@scope/current.

Workaround

I have always tried to keep imports relative within members, just so things don't go wrong at publish time.

// current/current.ts
import { symbol } from "./module.ts";

I believe this is because the module export is not yet present on JSR. I expect the magical import to start working once the module is published once, but I have never tried this. However, I do expect JSR to be lenient initially, since I am providing the export map during upload.

Reproduction

I have produced a minimal repro case at: https://github.com/tugrulates/repo/tree/test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions