Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,35 @@ on:
branches:
- dev
pull_request:
branches:
- dev

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}

permissions:
contents: read

strategy:
matrix:
node-version: [22.x]
node-version: [22.x, 24.x, 25.x]
runs-on: ['ubuntu-latest']

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
Expand All @@ -44,4 +43,5 @@ jobs:
run: pnpm install --ignore-scripts

- name: Run tests
shell: 'script --return --quiet --command "bash {0}"'
run: pnpm test
2 changes: 1 addition & 1 deletion examples/vue-vanilla-ts/server.test.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/fastify-react/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
25 changes: 17 additions & 8 deletions packages/fastify-vite/mode/production.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down Expand Up @@ -124,16 +124,25 @@ async function setup(config) {

return { client, routes: client?.routes }

async function loadBundle(viteRoot, distOutDir, entryPath) {
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
Comment on lines +131 to +133
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be extracted outside of this function?
We are re-creating the fix function on every invocation of loadBundle, but I don't think that the platform will change once is executed the first time.


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) {
// Use file path on Windows
bundlePath =
process.platform === 'win32'
? new URL(fileUrl(resolve(viteRoot, distOutDir, serverFile)))
: resolve(viteRoot, distOutDir, serverFile)
bundlePath = getBundlePath(serverFile)
if (exists(bundlePath)) {
break
}
Expand Down Expand Up @@ -174,7 +183,7 @@ async function setup(config) {
config.vite.fastify.entryPaths,
)) {
entries[env] = await loadBundle(
config.vite.root,
config.vite,
config.vite.fastify.outDirs[env],
entryPath,
)
Expand Down