From 9685488451f1330c4f2021ecdf9aaf31a6cb02d8 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Tue, 2 Sep 2025 15:35:02 +0200 Subject: [PATCH] docs: add troubleshooting page (#3313) --- docs/canary/advanced/troubleshooting.md | 56 +++++++++++++++++++++++++ docs/toc.ts | 1 + 2 files changed, 57 insertions(+) create mode 100644 docs/canary/advanced/troubleshooting.md diff --git a/docs/canary/advanced/troubleshooting.md b/docs/canary/advanced/troubleshooting.md new file mode 100644 index 00000000..f981e3e5 --- /dev/null +++ b/docs/canary/advanced/troubleshooting.md @@ -0,0 +1,56 @@ +--- +description: | + Troubleshooting Fresh applications. +--- + +This site contains some tips to troubleshoot your app in case something doesn't +work as expected. + +## Update Fresh + +The easiest way to resolve most issues is to ensure that you're on the +[latest version](https://jsr.io/@fresh/core/versions) of Fresh. We continuously +work on Fresh and there is a good chance that the issue you're running into has +already been resolved in the latest version of Fresh. + +## Don't use esm.sh + +Fresh 1.x heavily relied on [esm.sh](https://esm.sh/) to be able to use npm +packages with Fresh. This continued a bit through the early alpha versions of +Fresh 2. With the move to [`vite`](https://vite.dev/) this is not necessary +anymore and you should use the relevant npm package directly from npm. + +```diff deno.json + { + "imports": { +- "cowsay": "https://esm.sh/cowsay" ++ "cowsay": "npm:cowsay@^1.6.0" + } + } +``` + +> [info]: Not using `esm.sh` solves many issues and footguns with duplicate +> Preact versions in your app. If you're seeing strange JavaScript errors in the +> browser in your app than this is likely the cause. + +## Attach a debugger + +To attach a debugger to vite with Deno run this command: + +```sh Terminal +deno run -A --inspect npm:vite +# or +deno run -A --inspect-brk npm:vite +``` + +## Debug vite resolution + +To debug vite resolution issues run vite with the `--debug` flag. This will +print lots of debugging information to the terminal. + +## Debug vite transformations + +To debug vite plugin transformations, use +[`vite-plugin-inspect`](https://github.com/antfu-collective/vite-plugin-inspect). +This gives you a UI that shows all transformations of all plugins for every +file. diff --git a/docs/toc.ts b/docs/toc.ts index 006fc889..e52c373a 100644 --- a/docs/toc.ts +++ b/docs/toc.ts @@ -55,6 +55,7 @@ const toc: RawTableOfContents = { ["environment-variables", "Environment Variables", "link:canary"], ["head", "Modifying ", "link:canary"], ["vite", "Vite Plugin Options", "link:canary"], + ["troubleshooting", "Troubleshooting", "link:canary"], ["builder", "Builder (Legacy)", "link:canary"], ], },