@fastify/react 1.1.0-beta.1 → 1.1.1
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 +7 -7
- package/plugin/virtual.js +9 -11
- package/LICENSE +0 -21
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://github.com/fastify/fastify-vite) to learn more.
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"lint": "biome check --apply-unsafe ."
|
|
4
|
+
},
|
|
2
5
|
"type": "module",
|
|
3
6
|
"main": "index.js",
|
|
4
7
|
"name": "@fastify/react",
|
|
5
8
|
"description": "The official @fastify/vite renderer for React",
|
|
6
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.1",
|
|
7
10
|
"files": [
|
|
8
11
|
"plugin/index.js",
|
|
9
12
|
"plugin/parsers.js",
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
"./server": "./server.js"
|
|
48
51
|
},
|
|
49
52
|
"dependencies": {
|
|
53
|
+
"@fastify/vite": "workspace:^",
|
|
50
54
|
"@unhead/react": "^2.0.8",
|
|
51
55
|
"acorn": "^8.14.1",
|
|
52
56
|
"acorn-strip-function": "^1.2.0",
|
|
@@ -60,8 +64,7 @@
|
|
|
60
64
|
"react-dom": "^19.1.0",
|
|
61
65
|
"react-router": "^7.5.0",
|
|
62
66
|
"valtio": "latest",
|
|
63
|
-
"youch": "^3.3.4"
|
|
64
|
-
"@fastify/vite": "^8.1.2"
|
|
67
|
+
"youch": "^3.3.4"
|
|
65
68
|
},
|
|
66
69
|
"devDependencies": {
|
|
67
70
|
"@biomejs/biome": "^1.9.2"
|
|
@@ -81,8 +84,5 @@
|
|
|
81
84
|
"bugs": {
|
|
82
85
|
"url": "https://github.com/fastify/fastify-vite/issues"
|
|
83
86
|
},
|
|
84
|
-
"homepage": "https://fastify-vite
|
|
85
|
-
"scripts": {
|
|
86
|
-
"lint": "biome check --apply-unsafe ."
|
|
87
|
-
}
|
|
87
|
+
"homepage": "https://github.com/fastify/fastify-vite/tree/main/packages/fastify-react"
|
|
88
88
|
}
|
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/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021-present Jonas Galvez
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|