vite-plugin-vanjs 0.0.4 → 0.0.6

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.
Files changed (55) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +31 -28
  3. package/client/global.d.ts +5 -1
  4. package/client/index.mjs +99 -5
  5. package/client/package.json +0 -0
  6. package/client/types.d.ts +5 -1
  7. package/jsx/fragment.d.ts +0 -0
  8. package/jsx/fragment.mjs +0 -0
  9. package/jsx/global.d.ts +3 -2
  10. package/jsx/index.mjs +3 -3
  11. package/jsx/jsx-dev-runtime.d.ts +0 -0
  12. package/jsx/jsx-dev-runtime.mjs +1 -1
  13. package/jsx/jsx-runtime.d.ts +0 -0
  14. package/jsx/jsx-runtime.mjs +1 -1
  15. package/jsx/jsx.d.ts +42 -9
  16. package/jsx/jsx.mjs +10 -10
  17. package/jsx/package.json +0 -0
  18. package/jsx/types.d.ts +0 -0
  19. package/jsx-dev-runtime.d.ts +0 -0
  20. package/jsx-runtime.d.ts +0 -0
  21. package/meta/Head.mjs +4 -4
  22. package/meta/global.d.ts +24 -12
  23. package/meta/helpers.mjs +5 -3
  24. package/meta/index.mjs +3 -3
  25. package/meta/package.json +0 -0
  26. package/meta/tags.mjs +6 -8
  27. package/meta/types.d.ts +7 -7
  28. package/package.json +20 -18
  29. package/router/a.mjs +16 -10
  30. package/router/global.d.ts +75 -16
  31. package/router/helpers.mjs +28 -9
  32. package/router/index.mjs +7 -6
  33. package/router/lazy.mjs +2 -2
  34. package/router/package.json +0 -0
  35. package/router/router.mjs +20 -13
  36. package/router/routes.mjs +2 -2
  37. package/router/state.mjs +2 -1
  38. package/router/types.d.ts +86 -22
  39. package/server/global.d.ts +1 -0
  40. package/server/index.mjs +3 -3
  41. package/server/package.json +0 -0
  42. package/server/types.d.ts +1 -1
  43. package/setup/global.d.ts +0 -0
  44. package/setup/index-debug.mjs +21 -0
  45. package/setup/index.mjs +0 -0
  46. package/setup/package.json +0 -0
  47. package/setup/types.d.ts +0 -0
  48. package/setup/van-debug.mjs +2 -0
  49. package/setup/van.d.ts +0 -0
  50. package/setup/van.mjs +0 -0
  51. package/setup/vanX.d.ts +0 -0
  52. package/setup/vanX.mjs +0 -0
  53. package/src/index.mjs +19 -4
  54. package/src/types.d.ts +2 -3
  55. package/tsconfig.json +1 -1
