DenoDDeno
Powered by
moodringM
Denoβ€’10mo 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
deno.json
references a project within (at some sub-dir path).
- The project's
deno.json
deno.json
uses the "exports" option to map
"."
"."
to
"./src/mod.ts"
"./src/mod.ts"
.
- The workspace root's
deno.json
deno.json
then references this directory in the
"imports"
"imports"
map, from
"package-a"
"package-a"
to
"./package-a"
"./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"
[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`;
                   ^
$ 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"
"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.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

GitHub imports from package.json in Deno
phocks_testPphocks_test / help
16mo ago
deno.json glob exports
JadJJad / help
12mo ago
Cache imports in deno.json
NebulaRhythmNNebulaRhythm / help
3y ago
Converting package.json into deno.json
KotkoroidKKotkoroid / help
16mo ago