Rob S
Rob S3w ago

Workspace documentation lacks explanation of `exports` member in deno.json

I was reading the documentation on workspaces and monorepos. It shows usage of the exports member ina deno.json file. The example shows it as a single string. There's no explanation of the exports member in the documenation for workspaces, monorepos, nor the "deno.json and package.json" help page, either. I am trying to understand how I can share commonly used enums across all of my microservices; but, I got confused. If my enums are declared in individual *.ts files (e.g. Statuses.ts, ExpirationTypes.ts, etc), how do I mark this up in my root-level and module-level deno.json files such that I can access the enums from within all modules? Specific example: I have an enum called Status.
export enum Status = {
OFF,
ON,
CANCELLED
}
export enum Status = {
OFF,
ON,
CANCELLED
}
I want to use this enum in multiple modules without copying the enum to those modules. My hypothetical workspace structure is as follows.
root
- deno.json
/modules
/common
deno.json
Statuses.ts
/authentication
deno.json
server.ts
root
- deno.json
/modules
/common
deno.json
Statuses.ts
/authentication
deno.json
server.ts
5 Replies
Kedi
Kedi2w ago
It is really frustrating, I think u should open an issue, the only solution I found, was to export just one file as the docu says (one file per workspace), which is very limiting unlike for example pnpm workspaces
Kedi
Kedi2w ago
GitHub
Allow multiple exports in Deno Workspaces · Issue #28019 · denoland...
Currently, Deno workspaces only allow a single "exports" entry per workspace member (deno.json). This forces monorepo packages to expose a single entry point, unlike tools like pnpm that ...
Kedi
Kedi2w ago
consider mentioning ur problem also there @Rob S Deno workspaces supports the same behaviour as Pnpm workspaces:
"name": "@repo/core",
"exports": {
"./utils": "./utils/mod.ts",
"./services": "./services/services.ts",
"./errors": "./services/errors.ts",
"./types": "./types/mod.ts",
}
"name": "@repo/core",
"exports": {
"./utils": "./utils/mod.ts",
"./services": "./services/services.ts",
"./errors": "./services/errors.ts",
"./types": "./types/mod.ts",
}
the confusion is just due to lacking of documentation
Rob S
Rob SOP2w ago
You are champion, Kedi!
Kedi
Kedi2w ago
thanks I was also looking for a solution hahaha

Did you find this page helpful?