vite-plugin-vanjs 0.0.10 → 0.1.0

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/setup/vanX.mjs CHANGED
@@ -1,7 +1,17 @@
1
- import setup from "./index.mjs";
2
- const vanX = setup.vanX;
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
- export const {
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
- } = "default" in vanX ? vanX.default : /* istanbul ignore next */ vanX;
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
@@ -32,7 +32,7 @@
32
32
  "include": [
33
33
  "./tests/*.ts",
34
34
  "./tests/*.tsx",
35
- "./src/*.ts",
35
+ "./plugin/*.ts",
36
36
  "./jsx/*.ts",
37
37
  "./setup/*.ts",
38
38
  "./router/*.ts",
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 {};