moodringM
Denoβ€’8mo agoβ€’
11 replies
moodring

Local Deno package imports: Use package's deno.json config "exports" map?

I'm working in a Deno workspace where the outer workspace deno.json references a project within (at some sub-dir path).
- The project's deno.json uses the "exports" option to map "." to "./src/mod.ts".
- The workspace root's deno.json then references this directory in the "imports" map, from "package-a" to "./package-a".

[workspace-root]/
  [project-a]/
    src/
      mod.ts - References ``
    deno.json - Maps export "." to "src/mod.ts"
  src/
    main.ts - References 
  deno.json - Maps import "project-a" to "./project-a"


I would infer/expect (incorrectly?) based on Deno + JSR's import docs, that the outer workspace's import would use the values found in project-a's "exports" map. Running the project returns the following error:

$ deno run -A --unstable-ffi ./src/main.tsx
error: Import 'file:///Users/[user]/[workspace-root]/[project-a]' failed.
    0: Is a directory (os error 21)
error: Uncaught (in promise) ProcessError: Command failed.
Exit code: 1
            await $`deno run -A --unstable-ffi ./src/main.tsx`;
                   ^


Is my assumption incorrect? Is there something else wrong with my setup?

Ultimately, what I'd like is to respect the package's "exports" values, such that 1) I can import with a short specifier, and 2) I can reference either a local directory or the package on JSR without changing any import code.
Was this page helpful?