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

Deno fails when a package in a monorepo uses a ./* export #26693

Open
michael-aldridge-pozlo opened this issue Nov 2, 2024 · 3 comments
Open
Labels
needs investigation requires further investigation before determining if it is an issue or not publish Related to "deno publish" subcommand triage required 👀 Deno team needs to make a decision if this change is desired

Comments

@michael-aldridge-pozlo
Copy link

michael-aldridge-pozlo commented Nov 2, 2024

Deno version

$ deno --version
deno 2.0.4 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2

To demonstrate the issue I created the following mono-repo

$ tree
.
├── a
│   ├── deno.json
│   └── src
│       └── index.ts
├── deno.json
└── index.ts

The root deno.json just specifies the a package

$ cat deno.json 
{
    "workspace": ["./a"]
}

The a package has a single export

$ cat a/src/index.ts 
export const foo = 42;

and a minimal deno.json

$ cat a/deno.json 
{
    "name": "@github-issue-example/a",
    "exports": {
        ".": "./src/index.ts",
        "./*": "./src/*"
    }
}

finally, the root module index.ts files contains a single export

$ cat index.ts 
import { foo } from "@github-issue-example/a/index.ts";

This sort of set up worked fine with node but deno is not happy about this import

$ deno run index.ts 
error: Relative import path "@github-issue-example/a/index.ts" not prefixed with / or ./ or ../ and not in import map from "file:///home/michael/github-issue-demos/deno-monorepo/index.ts"
    at file:///home/michael/github-issue-demos/deno-monorepo/index.ts:1:21

If I change the export map in a/deno.json to explicitly list index everything works fine, i.e.

$ cat a/deno.json 
{
    "name": "@github-issue-example/a",
    "exports": {
        ".": "./src/index.ts",
        "./index.ts": "./src/index.ts"
    }
}

This would seem to be a bug to me but it might be a feature request, I can't quite tell from the documentation. Any advise or help greatly appreciated. Thanks.


This issues looks similar to #20513 but I thought it different enough to warrant a separate issue.

@bartlomieju
Copy link
Member

I believe this is working as intended. deno.json exports expects all entry points to be listed out verbatim and doesn't support "globs" like ./*.

@dsherret can you please confirm it?

@bartlomieju bartlomieju added needs investigation requires further investigation before determining if it is an issue or not publish Related to "deno publish" subcommand labels Nov 4, 2024
@michael-aldridge-pozlo
Copy link
Author

Ah okay. Thanks for the clarification.

@dsherret
Copy link
Member

dsherret commented Nov 4, 2024

Yeah, it needs to list out the exports. There's some cases where we go from the deno.json or manifest to all the exports (ex. linting no-slow-types and deno install). It's a little tricky how that could work if we allowed wildcards (ex. we'd probably have to not consider files that are excluded from publish when doing this locally and remotely we'd have to look at the manifest items to figure out the modules).

I opened denoland/deno_config#134 for now.

@bartlomieju bartlomieju added the triage required 👀 Deno team needs to make a decision if this change is desired label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation requires further investigation before determining if it is an issue or not publish Related to "deno publish" subcommand triage required 👀 Deno team needs to make a decision if this change is desired
Projects
None yet
Development

No branches or pull requests

3 participants