@shaper.org/vite-react-plugin 1.0.21 → 1.0.22-prerelease
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/dist/index.d.mts +18 -0
- package/dist/index.mjs +25 -17
- package/package.json +11 -10
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,24 @@ declare const reactPlugin: (config: ReactPluginConfig) => ({
|
|
|
12
12
|
code: any;
|
|
13
13
|
map: null;
|
|
14
14
|
} | null>;
|
|
15
|
+
} | {
|
|
16
|
+
name: string;
|
|
17
|
+
enforce: string;
|
|
18
|
+
apply: string;
|
|
19
|
+
configResolved(resolvedConfig: vite0.ResolvedConfig): void;
|
|
20
|
+
resolveId(id: string): "virtual:routes-listening" | undefined;
|
|
21
|
+
load(id: string): string | undefined;
|
|
22
|
+
transformIndexHtml(html: string): Promise<{
|
|
23
|
+
html: string;
|
|
24
|
+
tags: {
|
|
25
|
+
tag: string;
|
|
26
|
+
injectTo: string;
|
|
27
|
+
attrs: {
|
|
28
|
+
src: string;
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
15
33
|
} | {
|
|
16
34
|
name: string;
|
|
17
35
|
enforce: string;
|
package/dist/index.mjs
CHANGED
|
@@ -37,8 +37,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/react-route-plugin.ts
|
|
40
|
-
const mainContentPath
|
|
41
|
-
const appendTo
|
|
40
|
+
const mainContentPath = join(dirname(fileURLToPath(import.meta.url)), "../templates/main.ts");
|
|
41
|
+
const appendTo = "src/main.tsx";
|
|
42
42
|
const reactRoutesPlugin = () => {
|
|
43
43
|
return {
|
|
44
44
|
name: "react-routes-plugin",
|
|
@@ -48,8 +48,8 @@ const reactRoutesPlugin = () => {
|
|
|
48
48
|
async transform(code, id, options) {
|
|
49
49
|
if (options?.ssr) return;
|
|
50
50
|
const [filename] = id.split("?", 2);
|
|
51
|
-
if (typeof appendTo
|
|
52
|
-
const transformed = await transform(await readFile(mainContentPath
|
|
51
|
+
if (typeof appendTo === "string" && filename.endsWith(appendTo)) {
|
|
52
|
+
const transformed = await transform(await readFile(mainContentPath, { encoding: "utf-8" }), {
|
|
53
53
|
loader: "ts",
|
|
54
54
|
format: "esm",
|
|
55
55
|
target: "es2022"
|
|
@@ -63,26 +63,34 @@ const reactRoutesPlugin = () => {
|
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/react-route-generouted.ts
|
|
66
|
-
|
|
67
|
-
const appendTo = "src/main.tsx";
|
|
66
|
+
join(dirname(fileURLToPath(import.meta.url)), "../templates/main-generouted.ts");
|
|
68
67
|
const reactRoutesGeneroutedPlugin = () => {
|
|
69
68
|
return {
|
|
70
69
|
name: "react-routes-plugin",
|
|
71
70
|
enforce: "post",
|
|
72
71
|
apply: "serve",
|
|
73
72
|
configResolved(resolvedConfig) {},
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
target: "es2022"
|
|
82
|
-
});
|
|
83
|
-
code = `${code}\n${transformed.code}`;
|
|
73
|
+
resolveId(id) {
|
|
74
|
+
if (id === "virtual:routes-listening") return id;
|
|
75
|
+
},
|
|
76
|
+
load(id) {
|
|
77
|
+
if (id === "virtual:routes-listening") {
|
|
78
|
+
const runtimePath = fileURLToPath(new URL("../templates/main-generouted", import.meta.url));
|
|
79
|
+
return `import ${JSON.stringify(runtimePath)};`;
|
|
84
80
|
}
|
|
85
|
-
|
|
81
|
+
},
|
|
82
|
+
async transformIndexHtml(html) {
|
|
83
|
+
return {
|
|
84
|
+
html,
|
|
85
|
+
tags: [{
|
|
86
|
+
tag: "script",
|
|
87
|
+
injectTo: "body",
|
|
88
|
+
attrs: {
|
|
89
|
+
src: "/@id/virtual:routes-listening",
|
|
90
|
+
type: "module"
|
|
91
|
+
}
|
|
92
|
+
}]
|
|
93
|
+
};
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaper.org/vite-react-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22-prerelease",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -16,36 +16,37 @@
|
|
|
16
16
|
"node": "^20.19.0 || >=22.12.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@shaper.org/core": "
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"@shaper.org/core": "1.0.4-prerelease",
|
|
20
|
+
"react": "^19.2.0",
|
|
21
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/core": "^7.28.5",
|
|
25
25
|
"@babel/preset-react": "^7.28.5",
|
|
26
26
|
"@babel/preset-typescript": "^7.28.5",
|
|
27
27
|
"@babel/types": "^7.28.5",
|
|
28
|
+
"@generouted/react-router": "^1.20.0",
|
|
28
29
|
"@jridgewell/gen-mapping": "^0.3.13",
|
|
29
30
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
30
31
|
"@rollup/pluginutils": "^5.3.0",
|
|
31
|
-
"@shaper.org/core": "
|
|
32
|
+
"@shaper.org/core": "1.0.4-prerelease",
|
|
32
33
|
"esbuild": "^0.27.0",
|
|
33
34
|
"obug": "^2.0.0",
|
|
35
|
+
"react": "^19.2.0",
|
|
34
36
|
"rollup": "^4.53.3",
|
|
35
37
|
"slash": "^5.1.0",
|
|
36
38
|
"source-map-js": "^1.2.1",
|
|
37
39
|
"tsdown": "^0.16.4",
|
|
38
40
|
"typescript": "5.9.3",
|
|
39
|
-
"vite": "^7.2.4"
|
|
40
|
-
"react": "^19.2.0"
|
|
41
|
+
"vite": "^7.2.4"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@rolldown/pluginutils": "1.0.0-beta.50",
|
|
44
|
-
"@shaper.org/core": "^1.0.0",
|
|
45
44
|
"@babel/core": "^7.28.5",
|
|
46
45
|
"@babel/preset-react": "^7.28.5",
|
|
47
46
|
"@babel/preset-typescript": "^7.28.5",
|
|
48
|
-
"@babel/types": "^7.28.5"
|
|
47
|
+
"@babel/types": "^7.28.5",
|
|
48
|
+
"@rolldown/pluginutils": "1.0.0-beta.50",
|
|
49
|
+
"@shaper.org/core": "^1.0.0"
|
|
49
50
|
},
|
|
50
51
|
"tsdown": {
|
|
51
52
|
"dts": true,
|