@marko/vite 2.4.2 → 2.4.4

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/dist/index.js CHANGED
@@ -59,26 +59,14 @@ const resolveOpts = { skipSelf: true };
59
59
  const cache = /* @__PURE__ */ new Map();
60
60
  const thisFile = typeof __filename === "string" ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
61
61
  function markoPlugin(opts = {}) {
62
- var _a;
63
62
  let compiler;
64
- const { runtimeId, basePathVar, linked = true } = opts;
65
- const baseConfig = {
66
- cache,
67
- runtimeId,
68
- sourceMaps: true,
69
- writeVersionComment: false,
70
- babelConfig: {
71
- ...opts.babelConfig,
72
- caller: {
73
- name: "@marko/vite",
74
- supportsStaticESM: true,
75
- supportsDynamicImport: true,
76
- supportsTopLevelAwait: true,
77
- supportsExportNamespaceFrom: true,
78
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
79
- }
80
- }
81
- };
63
+ let { linked = true } = opts;
64
+ let runtimeId;
65
+ let basePathVar;
66
+ let baseConfig;
67
+ let ssrConfig;
68
+ let domConfig;
69
+ let hydrateConfig;
82
70
  const resolveViteVirtualDep = (from, dep) => {
83
71
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
84
72
  normalizePath(dep.virtualPath)
@@ -94,21 +82,6 @@ function markoPlugin(opts = {}) {
94
82
  virtualFiles.set(id, dep);
95
83
  return `./${import_path.default.posix.basename(normalizedFrom) + query}`;
96
84
  };
97
- const ssrConfig = {
98
- ...baseConfig,
99
- resolveVirtualDependency: resolveViteVirtualDep,
100
- output: "html"
101
- };
102
- const domConfig = {
103
- ...baseConfig,
104
- resolveVirtualDependency: resolveViteVirtualDep,
105
- output: "dom"
106
- };
107
- const hydrateConfig = {
108
- ...baseConfig,
109
- resolveVirtualDependency: resolveViteVirtualDep,
110
- output: "hydrate"
111
- };
112
85
  let root;
113
86
  let devEntryFile;
114
87
  let devEntryFilePosix;
@@ -130,7 +103,42 @@ function markoPlugin(opts = {}) {
130
103
  enforce: "pre",
131
104
  // Must be pre to allow us to resolve assets before vite.
132
105
  async config(config, env) {
106
+ var _a;
133
107
  compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
108
+ runtimeId = opts.runtimeId;
109
+ basePathVar = opts.basePathVar;
110
+ baseConfig = {
111
+ cache,
112
+ runtimeId,
113
+ sourceMaps: true,
114
+ writeVersionComment: false,
115
+ babelConfig: {
116
+ ...opts.babelConfig,
117
+ caller: {
118
+ name: "@marko/vite",
119
+ supportsStaticESM: true,
120
+ supportsDynamicImport: true,
121
+ supportsTopLevelAwait: true,
122
+ supportsExportNamespaceFrom: true,
123
+ ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
124
+ }
125
+ }
126
+ };
127
+ ssrConfig = {
128
+ ...baseConfig,
129
+ resolveVirtualDependency: resolveViteVirtualDep,
130
+ output: "html"
131
+ };
132
+ domConfig = {
133
+ ...baseConfig,
134
+ resolveVirtualDependency: resolveViteVirtualDep,
135
+ output: "dom"
136
+ };
137
+ hydrateConfig = {
138
+ ...baseConfig,
139
+ resolveVirtualDependency: resolveViteVirtualDep,
140
+ output: "hydrate"
141
+ };
134
142
  compiler.configure(baseConfig);
135
143
  root = normalizePath(config.root || process.cwd());
136
144
  devEntryFile = import_path.default.join(root, "index.html");
@@ -141,6 +149,9 @@ function markoPlugin(opts = {}) {
141
149
  store = opts.store || new import_store.FileStore(
142
150
  `marko-vite-${import_crypto.default.createHash("SHA1").update(root).digest("hex")}`
143
151
  );
152
+ if (isTest) {
153
+ linked = false;
154
+ }
144
155
  if (linked && !registeredTag) {
145
156
  const transformer = import_path.default.resolve(
146
157
  thisFile,
@@ -279,7 +290,7 @@ function markoPlugin(opts = {}) {
279
290
  }
280
291
  },
281
292
  async resolveId(importee, importer, importOpts, ssr = importOpts.ssr) {
282
- var _a2;
293
+ var _a;
283
294
  if (virtualFiles.has(importee)) {
284
295
  return importee;
285
296
  }
@@ -289,7 +300,7 @@ function markoPlugin(opts = {}) {
289
300
  } else if (ssr && linked && importer && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
290
301
  isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
291
302
  importeeQuery = serverEntryQuery;
292
- } else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a2 = this.getModuleInfo(importer)) == null ? void 0 : _a2.isEntry)) {
303
+ } else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a = this.getModuleInfo(importer)) == null ? void 0 : _a.isEntry)) {
293
304
  importeeQuery = browserEntryQuery;
294
305
  }
295
306
  if (importeeQuery) {
@@ -350,7 +361,7 @@ function markoPlugin(opts = {}) {
350
361
  fileName,
351
362
  entryData,
352
363
  runtimeId,
353
- basePathVar
364
+ basePathVar: isBuild ? basePathVar : void 0
354
365
  });
355
366
  }
