@fastify/react 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +28 -28
- package/plugin/virtual.js +9 -11
- package/rendering.js +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<br>
|
|
2
2
|
|
|
3
|
-
**`@fastify/react`** is the official [**`@fastify/vite`**](https://fastify-vite
|
|
3
|
+
**`@fastify/react`** is the official [**`@fastify/vite`**](https://github.com/fastify/fastify-vite) renderer for React.
|
|
4
4
|
|
|
5
|
-
See the [documentation suite](https://fastify-vite
|
|
5
|
+
See the [documentation suite](https://fastify.github.io/fastify-vite/react/) to learn more.
|
package/package.json
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"type": "module",
|
|
3
|
-
"main": "index.js",
|
|
4
2
|
"name": "@fastify/react",
|
|
3
|
+
"version": "1.1.2",
|
|
5
4
|
"description": "The official @fastify/vite renderer for React",
|
|
6
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fastify",
|
|
7
|
+
"vite",
|
|
8
|
+
"react"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://fastify.github.io/fastify-vite/react/",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/fastify/fastify-vite/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/fastify/fastify-vite.git"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./plugin": "./plugin/index.js",
|
|
24
|
+
"./client": "./client.js",
|
|
25
|
+
"./server": "./server.js"
|
|
26
|
+
},
|
|
7
27
|
"files": [
|
|
8
28
|
"plugin/index.js",
|
|
9
29
|
"plugin/parsers.js",
|
|
@@ -39,29 +59,22 @@
|
|
|
39
59
|
"server.js",
|
|
40
60
|
"templating.js"
|
|
41
61
|
],
|
|
42
|
-
"license": "MIT",
|
|
43
|
-
"exports": {
|
|
44
|
-
".": "./index.js",
|
|
45
|
-
"./plugin": "./plugin/index.js",
|
|
46
|
-
"./client": "./client.js",
|
|
47
|
-
"./server": "./server.js"
|
|
48
|
-
},
|
|
49
62
|
"dependencies": {
|
|
50
63
|
"@unhead/react": "^2.0.8",
|
|
51
64
|
"acorn": "^8.14.1",
|
|
52
65
|
"acorn-strip-function": "^1.2.0",
|
|
53
66
|
"acorn-walk": "^8.3.4",
|
|
54
|
-
"devalue": "
|
|
67
|
+
"devalue": "^5.6.1",
|
|
55
68
|
"history": "latest",
|
|
56
69
|
"html-rewriter-wasm": "^0.4.1",
|
|
57
70
|
"minipass": "latest",
|
|
58
71
|
"mlly": "^1.7.4",
|
|
59
|
-
"react": "^19.
|
|
60
|
-
"react-dom": "^19.
|
|
61
|
-
"react-router": "^7.5.
|
|
72
|
+
"react": "^19.2.3",
|
|
73
|
+
"react-dom": "^19.2.3",
|
|
74
|
+
"react-router": "^7.5.1",
|
|
62
75
|
"valtio": "latest",
|
|
63
76
|
"youch": "^3.3.4",
|
|
64
|
-
"@fastify/vite": "^8.1
|
|
77
|
+
"@fastify/vite": "^8.2.1"
|
|
65
78
|
},
|
|
66
79
|
"devDependencies": {
|
|
67
80
|
"@biomejs/biome": "^1.9.2"
|
|
@@ -69,19 +82,6 @@
|
|
|
69
82
|
"publishConfig": {
|
|
70
83
|
"access": "public"
|
|
71
84
|
},
|
|
72
|
-
"repository": {
|
|
73
|
-
"type": "git",
|
|
74
|
-
"url": "git+https://github.com/fastify/fastify-vite.git"
|
|
75
|
-
},
|
|
76
|
-
"keywords": [
|
|
77
|
-
"fastify",
|
|
78
|
-
"vite",
|
|
79
|
-
"react"
|
|
80
|
-
],
|
|
81
|
-
"bugs": {
|
|
82
|
-
"url": "https://github.com/fastify/fastify-vite/issues"
|
|
83
|
-
},
|
|
84
|
-
"homepage": "https://fastify-vite.dev/react/",
|
|
85
85
|
"scripts": {
|
|
86
86
|
"lint": "biome check --apply-unsafe ."
|
|
87
87
|
}
|
package/plugin/virtual.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'node:fs'
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, resolve } from 'node:path'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
4
3
|
import { findExports } from 'mlly'
|
|
5
4
|
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
7
5
|
|
|
8
|
-
const virtualRoot = resolve(
|
|
9
|
-
const virtualRootTS = resolve(
|
|
6
|
+
const virtualRoot = resolve(import.meta.dirname, '..', 'virtual')
|
|
7
|
+
const virtualRootTS = resolve(import.meta.dirname, '..', 'virtual-ts')
|
|
10
8
|
|
|
11
9
|
const virtualModules = [
|
|
12
10
|
'mount.js',
|
|
@@ -36,7 +34,7 @@ const virtualModulesTS = [
|
|
|
36
34
|
|
|
37
35
|
export const prefix = /^\/?\$app\//
|
|
38
36
|
|
|
39
|
-
export async function resolveId
|
|
37
|
+
export async function resolveId(id) {
|
|
40
38
|
// Paths are prefixed with .. on Windows by the glob import
|
|
41
39
|
if (process.platform === 'win32' && /^\.\.\/[C-Z]:/.test(id)) {
|
|
42
40
|
return id.substring(3)
|
|
@@ -54,7 +52,7 @@ export async function resolveId (id) {
|
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
export function loadVirtualModule
|
|
55
|
+
export function loadVirtualModule(virtualInput) {
|
|
58
56
|
let virtual = virtualInput
|
|
59
57
|
if (!virtualModules.includes(virtual) && !virtualModulesTS.includes(virtual)) {
|
|
60
58
|
return
|
|
@@ -96,12 +94,12 @@ virtualModules.includes = function (virtual) {
|
|
|
96
94
|
return false
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
function loadVirtualModuleOverride
|
|
97
|
+
function loadVirtualModuleOverride(viteProjectRoot, virtualInput) {
|
|
100
98
|
let virtual = virtualInput
|
|
101
99
|
if (!virtualModules.includes(virtual) && !virtualModulesTS.includes(virtual)) {
|
|
102
100
|
return
|
|
103
101
|
}
|
|
104
|
-
let overridePath = resolve(viteProjectRoot, virtual)
|
|
102
|
+
let overridePath = resolve(viteProjectRoot, virtual)
|
|
105
103
|
if (existsSync(overridePath)) {
|
|
106
104
|
return overridePath
|
|
107
105
|
}
|
|
@@ -111,14 +109,14 @@ function loadVirtualModuleOverride (viteProjectRoot, virtualInput) {
|
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
export function loadSource
|
|
112
|
+
export function loadSource(id) {
|
|
115
113
|
const filePath = id
|
|
116
114
|
.replace(/\?client$/, '')
|
|
117
115
|
.replace(/\?server$/, '')
|
|
118
116
|
return readFileSync(filePath, 'utf8')
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
export function createPlaceholderExports
|
|
119
|
+
export function createPlaceholderExports(source) {
|
|
122
120
|
let pExports = ''
|
|
123
121
|
for (const exp of findExports(source)) {
|
|
124
122
|
switch (exp.type) {
|
package/rendering.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createHtmlTemplates } from './templating.js'
|
|
|
13
13
|
// from the renderToPipeableStream() onShellReady event
|
|
14
14
|
export function onShellReady(app) {
|
|
15
15
|
const duplex = new Minipass()
|
|
16
|
-
return new Promise((resolve
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
17
|
try {
|
|
18
18
|
const pipeable = renderToPipeableStream(app, {
|
|
19
19
|
onShellReady() {
|
|
@@ -30,7 +30,7 @@ export function onShellReady(app) {
|
|
|
30
30
|
// from the renderToPipeableStream() onAllReady event
|
|
31
31
|
export function onAllReady(app) {
|
|
32
32
|
const duplex = new Minipass()
|
|
33
|
-
return new Promise((resolve
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
34
|
try {
|
|
35
35
|
const pipeable = renderToPipeableStream(app, {
|
|
36
36
|
onAllReady() {
|