vite-plugin-vanjs 0.1.3 → 0.1.5
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 +1 -1
- package/client/index.mjs +6 -1
- package/package.json +2 -2
- package/plugin/index.mjs +0 -19
- package/server/index.mjs +6 -2
- package/setup/vanX-ssr.mjs +23 -5
- package/setup/vanX.mjs +2 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://github.com/vanjs-org/van)
|
|
9
9
|
[](https://github.com/vanjs-org/mini-van-plate)
|
|
10
10
|
[](https://www.vitest.dev/)
|
|
11
|
-
[](https://vite.dev)
|
|
12
12
|
|
|
13
13
|
A mini meta-framework for [VanJS](https://vanjs.org/) developed around the awesome [vite](https://vite.dev) and tested with [vitest](https://vitest.dev). The plugin comes with a set of modules to streamline your workflow:
|
|
14
14
|
* ***@vanjs/router*** - one of the most important part of an application which allows you to split code and lazy load page like components with ease, handles both Client Side Rendering (SSR) and Server Side Rendering (CSR) and makes it really easy to work with;
|
package/client/index.mjs
CHANGED
|
@@ -106,13 +106,18 @@ function createHydrationContext() {
|
|
|
106
106
|
return parent;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/** @type {(oldDom: HTMLElement, newDom: HTMLElement) => HTMLElement} */
|
|
109
|
+
/** @type {(oldDom: HTMLElement, newDom: HTMLElement | HTMLElement[]) => HTMLElement} */
|
|
110
110
|
function diffAndHydrate(oldDom, newDom) {
|
|
111
111
|
// SPA mode
|
|
112
112
|
// istanbul ignore else
|
|
113
113
|
if (!oldDom.children.length && !elementsMatch(oldDom, newDom)) {
|
|
114
114
|
return oldDom.replaceChildren(...unwrap(newDom).children);
|
|
115
115
|
}
|
|
116
|
+
// istanbul ignore else
|
|
117
|
+
if (newDom instanceof Array) {
|
|
118
|
+
oldDom.replaceChildren(...unwrap(newDom).children);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
116
121
|
|
|
117
122
|
// SSR Mode
|
|
118
123
|
/** @type {Set<HTMLElement>} */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vanjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"author": "thednp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A mini meta-framework for VanJS powered by Vite",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@vitest/ui": "^3.1.2",
|
|
94
94
|
"happy-dom": "^16.8.1",
|
|
95
95
|
"typescript": "5.6.2",
|
|
96
|
-
"vite": "^6.3.
|
|
96
|
+
"vite": "^6.3.4",
|
|
97
97
|
"vitest": "^3.1.2"
|
|
98
98
|
},
|
|
99
99
|
"packageManager": "pnpm@8.6.12",
|
package/plugin/index.mjs
CHANGED
|
@@ -19,22 +19,14 @@ const pluginDefaults = {
|
|
|
19
19
|
extensions: [".tsx", ".jsx", ".ts", ".js"],
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
// Aliases coming from plugin.config()
|
|
23
|
-
// const resolvedVan = toAbsolute("../setup/van");
|
|
24
|
-
// const resolvedVanX = toAbsolute("../setup/vanX");
|
|
25
|
-
// const resolvedSetup = toAbsolute("../setup/index");
|
|
26
|
-
|
|
27
22
|
// Define module mapping configuration
|
|
28
23
|
const moduleAliases = {
|
|
29
24
|
// Core modules
|
|
30
25
|
"@vanjs/van": "../setup/van",
|
|
31
|
-
// [resolvedVan]: "../setup/van",
|
|
32
26
|
"@vanjs/vanX": "../setup/vanX",
|
|
33
|
-
// [resolvedVanX]: "../setup/vanX",
|
|
34
27
|
|
|
35
28
|
// Setup modules
|
|
36
29
|
"@vanjs/setup": "../setup/index",
|
|
37
|
-
// [resolvedSetup]: "../setup/index",
|
|
38
30
|
|
|
39
31
|
// Other modules
|
|
40
32
|
"@vanjs/client": "../client",
|
|
@@ -47,19 +39,14 @@ const moduleAliases = {
|
|
|
47
39
|
// SSR specific module mappings
|
|
48
40
|
const ssrModuleAliases = {
|
|
49
41
|
"@vanjs/van": "../setup/van-ssr",
|
|
50
|
-
// [resolvedVan]: "../setup/van-ssr",
|
|
51
42
|
"@vanjs/vanX": "../setup/vanX-ssr",
|
|
52
|
-
// [resolvedVanX]: "../setup/vanX-ssr",
|
|
53
43
|
"@vanjs/setup": "../setup/index-ssr",
|
|
54
|
-
// [resolvedSetup]: "../setup/index-ssr",
|
|
55
44
|
};
|
|
56
45
|
|
|
57
46
|
// Debug specific module mappings (development only)
|
|
58
47
|
const debugModuleAliases = {
|
|
59
48
|
"@vanjs/van": "../setup/van-debug",
|
|
60
|
-
// [resolvedVan]: "../setup/van-debug",
|
|
61
49
|
"@vanjs/setup": "../setup/index-debug",
|
|
62
|
-
// [resolvedSetup]: "../setup/index-debug",
|
|
63
50
|
};
|
|
64
51
|
|
|
65
52
|
export default function VitePluginVanJS(options = {}) {
|
|
@@ -155,14 +142,8 @@ export default function VitePluginVanJS(options = {}) {
|
|
|
155
142
|
const isTest = process.env.NODE_ENV === "test";
|
|
156
143
|
const isSetupFile = typeof importer === "string" &&
|
|
157
144
|
importer.includes("vite-plugin-vanjs/setup");
|
|
158
|
-
// const isVanXFile = typeof importer === "string" &&
|
|
159
|
-
// importer.includes("vanjs-ext/src/van-x");
|
|
160
145
|
const isImportedVanXFile = typeof importer === "string" &&
|
|
161
146
|
importer.includes("vite-plugin-vanjs/setup/vanX");
|
|
162
|
-
// const isImportedVanFile = !isImportedVanXFile && typeof importer === "string" &&
|
|
163
|
-
// importer.includes("vite-plugin-vanjs/setup/van");
|
|
164
|
-
// const isImportedSetupFile = typeof importer === "string" &&
|
|
165
|
-
// importer.includes("vite-plugin-vanjs/setup/index");
|
|
166
147
|
const isResolvedVanXFile = source.includes(
|
|
167
148
|
"vite-plugin-vanjs/setup/vanX",
|
|
168
149
|
);
|
package/server/index.mjs
CHANGED
|
@@ -80,8 +80,12 @@ export function renderPreloadLinks(modules, manifest) {
|
|
|
80
80
|
|
|
81
81
|
// First pass: collect all assets from ignored paths
|
|
82
82
|
Object.entries(manifest).forEach(([id, files]) => {
|
|
83
|
-
// istanbul ignore else
|
|
84
|
-
if (
|
|
83
|
+
// istanbul ignore else - don't pre-render routes, layouts and JSX stuff
|
|
84
|
+
if (
|
|
85
|
+
["src/pages", "src/routes", "vite-plugin-vanjs/jsx"].some((l) =>
|
|
86
|
+
id.includes(l)
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
85
89
|
files.forEach((asset) => ignoredAssets.add(asset));
|
|
86
90
|
}
|
|
87
91
|
});
|
package/setup/vanX-ssr.mjs
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { dummyVanX, registerEnv } from "mini-van-plate/shared";
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
calc,
|
|
5
|
+
compact,
|
|
6
|
+
list,
|
|
7
|
+
noreactive,
|
|
8
|
+
raw,
|
|
9
|
+
reactive,
|
|
10
|
+
replace,
|
|
11
|
+
stateFields,
|
|
12
|
+
} = dummyVanX;
|
|
13
|
+
|
|
3
14
|
const vanX = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
calc,
|
|
16
|
+
compact,
|
|
17
|
+
list,
|
|
18
|
+
noreactive,
|
|
19
|
+
raw,
|
|
20
|
+
reactive,
|
|
21
|
+
replace,
|
|
22
|
+
stateFields,
|
|
8
23
|
};
|
|
9
24
|
|
|
10
25
|
registerEnv({ vanX });
|
|
11
26
|
|
|
12
|
-
export
|
|
27
|
+
export { calc, compact, list, noreactive, raw, reactive, replace, stateFields };
|
|
28
|
+
|
|
29
|
+
export { vanX as default };
|
|
30
|
+
export {};
|
package/setup/vanX.mjs
CHANGED
|
@@ -20,14 +20,11 @@ const vanX = {
|
|
|
20
20
|
list,
|
|
21
21
|
replace,
|
|
22
22
|
compact,
|
|
23
|
-
// Define default as part of the initial object
|
|
24
|
-
get default() {
|
|
25
|
-
return vanX;
|
|
26
|
-
},
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
// Export named exports
|
|
30
26
|
export { calc, compact, list, noreactive, raw, reactive, replace, stateFields };
|
|
31
27
|
|
|
32
28
|
// Export as default
|
|
33
|
-
export default
|
|
29
|
+
export { vanX as default };
|
|
30
|
+
export {};
|