package/server/index.mjs CHANGED
@@ -43,10 +43,10 @@ export const renderToString = async (inputSource) => {
43
43
  * @returns {string}
44
44
  */
45
45
  function renderPreloadLink(file) {
46
- if (file.endsWith(".js") || file.endsWith(".mjs")) {
47
- return `<link rel="modulepreload" as="script" crossorigin href="${file}">`;
46
+ if (file.endsWith(".js")) {
47
+ return `<link rel="preload" href="${file}" as="script" crossorigin>`;
48
48
  } else if (file.endsWith(".css")) {
49
- return `<link rel="stylesheet" href="${file}">`;
49
+ return `<link rel="preload" href="${file}" as="style" crossorigin>`;
50
50
  } else if (file.endsWith(".woff")) {
51
51
  return ` <link rel="preload" href="${file}" as="font" type="font/woff" crossorigin>`;
52
52
  } else if (file.endsWith(".woff2")) {
File without changes
package/server/types.d.ts CHANGED
@@ -20,7 +20,7 @@ type ValidVanNode =
20
20
  | VanElement
21
21
  | TagFunc;
22
22
 
23
- type VanComponent = () => ValidVanNode | ValidVanNode[];
23
+ type VanComponent = () => HTMLElement | ValidVanNode | ValidVanNode[];
24
24
  export type Source =
25
25
  | Promise<ValidVanNode>
26
26
  | VanComponent
package/setup/global.d.ts CHANGED
File without changes
@@ -0,0 +1,21 @@
1
+ import { dummyVanX, registerEnv } from "mini-van-plate/shared";
2
+ import vanPlate from "mini-van-plate/van-plate";
3
+ import vanCore from "vanjs-core/debug";
4
+ import * as vanX from "vanjs-ext";
5
+
6
+ const vanXObject = { ...vanX, default: vanX };
7
+ const dummyObject = { ...dummyVanX, default: dummyVanX };
8
+
9
+ const setup = {
10
+ isServer: typeof window === "undefined",
11
+ get van() {
12
+ return this.isServer ? vanPlate : vanCore;
13
+ },
14
+ get vanX() {
15
+ return this.isServer ? dummyObject : vanXObject;
16
+ },
17
+ };
18
+
19
+ registerEnv(setup);
20
+
21
+ export default setup;
package/setup/index.mjs CHANGED
File without changes
File without changes
package/setup/types.d.ts CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ import setup from "./index-debug.mjs";
2
+ export default setup.van;
package/setup/van.d.ts CHANGED
File without changes
package/setup/van.mjs CHANGED
File without changes
package/setup/vanX.d.ts CHANGED
File without changes
package/setup/vanX.mjs CHANGED
File without changes
package/src/index.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import { dirname, resolve } from "node:path";
3
+ import process from "node:process";
3
4
 
4
5
  const __filename = fileURLToPath(import.meta.url);
5
6
  const __dirname = dirname(__filename);
7
+ const isProduction = process.env.NODE_ENV === "production";
6
8
 
7
9
  export default function VitePluginVanJS() {
8
10
  return {
@@ -10,22 +12,35 @@ export default function VitePluginVanJS() {
10
12
  enforce: "pre",
11
13
  config() {
12
14
  return {
15
+ ssr: {
16
+ noExternal: ["vanjs-*", "*-vanjs", "@vanjs/*"],
17
+ },
13
18
  resolve: {
14
19
  alias: {
15
- "@vanjs/setup": resolve(__dirname, "../setup"),
16
- "@vanjs/van": resolve(__dirname, "../setup/van"),
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
+ ),
17
32
  "@vanjs/vanX": resolve(__dirname, "../setup/vanX"),
18
33
  "@vanjs/client": resolve(__dirname, "../client"),
19
34
  "@vanjs/server": resolve(__dirname, "../server"),
20
35
  "@vanjs/meta": resolve(__dirname, "../meta"),
21
36
  "@vanjs/router": resolve(__dirname, "../router"),
22
37
  "@vanjs/jsx": resolve(__dirname, "../jsx"),
38
+ "@vanjs/parser": resolve(__dirname, "../parser"),
23
39
  },
24
40
  },
25
41
  esbuild: {
26
42
  jsx: "automatic",
27
- jsxFactory: "jsx",
28
- jsxFragment: "Fragment",
43
+ jsxImportSource: "@vanjs/jsx",
29
44
  },
30
45
  };
31
46
  },
package/src/types.d.ts CHANGED
@@ -4,19 +4,18 @@ export * from "../router/types";
4
4
  export * from "../meta/types";
5
5
  export * from "../server/types";
6
6
  export * from "../client/types";
7
+ export * from "../parser/types";
7
8
 
8
9
  declare const VitePluginVanJS: () => {
9
10
  name: "string";
10
11
  enforce: "pre" | "post" | undefined;
11
- apply: "build";
12
12
  config(): {
13
13
  resolve: {
14
14
  alias: Record<string, string>;
15
15
  };
16
16
  esBuild: {
17
17
  jsx: "string";
18
- jsxFactory: "string";
19
- jsxFragment: "string";
18
+ jsxImportSource: "string";
20
19
  };
21
20
  };
22
21
  transform(code: string, id?: string): {
package/tsconfig.json CHANGED
@@ -39,7 +39,7 @@
39
39
  "./meta/*.ts",
40
40
  "./server/*.ts",
41
41
  "./client/*.ts",
42
- // "./tests/vite-env.d.ts"
42
+ "./tests/vite-env.d.ts"
43
43
  ],
44
44
  "exclude": ["node_modules", "experiments", "coverage"],
45
45
  }