From f7a2422e936ea6af8346b7c811eeeafc1cc110d4 Mon Sep 17 00:00:00 2001 From: fry69 <142489379+fry69@users.noreply.github.com> Date: Thu, 25 Sep 2025 20:54:27 +0200 Subject: [PATCH] fix: set nodeModulesDir to manual (#3493) Hopefully a less invasive fix for #3378 --------- Co-authored-by: Marvin Hagemeister --- .github/workflows/ci.yml | 3 ++ .github/workflows/deploy.yml | 3 ++ deno.json | 5 ++- deno.lock | 37 +++++++++++++++++++-- packages/examples/deno.json | 5 +++ packages/plugin-vite/src/plugins/deno.ts | 4 ++- packages/plugin-vite/src/plugins/patches.ts | 4 ++- www/utils/prism.ts | 7 ++-- 8 files changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fd277c0..885de7e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,9 @@ jobs: cache: true deno-version: ${{ matrix.deno }} + - name: Install dependencies + run: deno install + - name: Verify formatting if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x' run: deno fmt --check diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 44243176..9815b742 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,9 @@ jobs: with: cache: true + - name: Run install step + run: "deno install" + - name: Build step working-directory: ./www run: "deno task build" diff --git a/deno.json b/deno.json index bae8fa25..dd7e63ca 100644 --- a/deno.json +++ b/deno.json @@ -1,5 +1,5 @@ { - "nodeModulesDir": "auto", + "nodeModulesDir": "manual", "workspace": [ "./packages/*", "./www" @@ -48,7 +48,10 @@ "@std/http": "jsr:@std/http@^1.0.15", "@std/uuid": "jsr:@std/uuid@^1.0.7", "@supabase/postgrest-js": "npm:@supabase/postgrest-js@^1.21.4", + "@types/mime-db": "npm:@types/mime-db@^1.43.6", "@types/node": "npm:@types/node@^24.3.0", + "@types/pg": "npm:@types/pg@^8.15.5", + "@types/prismjs": "npm:@types/prismjs@^1.26.5", "docsearch": "https://esm.sh/@docsearch/js@3.5.2?target=es2020", "esbuild": "npm:esbuild@0.25.7", "esbuild-wasm": "npm:esbuild-wasm@0.25.7", diff --git a/deno.lock b/deno.lock index ea888810..9850a590 100644 --- a/deno.lock +++ b/deno.lock @@ -72,9 +72,12 @@ "npm:@tailwindcss/postcss@^4.1.10": "4.1.13", "npm:@tailwindcss/vite@^4.1.12": "4.1.13_vite@7.1.5__@types+node@24.3.3__picomatch@4.0.3_@types+node@24.3.3", "npm:@types/babel__core@^7.20.5": "7.20.5", + "npm:@types/mime-db@^1.43.6": "1.43.6", "npm:@types/node@^24.1.0": "24.3.3", "npm:@types/node@^24.2.1": "24.3.3", "npm:@types/node@^24.3.0": "24.3.3", + "npm:@types/pg@^8.15.5": "8.15.5", + "npm:@types/prismjs@^1.26.5": "1.26.5", "npm:autoprefixer@^10.4.21": "10.4.21_postcss@8.5.6", "npm:cssnano@^6.1.2": "6.1.2_postcss@8.5.6", "npm:esbuild-wasm@0.25.7": "0.25.7", @@ -1817,12 +1820,32 @@ "@types/estree@1.0.8": { "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==" }, + "@types/mime-db@1.43.6": { + "integrity": "sha512-r2cqxAt/Eo5yWBOQie1lyM1JZFCiORa5xtLlhSZI0w8RJggBPKw8c4g/fgQCzWydaDR5bL4imnmix2d1n52iBw==" + }, + "@types/node@24.2.0": { + "integrity": "sha512-3xyG3pMCq3oYCNg7/ZP+E1ooTaGB4cG8JWRsqqOYQdbWNY4zbaV0Ennrd7stjiJEFZCaybcIgpTjJWHRfBSIDw==", + "dependencies": [ + "undici-types" + ] + }, "@types/node@24.3.3": { "integrity": "sha512-GKBNHjoNw3Kra1Qg5UXttsY5kiWMEfoHq2TmXb+b1rcm6N7B3wTrFYIf/oSZ1xNQ+hVVijgLkiDZh7jRRsh+Gw==", "dependencies": [ "undici-types" ] }, + "@types/pg@8.15.5": { + "integrity": "sha512-LF7lF6zWEKxuT3/OR8wAZGzkg4ENGXFNyiV/JeOt9z5B+0ZVwbql9McqX5c/WStFq1GaGso7H1AzP/qSzmlCKQ==", + "dependencies": [ + "@types/node@24.2.0", + "pg-protocol", + "pg-types" + ] + }, + "@types/prismjs@1.26.5": { + "integrity": "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==" + }, "ansi-regex@5.0.1": { "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, @@ -3504,7 +3527,7 @@ "vite@7.1.5_@types+node@24.3.3_picomatch@4.0.3": { "integrity": "sha512-4cKBO9wR75r0BeIWWWId9XK9Lj6La5X846Zw9dFfzMRw38IlTk2iCcUt6hsyiDRcPidc55ZParFYDXi0nXOeLQ==", "dependencies": [ - "@types/node", + "@types/node@24.3.3", "esbuild", "fdir", "picomatch@4.0.3", @@ -3516,7 +3539,7 @@ "fsevents" ], "optionalPeers": [ - "@types/node" + "@types/node@24.3.3" ], "bin": true }, @@ -3689,7 +3712,10 @@ "npm:@preact/signals@^2.2.1", "npm:@supabase/postgrest-js@^1.21.4", "npm:@tailwindcss/postcss@^4.1.10", + "npm:@types/mime-db@^1.43.6", "npm:@types/node@^24.3.0", + "npm:@types/pg@^8.15.5", + "npm:@types/prismjs@^1.26.5", "npm:esbuild-wasm@0.25.7", "npm:esbuild@0.25.7", "npm:github-slugger@2", @@ -3713,6 +3739,13 @@ "jsr:@std/encoding@^1.0.10" ] }, + "packages/examples": { + "dependencies": [ + "jsr:@fresh/core@2", + "npm:@preact/signals@^2.2.1", + "npm:preact@^10.27.0" + ] + }, "packages/fresh": { "dependencies": [ "jsr:@std/fmt@^1.0.8", diff --git a/packages/examples/deno.json b/packages/examples/deno.json index ed04a6f7..501b9612 100644 --- a/packages/examples/deno.json +++ b/packages/examples/deno.json @@ -2,6 +2,11 @@ "name": "@fresh/examples", "version": "1.0.1", "license": "MIT", + "imports": { + "fresh": "jsr:@fresh/core@^2.0.0", + "preact": "npm:preact@^10.27.0", + "@preact/signals": "npm:@preact/signals@^2.2.1" + }, "exports": { "./island": "./src/island.tsx", "./app1": "./src/app1.tsx", diff --git a/packages/plugin-vite/src/plugins/deno.ts b/packages/plugin-vite/src/plugins/deno.ts index 1f2e9988..49bb2707 100644 --- a/packages/plugin-vite/src/plugins/deno.ts +++ b/packages/plugin-vite/src/plugins/deno.ts @@ -8,11 +8,13 @@ import { } from "@deno/loader"; import * as path from "@std/path"; import * as babel from "@babel/core"; -import babelReact from "@babel/preset-react"; import { httpAbsolute } from "./patches/http_absolute.ts"; import { JS_REG, JSX_REG } from "../utils.ts"; import { builtinModules } from "node:module"; +// @ts-ignore Workaround for https://github.com/denoland/deno/issues/30850 +const { default: babelReact } = await import("@babel/preset-react"); + const BUILTINS = new Set(builtinModules); interface DenoState { diff --git a/packages/plugin-vite/src/plugins/patches.ts b/packages/plugin-vite/src/plugins/patches.ts index b5f37e82..3f5c9db0 100644 --- a/packages/plugin-vite/src/plugins/patches.ts +++ b/packages/plugin-vite/src/plugins/patches.ts @@ -2,12 +2,14 @@ import type { Plugin } from "vite"; import * as babel from "@babel/core"; import { cjsPlugin } from "./patches/commonjs.ts"; import { jsxComments } from "./patches/jsx_comment.ts"; -import babelReact from "@babel/preset-react"; import { inlineEnvVarsPlugin } from "./patches/inline_env_vars.ts"; import { removePolyfills } from "./patches/remove_polyfills.ts"; import { JS_REG, JSX_REG } from "../utils.ts"; import { codeEvalPlugin } from "./patches/code_eval.ts"; +// @ts-ignore Workaround for https://github.com/denoland/deno/issues/30850 +const { default: babelReact } = await import("@babel/preset-react"); + export function patches(): Plugin { let isDev = false; diff --git a/www/utils/prism.ts b/www/utils/prism.ts index 8389ec72..fe019263 100644 --- a/www/utils/prism.ts +++ b/www/utils/prism.ts @@ -8,13 +8,16 @@ import "prismjs/components/prism-bash.js"; import "prismjs/components/prism-yaml.js"; import "prismjs/components/prism-ignore.js"; +// deno-lint-ignore no-explicit-any +const languages = Prism.languages as any; + /** Extends `sh` with `deno` as a function token in Shell/Bash languages */ -Prism.languages.sh.deno = { +languages.sh.deno = { pattern: /(^|[\s;|&]|[<>]\()(?:deno)(?=$|[)\s;|&])/, lookbehind: true, alias: "function", }; -Prism.languages.bash.deno = Prism.languages.sh.deno; +languages.bash.deno = languages.sh.deno; /** * Adds `txt-files` language for file-structure code blocks.