From d5444c6aa6defc354a40b828d7d2f07374436607 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Fri, 7 Nov 2025 22:01:10 +0100 Subject: [PATCH 01/14] chore: use ci for prs --- .github/workflows/ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa086273..562d2a53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,6 @@ on: branches: - dev pull_request: - branches: - - dev permissions: contents: read @@ -20,21 +18,21 @@ jobs: strategy: matrix: - node-version: [22.x] + node-version: [22.x, 24.x, 25.x] steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 with: version: 10.17.0+sha512.fce8a3dd29a4ed2ec566fb53efbb04d8c44a0f05bc6f24a73046910fb9c3ce7afa35a0980500668fa3573345bd644644fa98338fa168235c80f4aa17aa17fbef - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: cache: "pnpm" check-latest: true From d781d446429628142806f761de9aa6184c3ab620 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Fri, 7 Nov 2025 22:06:32 +0100 Subject: [PATCH 02/14] add faketty --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 562d2a53..2b07eb53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,5 +41,8 @@ jobs: - name: Install dependencies run: pnpm install --ignore-scripts + - name: faketty + uses: Yuri6037/Action-FakeTTY@v1.1 + - name: Run tests run: pnpm test From 30b4c233e660a8e3902825a2ab1e08d0fd44d37b Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Fri, 7 Nov 2025 22:07:50 +0100 Subject: [PATCH 03/14] another try --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b07eb53..64960a69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,4 +45,5 @@ jobs: uses: Yuri6037/Action-FakeTTY@v1.1 - name: Run tests + shell: 'script --return --quiet --command "bash {0}"' run: pnpm test From 5f80bc174ee88fde9a88e2f3ee96454faea3746b Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Fri, 7 Nov 2025 22:09:41 +0100 Subject: [PATCH 04/14] remove faketty --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64960a69..45a7b2d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,9 +41,6 @@ jobs: - name: Install dependencies run: pnpm install --ignore-scripts - - name: faketty - uses: Yuri6037/Action-FakeTTY@v1.1 - - name: Run tests shell: 'script --return --quiet --command "bash {0}"' run: pnpm test From f841b45d0f33b937aa98f0aca5d82a45562f5f5a Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Mon, 24 Nov 2025 22:27:37 +0100 Subject: [PATCH 05/14] fix: tests --- examples/vue-vanilla-ts/server.test.ts | 2 +- packages/fastify-react/rendering.js | 4 +-- packages/fastify-vite/mode/production.js | 35 ++++++++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/examples/vue-vanilla-ts/server.test.ts b/examples/vue-vanilla-ts/server.test.ts index 541a40f2..ec20ba6e 100644 --- a/examples/vue-vanilla-ts/server.test.ts +++ b/examples/vue-vanilla-ts/server.test.ts @@ -1,6 +1,6 @@ import test from 'node:test' import { makeBuildTest, makeIndexTest } from '../test-factories.mjs' -import { main } from './server.js' +import { main } from './src/server.ts' const cwd = import.meta.dirname diff --git a/packages/fastify-react/rendering.js b/packages/fastify-react/rendering.js index 490b406b..9f41ab76 100644 --- a/packages/fastify-react/rendering.js +++ b/packages/fastify-react/rendering.js @@ -13,7 +13,7 @@ import { createHtmlTemplates } from './templating.js' // from the renderToPipeableStream() onShellReady event export function onShellReady(app) { const duplex = new Minipass() - return new Promise((resolve, reject) => { + return new Promise((resolve) => { try { const pipeable = renderToPipeableStream(app, { onShellReady() { @@ -30,7 +30,7 @@ export function onShellReady(app) { // from the renderToPipeableStream() onAllReady event export function onAllReady(app) { const duplex = new Minipass() - return new Promise((resolve, reject) => { + return new Promise((resolve) => { try { const pipeable = renderToPipeableStream(app, { onAllReady() { diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 81edf778..38721d3a 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -1,4 +1,4 @@ -const { join, resolve } = require('node:path') +const { join, resolve, isAbsolute } = require('node:path') const FastifyStatic = require('@fastify/static') const { parse, resolveIfRelative, read, exists } = require('../ioutils.cjs') @@ -17,6 +17,10 @@ function fileUrl(str) { return encodeURI(`file://${pathName}`) } +function adaptPath(path) { + return process.platform === 'win32' ? new URL(fileUrl(path)) : path +} + async function setup(config) { const { spa, vite } = config let clientOutDir @@ -124,16 +128,26 @@ async function setup(config) { return { client, routes: client?.routes } - async function loadBundle(viteRoot, distOutDir, entryPath) { + function retrievePath(viteConfig, env, serverFile) { + const viteRoot = viteConfig.root + const distOutDir = viteConfig.fastify.outDirs[env] + if (viteConfig.fastify.usePathsRelativeToAppRoot) { + return resolve(distOutDir, serverFile) + } + if (isAbsolute(distOutDir)) { + return resolve(distOutDir, serverFile) + } + return resolve(viteRoot, distOutDir, serverFile) + } + + async function loadBundle(viteConfig, env, entryPath) { const parsedNamed = parse(entryPath).name const bundleFiles = [`${parsedNamed}.js`, `${parsedNamed}.mjs`] let bundlePath for (const serverFile of bundleFiles) { + const path = retrievePath(viteConfig, env, serverFile) // Use file path on Windows - bundlePath = - process.platform === 'win32' - ? new URL(fileUrl(resolve(viteRoot, distOutDir, serverFile))) - : resolve(viteRoot, distOutDir, serverFile) + bundlePath = adaptPath(path) if (exists(bundlePath)) { break } @@ -164,18 +178,15 @@ async function setup(config) { ssrManifestPath = manifestPath } } - const ssrManifest = - process.platform === 'win32' - ? new URL(fileUrl(ssrManifestPath)) - : ssrManifestPath + const ssrManifest = adaptPath(ssrManifestPath) const entries = {} for (const [env, entryPath] of Object.entries( config.vite.fastify.entryPaths, )) { entries[env] = await loadBundle( - config.vite.root, - config.vite.fastify.outDirs[env], + config.vite, + env, entryPath, ) } From ffcb1a3829a2a4c0bb6d613b1d00ccb54f358975 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:29:48 +0100 Subject: [PATCH 06/14] Update packages/fastify-vite/mode/production.js Signed-off-by: Aras Abbasi --- packages/fastify-vite/mode/production.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 38721d3a..efda5c65 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -129,7 +129,6 @@ async function setup(config) { return { client, routes: client?.routes } function retrievePath(viteConfig, env, serverFile) { - const viteRoot = viteConfig.root const distOutDir = viteConfig.fastify.outDirs[env] if (viteConfig.fastify.usePathsRelativeToAppRoot) { return resolve(distOutDir, serverFile) @@ -137,7 +136,7 @@ async function setup(config) { if (isAbsolute(distOutDir)) { return resolve(distOutDir, serverFile) } - return resolve(viteRoot, distOutDir, serverFile) + return resolve(viteConfig.root, distOutDir, serverFile) } async function loadBundle(viteConfig, env, entryPath) { From 92a42621ef63eb26ac405ae41da9a132e3fb8325 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:30:36 +0100 Subject: [PATCH 07/14] Update packages/fastify-vite/mode/production.js Signed-off-by: Aras Abbasi --- packages/fastify-vite/mode/production.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index efda5c65..49ada34f 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -17,9 +17,9 @@ function fileUrl(str) { return encodeURI(`file://${pathName}`) } -function adaptPath(path) { - return process.platform === 'win32' ? new URL(fileUrl(path)) : path -} +const adaptPath = process.platform === 'win32' + ? (path) => new URL(fileUrl(path)) + : (path) => path async function setup(config) { const { spa, vite } = config From 2756b6deede3ae8c6cb57bf429509b724db28b23 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:44:27 +0100 Subject: [PATCH 08/14] partial revert --- packages/fastify-vite/mode/production.js | 38 +++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 49ada34f..8d1a7f45 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -17,10 +17,6 @@ function fileUrl(str) { return encodeURI(`file://${pathName}`) } -const adaptPath = process.platform === 'win32' - ? (path) => new URL(fileUrl(path)) - : (path) => path - async function setup(config) { const { spa, vite } = config let clientOutDir @@ -128,25 +124,22 @@ async function setup(config) { return { client, routes: client?.routes } - function retrievePath(viteConfig, env, serverFile) { - const distOutDir = viteConfig.fastify.outDirs[env] - if (viteConfig.fastify.usePathsRelativeToAppRoot) { - return resolve(distOutDir, serverFile) - } - if (isAbsolute(distOutDir)) { - return resolve(distOutDir, serverFile) - } - return resolve(viteConfig.root, distOutDir, serverFile) - } - - async function loadBundle(viteConfig, env, entryPath) { + async function loadBundle(viteConfig, distOutDir, entryPath) { const parsedNamed = parse(entryPath).name const bundleFiles = [`${parsedNamed}.js`, `${parsedNamed}.mjs`] let bundlePath + for (const serverFile of bundleFiles) { - const path = retrievePath(viteConfig, env, serverFile) - // Use file path on Windows - bundlePath = adaptPath(path) + if (viteConfig.fastify.usePathsRelativeToAppRoot) { + bundlePath = resolve(distOutDir, serverFile) + } else if (isAbsolute(distOutDir)) { + bundlePath = resolve(distOutDir, serverFile) + } else { + bundlePath = resolve(viteConfig.root, distOutDir, serverFile) + } + bundlePath = process.platform === 'win32' + ? (path) => new URL(fileUrl(path)) + : (path) => path if (exists(bundlePath)) { break } @@ -177,7 +170,10 @@ async function setup(config) { ssrManifestPath = manifestPath } } - const ssrManifest = adaptPath(ssrManifestPath) + const ssrManifest = + process.platform === 'win32' + ? new URL(fileUrl(ssrManifestPath)) + : ssrManifestPath const entries = {} for (const [env, entryPath] of Object.entries( @@ -185,7 +181,7 @@ async function setup(config) { )) { entries[env] = await loadBundle( config.vite, - env, + config.vite.fastify.outDirs[env], entryPath, ) } From 9b8a04e59e6f2f2a6d133c784b8d40f19a4a6b91 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:46:57 +0100 Subject: [PATCH 09/14] fix? --- packages/fastify-vite/mode/production.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 8d1a7f45..4ef77a36 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -137,9 +137,9 @@ async function setup(config) { } else { bundlePath = resolve(viteConfig.root, distOutDir, serverFile) } - bundlePath = process.platform === 'win32' - ? (path) => new URL(fileUrl(path)) - : (path) => path + if (process.platform === 'win32') { + bundlePath = new URL(fileUrl(bundlePath)) + } if (exists(bundlePath)) { break } From 7284568cac4dbff40d5ac7f1772e47f11146502d Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:51:48 +0100 Subject: [PATCH 10/14] Apply suggestion from @Uzlopak Signed-off-by: Aras Abbasi --- packages/fastify-vite/mode/production.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 4ef77a36..3563e1c6 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -171,7 +171,7 @@ async function setup(config) { } } const ssrManifest = - process.platform === 'win32' + process.platform === 'win32' ? new URL(fileUrl(ssrManifestPath)) : ssrManifestPath From 8c92d82e882c98eabd76e7d10ead89dbb3455086 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:53:19 +0100 Subject: [PATCH 11/14] test on more os --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45a7b2d5..628dfdb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ permissions: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.runs-on }} permissions: contents: read @@ -19,6 +19,7 @@ jobs: strategy: matrix: node-version: [22.x, 24.x, 25.x] + runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest'] steps: - name: Checkout code From d056f23cb2a0e140d44676255306a8628adb649a Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:57:21 +0100 Subject: [PATCH 12/14] no macos for now --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 628dfdb5..4a092e70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: node-version: [22.x, 24.x, 25.x] - runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest'] + runs-on: ['ubuntu-latest', 'windows-latest'] steps: - name: Checkout code From f705b2a75be2dc9a111424442e8116262aafaa35 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 24 Nov 2025 23:59:42 +0100 Subject: [PATCH 13/14] ubuntu only for now.... --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a092e70..71c3d9de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: node-version: [22.x, 24.x, 25.x] - runs-on: ['ubuntu-latest', 'windows-latest'] + runs-on: ['ubuntu-latest'] steps: - name: Checkout code From 5966193c44557d2d924b47f1355fc1652361bf1a Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Tue, 25 Nov 2025 00:13:57 +0100 Subject: [PATCH 14/14] fix? --- packages/fastify-vite/mode/production.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/fastify-vite/mode/production.js b/packages/fastify-vite/mode/production.js index 3563e1c6..e9ab59c8 100644 --- a/packages/fastify-vite/mode/production.js +++ b/packages/fastify-vite/mode/production.js @@ -127,19 +127,22 @@ async function setup(config) { async function loadBundle(viteConfig, distOutDir, entryPath) { const parsedNamed = parse(entryPath).name const bundleFiles = [`${parsedNamed}.js`, `${parsedNamed}.mjs`] + + const fixWin32Path = process.platform === 'win32' + ? (filePath) => new URL(fileUrl(filePath)) + : (filePath) => filePath + + const getBundlePath = ( + viteConfig.fastify.usePathsRelativeToAppRoot || + isAbsolute(distOutDir) + ) + ? (serverFile) => fixWin32Path(resolve(distOutDir, serverFile)) + : (serverFile) => fixWin32Path(resolve(viteConfig.root, distOutDir, serverFile)) + let bundlePath for (const serverFile of bundleFiles) { - if (viteConfig.fastify.usePathsRelativeToAppRoot) { - bundlePath = resolve(distOutDir, serverFile) - } else if (isAbsolute(distOutDir)) { - bundlePath = resolve(distOutDir, serverFile) - } else { - bundlePath = resolve(viteConfig.root, distOutDir, serverFile) - } - if (process.platform === 'win32') { - bundlePath = new URL(fileUrl(bundlePath)) - } + bundlePath = getBundlePath(serverFile) if (exists(bundlePath)) { break }