vite-plugin-vanjs 0.0.10 → 0.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 +19 -221
- package/client/global.d.ts +3 -3
- package/client/index.mjs +141 -7
- package/client/types.d.ts +3 -3
- package/jsx/jsx.d.ts +2 -0
- package/jsx/jsx.mjs +4 -4
- package/meta/Head.mjs +3 -3
- package/meta/helpers.mjs +3 -5
- package/package.json +19 -19
- package/plugin/helpers.mjs +271 -0
- package/plugin/index.mjs +206 -0
- package/plugin/types.d.ts +23 -0
- package/router/a.mjs +18 -19
- package/router/cache.mjs +4 -3
- package/router/global.d.ts +74 -28
- package/router/helpers.mjs +32 -27
- package/router/lazy.mjs +22 -11
- package/router/router.mjs +28 -21
- package/router/routes.mjs +38 -9
- package/router/state.mjs +3 -3
- package/router/types.d.ts +103 -29
- package/server/index.mjs +32 -9
- package/server/types.d.ts +56 -0
- package/setup/global.d.ts +41 -39
- package/setup/helpers.mjs +7 -0
- package/setup/index-debug.mjs +8 -20
- package/setup/index-ssr.mjs +5 -0
- package/setup/index.mjs +4 -20
- package/setup/isServer.mjs +2 -0
- package/setup/package.json +16 -0
- package/setup/van-debug.mjs +2 -2
- package/setup/van-ssr..d.ts +1 -0
- package/setup/van-ssr.mjs +51 -0
- package/setup/van.mjs +44 -2
- package/setup/vanX-ssr.d.ts +1 -0
- package/setup/vanX-ssr.mjs +12 -0
- package/setup/vanX.mjs +23 -4
- package/tsconfig.json +1 -1
- package/src/index.mjs +0 -79
- package/src/types.d.ts +0 -28
package/setup/vanX.mjs
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// setup/vanX.mjs
|
|
2
|
+
import {
|
|
3
|
+
calc,
|
|
4
|
+
compact,
|
|
5
|
+
list,
|
|
6
|
+
noreactive,
|
|
7
|
+
raw,
|
|
8
|
+
reactive,
|
|
9
|
+
replace,
|
|
10
|
+
stateFields,
|
|
11
|
+
} from "vanjs-ext";
|
|
3
12
|
|
|
4
|
-
|
|
13
|
+
// Create the namespace object first
|
|
14
|
+
const vanX = {
|
|
5
15
|
calc,
|
|
6
16
|
reactive,
|
|
7
17
|
noreactive,
|
|
@@ -10,5 +20,14 @@ export const {
|
|
|
10
20
|
list,
|
|
11
21
|
replace,
|
|
12
22
|
compact,
|
|
13
|
-
|
|
23
|
+
// Define default as part of the initial object
|
|
24
|
+
get default() {
|
|
25
|
+
return vanX;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Export named exports
|
|
30
|
+
export { calc, compact, list, noreactive, raw, reactive, replace, stateFields };
|
|
31
|
+
|
|
32
|
+
// Export as default
|
|
14
33
|
export default vanX;
|
package/tsconfig.json
CHANGED
package/src/index.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
7
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
8
|
-
|
|
9
|
-
export default function VitePluginVanJS() {
|
|
10
|
-
return {
|
|
11
|
-
name: "vanjs",
|
|
12
|
-
enforce: "pre",
|
|
13
|
-
config() {
|
|
14
|
-
return {
|
|
15
|
-
ssr: {
|
|
16
|
-
noExternal: ["vanjs-*", "*-vanjs", "@vanjs/*"],
|
|
17
|
-
},
|
|
18
|
-
resolve: {
|
|
19
|
-
alias: {
|
|
20
|
-
"@vanjs/setup": resolve(
|
|
21
|
-
__dirname,
|
|
22
|
-
isProduction
|
|
23
|
-
? /* istanbul ignore next */ "../setup/index"
|
|
24
|
-
: "../setup/index-debug",
|
|
25
|
-
),
|
|
26
|
-
"@vanjs/van": resolve(
|
|
27
|
-
__dirname,
|
|
28
|
-
isProduction
|
|
29
|
-
? /* istanbul ignore next */ "../setup/van"
|
|
30
|
-
: "../setup/van-debug",
|
|
31
|
-
),
|
|
32
|
-
"@vanjs/vanX": resolve(__dirname, "../setup/vanX"),
|
|
33
|
-
"@vanjs/client": resolve(__dirname, "../client"),
|
|
34
|
-
"@vanjs/server": resolve(__dirname, "../server"),
|
|
35
|
-
"@vanjs/meta": resolve(__dirname, "../meta"),
|
|
36
|
-
"@vanjs/router": resolve(__dirname, "../router"),
|
|
37
|
-
"@vanjs/jsx": resolve(__dirname, "../jsx"),
|
|
38
|
-
"@vanjs/parser": resolve(__dirname, "../parser"),
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
esbuild: {
|
|
42
|
-
jsx: "automatic",
|
|
43
|
-
jsxImportSource: "@vanjs/jsx",
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
transform(code, id) {
|
|
48
|
-
let newCode = String(code);
|
|
49
|
-
|
|
50
|
-
const vanCoreReg = /import\s*.*\s*from\s*['"]vanjs-core['"]/g;
|
|
51
|
-
const vanExtReg = /import\s*.*\s*from\s*['"]vanjs-ext['"]/g;
|
|
52
|
-
const isSetupFile = /vite-plugin-vanjs[\\/]setup/.test(id);
|
|
53
|
-
const isVanXFile = /vanjs-ext[\\/]src[\\/]van-x/.test(id);
|
|
54
|
-
|
|
55
|
-
/* istanbul ignore else */
|
|
56
|
-
if (!isSetupFile && !isVanXFile) {
|
|
57
|
-
/* istanbul ignore next - the plugin works, istanbul isn't instrumenting this part properly */
|
|
58
|
-
if (vanCoreReg.test(newCode)) {
|
|
59
|
-
newCode = newCode.replace(
|
|
60
|
-
vanCoreReg,
|
|
61
|
-
(match) => match.replace("vanjs-core", "@vanjs/van"),
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
/* istanbul ignore next - the plugin works, istanbul isn't instrumenting this part properly */
|
|
65
|
-
if (vanExtReg.test(newCode)) {
|
|
66
|
-
newCode = newCode.replace(
|
|
67
|
-
vanExtReg,
|
|
68
|
-
(match) => match.replace("vanjs-ext", "@vanjs/vanX"),
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
code: newCode,
|
|
75
|
-
map: null,
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
package/src/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from "../jsx/types";
|
|
2
|
-
export * from "../setup/types";
|
|
3
|
-
export * from "../router/types";
|
|
4
|
-
export * from "../meta/types";
|
|
5
|
-
export * from "../server/types";
|
|
6
|
-
export * from "../client/types";
|
|
7
|
-
export * from "../parser/types";
|
|
8
|
-
|
|
9
|
-
declare const VitePluginVanJS: () => {
|
|
10
|
-
name: "string";
|
|
11
|
-
enforce: "pre" | "post" | undefined;
|
|
12
|
-
config(): {
|
|
13
|
-
resolve: {
|
|
14
|
-
alias: Record<string, string>;
|
|
15
|
-
};
|
|
16
|
-
esBuild: {
|
|
17
|
-
jsx: "string";
|
|
18
|
-
jsxImportSource: "string";
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
transform(code: string, id?: string): {
|
|
22
|
-
code: string;
|
|
23
|
-
map: null;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default VitePluginVanJS;
|
|
27
|
-
|
|
28
|
-
export {};
|