Natdm
Natdm•2mo ago

Deno Monorepo with nested applications and packages

I'm trying to move a node monorepo from NPM to Deno. It's got a set of applications in a directory called services, and set of libraries used by said services in packages. These are all independent, and are registered to the apps workspace (@example) for now. eg: if a service myapp registered as @example/myapp wanted packages/utils, it'd import @example/utils and it'd find it within packages. I'm trying to do the same in NPM but it seems like everything has to be flat, at the root. Am I not able to register workspaces that are deeper than the root directory? I've got /packages/foo/deno.json and packages/foo/mod.ts with a funciton exported. the deno.js has the following contents:
{
"name": "@example/foo",
"exports": "./mod.ts",
"version": "1.0.0"
}
{
"name": "@example/foo",
"exports": "./mod.ts",
"version": "1.0.0"
}
The root project has this deno.json:
{
"workspace": [
"./services/api",
"./packages/foo"
]
}
{
"workspace": [
"./services/api",
"./packages/foo"
]
}
I'm unable to import @example/foo in API, as it says ..
error: Relative import path "@example/foo" not prefixed with / or ./ or ../ and not in import map from "file:///app/mod.ts"
error: Relative import path "@example/foo" not prefixed with / or ./ or ../ and not in import map from "file:///app/mod.ts"
The goal is to run these in docker containers in skaffold.
5 Replies
duesabati
duesabati•5w ago
You can use glob expressions for workspace like ./services/*
marvinh.
marvinh.•5w ago
I'm unable to import @example/foo in API, as it says ..
Regarding this: Have you added @example/foo to the imports section of the consuming package's deno.json?
Erfan
Erfan•2w ago
i have the same issue, i created an example repo what i am trying to do. Maybe i am using it wrong. Is there a best practice how to make it work ? https://github.com/ErfanNaz/deno-nested-workspace-example
GitHub
GitHub - ErfanNaz/deno-nested-workspace-example
Contribute to ErfanNaz/deno-nested-workspace-example development by creating an account on GitHub.
marvinh.
marvinh.•2w ago
Right, nested workspaces are not supported in Deno. Relevant issue https://github.com/denoland/deno/issues/26879
Erfan
Erfan•2w ago
ohh thanks for the quick answer (subscribed) 🙂 i will use fore now just one workspace

Did you find this page helpful?