sergees
sergees6mo ago

Using fresh inside an existing deno folder

I have an existing deno project with deno.jsonc at the root and would like to add a web app as a subfolder. When I do this, vscode picks up the settings from the root deno.jsonc (instead of the one generated by fresh cli), so I see a lot of messages like this: “Relative import path "$std/dotenv/load.ts" not prefixed with / or ./ or ../ and not in import map from” What’s the recommended way to do this, i.e. to have multiple deno project inside the same root folder?
5 Replies
sergees
sergees6mo ago
I’ve tried to do this: merged the contents of my parent deno.jsonc and from the one in fresh subfolder, also changed the start command as described here: https://fresh.deno.dev/docs/examples/changing-the-src-dir
Changing the source directory | Fresh docs
Change the source directory to effectively manage your project.
sergees
sergees6mo ago
Seems to be working with lots of deprecation warnings though (1.40.2)
Deno AI Helper
Deno AI Helper6mo ago
To have multiple Deno projects within the same root folder, you can utilize the feature of partially enabling Deno in a workspace. This allows you to have a mixed Deno project where some workspace folders are Deno-enabled and some are not. This is particularly useful when you have a project with different components, such as a front-end and a back-end, and you want different configurations for each. Here's what you can do according to the documentation: 1. Create a new workspace or add a folder to an existing workspace: You can organize your project into different folders, each with its own deno.jsonc configuration if needed. 2. Configure the settings for each folder: In the settings, you can configure one of the folders to have deno.enable set to true and one set to false. This will ensure that the Deno language server applies diagnostics only to the enabled folders, while the other folder will use the built-in TypeScript compiler of VSCode to supply diagnostics for TypeScript and JavaScript files. 3. Use the Deno: Enable Paths setting: If you want to enable Deno only for specific sub-paths within a workspace folder, you can use the Deno: Enable Paths setting (or deno.enablePaths if manually editing the settings JSON). This allows you to specify which paths should be Deno-enabled. For your specific case, you can place your web app in a subfolder and enable Deno only for that subfolder. Make sure that the deno.jsonc file in your web app's subfolder is correctly configured for the Fresh framework, and use the Deno: Enable Paths setting to point to your web app's subfolder. Here's an example of how you might structure your project: ``` project/ ├── deno.jsonc (root configuration) ├── some_other_deno_project/ │ └── deno.jsonc
Deno AI Helper
Deno AI Helper6mo ago
(specific configuration for this sub-project) └── web_app/ ├── deno.jsonc (Fresh configuration) └── ... (other Fresh project files) `` In this structure, you would enable Deno for the web_app/ directory specifically, and ensure that the settings in web_app/deno.jsonc` are respected when working within that directory in VSCode. Remember to check your VSCode workspace settings to ensure that the correct Deno configurations are applied to the respective folders. 🦕
Ooker
Ooker6mo ago
In my case, if the path contains a space or a non-ASCII character then it yields this error:
Error: The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../
Error: The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../
I haven't figured out how to escape those characters.
More Posts