vite-plugin-vanjs 0.1.0 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/plugin/index.mjs +10 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vanjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "author": "thednp",
5
5
  "license": "MIT",
6
6
  "description": "A mini meta-framework for VanJS powered by Vite",
package/plugin/index.mjs CHANGED
@@ -41,7 +41,8 @@ export default function VitePluginVanJS(options = {}) {
41
41
  include: [
42
42
  "vanjs-core",
43
43
  "vanjs-ext",
44
- "mini-van-plate",
44
+ "mini-van-plate/van-plate",
45
+ "mini-van-plate/shared",
45
46
  ],
46
47
  },
47
48
  ssr: {
@@ -101,17 +102,22 @@ export default function VitePluginVanJS(options = {}) {
101
102
  },
102
103
  /** @type {(source: string, importer: string | undefined, ops: { ssr: boolean }) => string | null} */
103
104
  resolveId(source, importer, ops) {
105
+ // istanbul ignore else
106
+ if (source === virtualModuleId) {
107
+ return resolvedVirtualModuleId;
108
+ }
104
109
  const isVanXFile = importer &&
105
110
  /vanjs-ext[\/\\]src[\/\\]van-x/.test(importer);
106
111
  const isSetupFile = importer &&
107
112
  /vite-plugin-vanjs[\/\\]setup/.test(importer);
108
113
  const isProduction = process.env.NODE_ENV === "production";
114
+ const isTest = process.env.NODE_ENV === "test";
109
115
  const isJSXImport = source.includes("/vite-plugin-vanjs/jsx/jsx") ||
110
116
  importer?.includes("/vite-plugin-vanjs/jsx/jsx.mjs");
111
117
 
112
118
  const resolvedVan = toAbsolute(
113
119
  ops.ssr ? "../setup/van-ssr.mjs" : (isJSXImport || isProduction ||
114
- config.mode === "test")
120
+ isTest)
115
121
  ? "../setup/van.mjs"
116
122
  : "../setup/van-debug.mjs",
117
123
  );
@@ -121,7 +127,7 @@ export default function VitePluginVanJS(options = {}) {
121
127
  const setupResolved = toAbsolute(
122
128
  ops.ssr
123
129
  ? "../setup/index-ssr.mjs"
124
- : (isProduction || config.mode === "test")
130
+ : (isProduction || isTest)
125
131
  ? "../setup/index.mjs"
126
132
  : "../setup/index-debug.mjs",
127
133
  );
@@ -152,10 +158,7 @@ export default function VitePluginVanJS(options = {}) {
152
158
  return resolvedVanX;
153
159
  }
154
160
  }
155
- // istanbul ignore else
156
- if (source === virtualModuleId) {
157
- return resolvedVirtualModuleId;
158
- }
161
+
159
162
  return null;
160
163
  },
161
164
  /** @type {(id: string, ops: { ssr: boolean }) => Promise<({ code: string, map: null } | null)>} */