@marko/vite 2.4.3 → 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,27 +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
63
  let { linked = true } = opts;
65
- const { runtimeId, basePathVar } = opts;
66
- const baseConfig = {
67
- cache,
68
- runtimeId,
69
- sourceMaps: true,
70
- writeVersionComment: false,
71
- babelConfig: {
72
- ...opts.babelConfig,
73
- caller: {
74
- name: "@marko/vite",
75
- supportsStaticESM: true,
76
- supportsDynamicImport: true,
77
- supportsTopLevelAwait: true,
78
- supportsExportNamespaceFrom: true,
79
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
80
- }
81
- }
82
- };
64
+ let runtimeId;
65
+ let basePathVar;
66
+ let baseConfig;
67
+ let ssrConfig;
68
+ let domConfig;
69
+ let hydrateConfig;
83
70
  const resolveViteVirtualDep = (from, dep) => {
84
71
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
85
72
  normalizePath(dep.virtualPath)
@@ -95,21 +82,6 @@ function markoPlugin(opts = {}) {
95
82
  virtualFiles.set(id, dep);
96
83
  return `./${import_path.default.posix.basename(normalizedFrom) + query}`;
97
84
  };
98
- const ssrConfig = {
99
- ...baseConfig,
100
- resolveVirtualDependency: resolveViteVirtualDep,
101
- output: "html"
102
- };
103
- const domConfig = {
104
- ...baseConfig,
105
- resolveVirtualDependency: resolveViteVirtualDep,
106
- output: "dom"
107
- };
108
- const hydrateConfig = {
109
- ...baseConfig,
110
- resolveVirtualDependency: resolveViteVirtualDep,
111
- output: "hydrate"
112
- };
113
85
  let root;
114
86
  let devEntryFile;
115
87
  let devEntryFilePosix;
@@ -131,7 +103,42 @@ function markoPlugin(opts = {}) {
131
103
  enforce: "pre",
132
104
  // Must be pre to allow us to resolve assets before vite.
133
105
  async config(config, env) {
106
+ var _a;
134
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
+ };
135
142
  compiler.configure(baseConfig);
136
143
  root = normalizePath(config.root || process.cwd());
137
144
  devEntryFile = import_path.default.join(root, "index.html");
@@ -283,7 +290,7 @@ function markoPlugin(opts = {}) {
283
290
  }
284
291
  },
285
292
  async resolveId(importee, importer, importOpts, ssr = importOpts.ssr) {
286
- var _a2;
293
+ var _a;
287
294
  if (virtualFiles.has(importee)) {
288
295
  return importee;
289
296
  }
@@ -293,7 +300,7 @@ function markoPlugin(opts = {}) {
293
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.
294
301
  isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
295
302
  importeeQuery = serverEntryQuery;
296
- } 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)) {
297
304
  importeeQuery = browserEntryQuery;
298
305
  }
299
306
  if (importeeQuery) {
@@ -354,7 +361,7 @@ function markoPlugin(opts = {}) {
354
361
  fileName,
355
362
  entryData,
356
363
  runtimeId,
357
- basePathVar
364
+ basePathVar: isBuild ? basePathVar : void 0
358
365
  });
359
366
  }
360
367
  case browserEntryQuery: {
package/dist/index.mjs CHANGED
@@ -39,27 +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
43
  let { linked = true } = opts;
45
- const { runtimeId, basePathVar } = opts;
46
- const baseConfig = {
47
- cache,
48
- runtimeId,
49
- sourceMaps: true,
50
- writeVersionComment: false,
51
- babelConfig: {
52
- ...opts.babelConfig,
53
- caller: {
54
- name: "@marko/vite",
55
- supportsStaticESM: true,
56
- supportsDynamicImport: true,
57
- supportsTopLevelAwait: true,
58
- supportsExportNamespaceFrom: true,
59
- ...(_a = opts.babelConfig) == null ? void 0 : _a.caller
60
- }
61
- }
62
- };
44
+ let runtimeId;
45
+ let basePathVar;
46
+ let baseConfig;
47
+ let ssrConfig;
48
+ let domConfig;
49
+ let hydrateConfig;
63
50
  const resolveViteVirtualDep = (from, dep) => {
64
51
  const query = `${virtualFileQuery}&id=${encodeURIComponent(
65
52
  normalizePath(dep.virtualPath)
@@ -75,21 +62,6 @@ function markoPlugin(opts = {}) {
75
62
  virtualFiles.set(id, dep);
76
63
  return `./${path.posix.basename(normalizedFrom) + query}`;
77
64
  };
78
- const ssrConfig = {
79
- ...baseConfig,
80
- resolveVirtualDependency: resolveViteVirtualDep,
81
- output: "html"
82
- };
83
- const domConfig = {
84
- ...baseConfig,
85
- resolveVirtualDependency: resolveViteVirtualDep,
86
- output: "dom"
87
- };
88
- const hydrateConfig = {
89
- ...baseConfig,
90
- resolveVirtualDependency: resolveViteVirtualDep,
91
- output: "hydrate"
92
- };
93
65
  let root;
94
66
  let devEntryFile;
95
67
  let devEntryFilePosix;
@@ -111,7 +83,42 @@ function markoPlugin(opts = {}) {
111
83
  enforce: "pre",
112
84
  // Must be pre to allow us to resolve assets before vite.
113
85
  async config(config, env) {
86
+ var _a;
114
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
+ };
115
122
  compiler.configure(baseConfig);
116
123
  root = normalizePath(config.root || process.cwd());
117
124
  devEntryFile = path.join(root, "index.html");
@@ -263,7 +270,7 @@ function markoPlugin(opts = {}) {
263
270
  }
264
271
  },
265
272
  async resolveId(importee, importer, importOpts, ssr = importOpts.ssr) {
266
- var _a2;
273
+ var _a;
267
274
  if (virtualFiles.has(importee)) {
268
275
  return importee;
269
276
  }
@@ -273,7 +280,7 @@ function markoPlugin(opts = {}) {
273
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.
274
281
  isMarkoFile(importee) && !isMarkoFile(importer.replace(queryReg, ""))) {
275
282
  importeeQuery = serverEntryQuery;
276
- } 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)) {
277
284
  importeeQuery = browserEntryQuery;
278
285
  }
279
286
  if (importeeQuery) {
@@ -334,7 +341,7 @@ function markoPlugin(opts = {}) {
334
341
  fileName,
335
342
  entryData,
336
343
  runtimeId,
337
- basePathVar
344
+ basePathVar: isBuild ? basePathVar : void 0
338
345
  });
339
346
  }
340
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.3",
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": {