Skip to content

Commit

Permalink
pathToFileURL
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Dec 18, 2023
1 parent d1c7f90 commit 42d33b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 7 additions & 5 deletions packages/vite/src/buildRouteManifest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs/promises'
import path from 'path'
import fs from 'node:fs/promises'
import path from 'node:path'
import url from 'node:url'

import type { Manifest as ViteBuildManifest } from 'vite'

Expand All @@ -13,10 +14,11 @@ import type { RWRouteManifest } from './types'
* Generate a route manifest file for the web server side.
*/
export async function buildRouteManifest() {
const buildManifestUrl = url.pathToFileURL(
path.join(getPaths().web.dist, 'client-build-manifest.json')
).href
const clientBuildManifest: ViteBuildManifest = (
await import(path.join(getPaths().web.dist, 'client-build-manifest.json'), {
with: { type: 'json' },
})
await import(buildManifestUrl, { with: { type: 'json' } })
).default

const routesList = getProjectRoutes()
Expand Down
13 changes: 8 additions & 5 deletions packages/vite/src/runFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// UPDATE: We decided to name the package @redwoodjs/web-server instead of
// fe-server. And it's already created, but this hasn't been moved over yet.

import path from 'path'
import path from 'node:path'
import url from 'node:url'

import { createServerAdapter } from '@whatwg-node/server'
// @ts-expect-error We will remove dotenv-defaults from this package anyway
Expand Down Expand Up @@ -60,14 +61,16 @@ export async function runFeServer() {
}
}

const routeManifestUrl = url.pathToFileURL(rwPaths.web.routeManifest).href
const routeManifest: RWRouteManifest = (
await import(rwPaths.web.routeManifest, { with: { type: 'json' } })
await import(routeManifestUrl, { with: { type: 'json' } })
).default

const buildManifestUrl = url.pathToFileURL(
path.join(rwPaths.web.dist, 'client-build-manifest.json')
).href
const buildManifest: ViteBuildManifest = (
await import(path.join(rwPaths.web.dist, 'client-build-manifest.json'), {
with: { type: 'json' },
})
await import(buildManifestUrl, { with: { type: 'json' } })
).default

if (rwConfig.experimental?.rsc?.enabled) {
Expand Down

0 comments on commit 42d33b8

Please sign in to comment.