BOLL
BOLL2mo ago

Run Fresh in subfolder with root deno.json

I'm using Fresh in a project where I have a big pile of other code in a separate folder. It works running the project if I have the deno.json file in the Fresh folder, but then formatting etc won't apply to code in the other folder. Considering this, I am trying to get workspaces working, but I'm kind of stuck. If I make a root file and try to include Fresh as a workspace, the imports in it then fails due to not having been prefixed with ./ or ../, if I move the imports to the root deno.json I get an error that the Fresh deno.json requires imports to be in there to run at all, but then those would override the ones in the root. I'm getting very confused by all of this. Is it even possible to have a Fresh instance as a workspace folder? I'm basically looking to do the below, and I'm struggling to keep my sanity:
/
├── deno.json
├── fresh/
│ ├── deno.json
│ └── main.ts
└── other/
├── deno.json
└── main.ts
/
├── deno.json
├── fresh/
│ ├── deno.json
│ └── main.ts
└── other/
├── deno.json
└── main.ts
But yeah, I'm kind of at a moment 22 here and not sure how to get that to work. If possible I want to have separated imports between fresh and other, thus why it's split up like this, but again I'm struggling to actually get Fresh to work while in a workspace.
4 Replies
BOLL
BOLLOP2mo ago
The first error when putting Fresh in a workspace:
error: Relative import path "preact" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs"
at https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:46
error: Relative import path "preact" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs"
at https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:46
And the other error when I move the imports to the root config:
error: Uncaught (in promise) Error: deno.json must contain an 'importMap' or 'imports' property.
throw new Error(
^
at getInternalFreshState (https://deno.land/x/fresh@1.7.3/src/server/config.ts:53:11)
at eventLoopTick (ext:core/01_core.js:175:7)
at async dev (https://deno.land/x/fresh@1.7.3/src/dev/dev_command.ts:51:19)
at async file:///D:/apps/desbot_wip/server/dev.ts:10:1
error: Uncaught (in promise) Error: deno.json must contain an 'importMap' or 'imports' property.
throw new Error(
^
at getInternalFreshState (https://deno.land/x/fresh@1.7.3/src/server/config.ts:53:11)
at eventLoopTick (ext:core/01_core.js:175:7)
at async dev (https://deno.land/x/fresh@1.7.3/src/dev/dev_command.ts:51:19)
at async file:///D:/apps/desbot_wip/server/dev.ts:10:1
Posted an issue on the repo, because why not. I'm starting to think this is just not possible to do right now, so I should just give up and put everything in the Fresh folder and be done with it.
bartlomieju
bartlomieju2mo ago
@marvinh. can you please take a look?
marvinh.
marvinh.2mo ago
responded on GH
BOLL
BOLLOP2mo ago
Ah, the difference to what I did was to move the whole Fresh config file to the root. I specifically wanted to split up the imports so started with a fresh config in the root and tried to move over as few parts as possible while retaining the config in the Fresh folder. I'm just home for a short while to look at this but will be back tonight. (Sweden) I did what was mentioned in the guide and closed the issue, will mark this as solved too 😛 will give up on splitting things in workspaces and just run it all through one config, it will hopefully keep me sane 🤣