356
367
  case browserEntryQuery: {
package/dist/index.mjs CHANGED
@@ -39,26 +39,14 @@ var resolveOpts = { skipSelf: true };
39
39
  var cache = /* @__PURE__ */ new Map();
40
40
  var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
41
41
  function markoPlugin(opts = {}) {
42
- var _a;
43
42
  let compiler;
44
- const { runtimeId, basePathVar, linked = true } = opts;
45
- const baseConfig = {
46
- cache,
47
- runtimeId,
48
- sourceMaps: true,
49
- writeVersionComment: false,
50
- babelConfig: {
51
- ...opts.babelConfig,
52
- caller: {
53
- name: "@marko/vite",
54
- supportsStaticESM: true,
55
- supportsDynamicImport: true,
56
- supportsTopLevelAwait: true,
57
- supportsExportNamespaceFrom: true,
58
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
59
- }
60
- }
61
- };
43
+ let { linked = true } = opts;
44
+ let runtimeId;
45
+ let basePathVar;
46
+ let baseConfig;
47
+ let ssrConfig;
48
+ let domConfig;
49
+ let hydrateConfig;
62
50
  const resolveViteVirtualDep = (from, dep) => {
63
51
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
64
52
  normalizePath(dep.virtualPath)
@@ -74,21 +62,6 @@ function markoPlugin(opts = {}) {
74
62
  virtualFiles.set(id, dep);
75
63
  return `./${path.posix.basename(normalizedFrom) + query}`;
76
64
  };
77
- const ssrConfig = {
78
- ...baseConfig,
79
- resolveVirtualDependency: resolveViteVirtualDep,
80
- output: "html"
81
- };
82
- const domConfig = {
83
- ...baseConfig,
84
- resolveVirtualDependency: resolveViteVirtualDep,
85
- output: "dom"
86
- };
87
- const hydrateConfig = {
88
- ...baseConfig,
89
- resolveVirtualDependency: resolveViteVirtualDep,
90
- output: "hydrate"
91
- };
92
65
  let root;
93
66
  let devEntryFile;
94
67
  let devEntryFilePosix;
@@ -110,7 +83,42 @@ function markoPlugin(opts = {}) {
110
83
  enforce: "pre",
111
84
  // Must be pre to allow us to resolve assets before vite.
112
85
  async config(config, env) {
86
+ var _a;
113
87
  compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
88
+ runtimeId = opts.runtimeId;
89
+ basePathVar = opts.basePathVar;
90
+ baseConfig = {
91
+ cache,
92
+ runtimeId,
93
+ sourceMaps: true,
94
+ writeVersionComment: false,
95
+ babelConfig: {
96
+ ...opts.babelConfig,
97
+ caller: {
98
+ name: "@marko/vite",
99
+ supportsStaticESM: true,
100
+ supportsDynamicImport: true,
101
+ supportsTopLevelAwait: true,
102
+ supportsExportNamespaceFrom: true,
103
+ ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
104
+ }
105
+ }
106
+ };
107
+ ssrConfig = {
108
+ ...baseConfig,
109
+ resolveVirtualDependency: resolveViteVirtualDep,
110
+ output: "html"
111
+ };
112
+ domConfig = {
113
+ ...baseConfig,
114
+ resolveVirtualDependency: resolveViteVirtualDep,
115
+ output: "dom"
116
+ };
117
+ hydrateConfig = {
118
+ ...baseConfig,
119
+ resolveVirtualDependency: resolveViteVirtualDep,
120
+ output: "hydrate"
121
+ };
114
122
  compiler.configure(baseConfig);
115
123
  root = normalizePath(config.root || process.cwd());
116
124
  devEntryFile = path.join(root, "index.html");
@@ -121,6 +129,9 @@ function markoPlugin(opts = {}) {
121
129
  store = opts.store || new FileStore(
122
130
  `marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
123
131
  );
132
+ if (isTest) {
133
+ linked = false;
134
+ }
124
135
  if (linked && !registeredTag) {
125
136
  const transformer = path.resolve(
126
137
  thisFile,
@@ -259,7 +270,7 @@ function markoPlugin(opts = {}) {
259
270
  }
260
271
  },
261
272
  async resolveId(importee, importer, importOpts, ssr = importOpts.ssr) {
262
- var _a2;
273
+ var _a;
263
274
  if (virtualFiles.has(importee)) {
264
275
  return importee;
265
276
  }
@@ -269,7 +280,7 @@ function markoPlugin(opts = {}) {
269
280
  } else if (ssr && linked && importer && (importer !== devEntryFile || normalizePath(importer) !== devEntryFilePosix) && // Vite tries to resolve against an `index.html` in some cases, we ignore it here.
270
281
  isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
271
282
  importeeQuery = serverEntryQuery;
272
- } else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a2 = this.getModuleInfo(importer)) == null ? void 0 : _a2.isEntry)) {
283
+ } else if (!ssr && isBuild && importer && isMarkoFile(importee) && ((_a = this.getModuleInfo(importer)) == null ? void 0 : _a.isEntry)) {
273
284
  importeeQuery = browserEntryQuery;
274
285
  }
275
286
  if (importeeQuery) {
@@ -330,7 +341,7 @@ function markoPlugin(opts = {}) {
330
341
  fileName,
331
342
  entryData,
332
343
  runtimeId,
333
- basePathVar
344
+ basePathVar: isBuild ? basePathVar : void 0
334
345
  });
335
346
  }
336
347
  case browserEntryQuery: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "2.4.2",
4
+ "version": "2.4.4",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {