devin
devin2mo ago

fresh + workspace

i have bootstrapped a fresh project inside a deno workspace. when installing at the workspace root, i get the following error:
$ deno install --allow-scripts=npm:@bufbuild/buf@1.47.2
error: Relative import path "@preact/signals-core" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs"
at https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs:2:196
$ deno install --allow-scripts=npm:@bufbuild/buf@1.47.2
error: Relative import path "@preact/signals-core" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs"
at https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs:2:196
what does this mean? here's the root deno.json (i've moved lock, compilerOptions and nodeModulesDir from the fresh project):
{
"workspace": ["./web"],
"lock": false,
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"nodeModulesDir": "auto"
}
{
"workspace": ["./web"],
"lock": false,
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"nodeModulesDir": "auto"
}
and here's the web's deno.json:
{
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
}
},
"exclude": [
"**/_fresh/*"
],
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.7.3/",
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"tailwindcss": "npm:tailwindcss@3.4.1",
"tailwindcss/": "npm:/tailwindcss@3.4.1/",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.1/plugin.js",
"$std/": "https://deno.land/std@0.216.0/"
}
}
{
"tasks": {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
}
},
"exclude": [
"**/_fresh/*"
],
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.7.3/",
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"tailwindcss": "npm:tailwindcss@3.4.1",
"tailwindcss/": "npm:/tailwindcss@3.4.1/",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.1/plugin.js",
"$std/": "https://deno.land/std@0.216.0/"
}
}
2 Replies
devin
devinOP2mo ago
my solution is highly suspect. it turns out if i clone this into the root deno.json (from web's deno.json), i resolve the error:
"imports": {
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1"
}
"imports": {
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1"
}
but why should i specify this dependency at the root? alternatively, if i start building an import map, it progresses, but gets incrementally stuck:
{
"imports": {
"preact/hooks": "https://esm.sh/preact@10.22.0/hooks",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1"
}
}
{
"imports": {
"preact/hooks": "https://esm.sh/preact@10.22.0/hooks",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1"
}
}
then complains on (and it seems to keep going...):
error: Relative import path "preact" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs"
error: Relative import path "preact" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@preact/signals@1.2.2/X-ZS8q/denonext/signals.mjs"
PIat
PIat2mo ago
I am trying to do the same but with React. I also found that copying the configuration to root helps, but importing anything like useState doesn't work

Did you find this page helpful?