@marko/vite 2.3.4 → 2.3.5

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
@@ -102,6 +102,7 @@ function markoPlugin(opts = {}) {
102
102
  let devServer;
103
103
  let registeredTag = false;
104
104
  let serverManifest;
105
+ const devEntryFileSources = /* @__PURE__ */ new Map();
105
106
  const transformWatchFiles = /* @__PURE__ */ new Map();
106
107
  const transformOptionalFiles = /* @__PURE__ */ new Map();
107
108
  return [
@@ -167,6 +168,9 @@ function markoPlugin(opts = {}) {
167
168
  ssrConfig.hot = domConfig.hot = true;
168
169
  devServer = _server;
169
170
  devServer.watcher.on("all", (type, filename) => {
171
+ if (type === "unlink") {
172
+ devEntryFileSources.delete(filename);
173
+ }
170
174
  for (const [id, files] of transformWatchFiles) {
171
175
  if ((0, import_anymatch.default)(files, filename)) {
172
176
  devServer.watcher.emit("change", id);
@@ -248,8 +252,19 @@ function markoPlugin(opts = {}) {
248
252
  runtimeId
249
253
  });
250
254
  }
251
- case browserEntryQuery:
252
- return import_fs.default.promises.readFile(id.slice(0, -browserEntryQuery.length), "utf-8");
255
+ case browserEntryQuery: {
256
+ const realId = id.slice(0, -browserEntryQuery.length);
257
+ if (isBuild) {
258
+ const {
259
+ meta: { source }
260
+ } = await this.load({
261
+ id: realId,
262
+ resolveDependencies: false
263
+ });
264
+ return source;
265
+ }
266
+ return devEntryFileSources.get(realId);
267
+ }
253
268
  }
254
269
  return virtualFiles.get(id) || null;
255
270
  },
@@ -264,6 +279,7 @@ function markoPlugin(opts = {}) {
264
279
  if (query && !query.startsWith(virtualFileQuery)) {
265
280
  id = id.slice(0, -query.length);
266
281
  if (query === serverEntryQuery) {
282
+ devEntryFileSources.set(id, source);
267
283
  id = `${id.slice(0, -markoExt.length)}.entry.marko`;
268
284
  }
269
285
  }
@@ -291,7 +307,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
291
307
  ]);
292
308
  transformWatchFiles.set(id, meta.watchFiles);
293
309
  }
294
- return { code, map };
310
+ return { code, map, meta: isBuild ? { source } : void 0 };
295
311
  }
296
312
  },
297
313
  {
package/dist/index.mjs CHANGED
@@ -85,6 +85,7 @@ function markoPlugin(opts = {}) {
85
85
  let devServer;
86
86
  let registeredTag = false;
87
87
  let serverManifest;
88
+ const devEntryFileSources = /* @__PURE__ */ new Map();
88
89
  const transformWatchFiles = /* @__PURE__ */ new Map();
89
90
  const transformOptionalFiles = /* @__PURE__ */ new Map();
90
91
  return [
@@ -150,6 +151,9 @@ function markoPlugin(opts = {}) {
150
151
  ssrConfig.hot = domConfig.hot = true;
151
152
  devServer = _server;
152
153
  devServer.watcher.on("all", (type, filename) => {
154
+ if (type === "unlink") {
155
+ devEntryFileSources.delete(filename);
156
+ }
153
157
  for (const [id, files] of transformWatchFiles) {
154
158
  if (anyMatch(files, filename)) {
155
159
  devServer.watcher.emit("change", id);
@@ -231,8 +235,19 @@ function markoPlugin(opts = {}) {
231
235
  runtimeId
232
236
  });
233
237
  }
234
- case browserEntryQuery:
235
- return fs.promises.readFile(id.slice(0, -browserEntryQuery.length), "utf-8");
238
+ case browserEntryQuery: {
239
+ const realId = id.slice(0, -browserEntryQuery.length);
240
+ if (isBuild) {
241
+ const {
242
+ meta: { source }
243
+ } = await this.load({
244
+ id: realId,
245
+ resolveDependencies: false
246
+ });
247
+ return source;
248
+ }
249
+ return devEntryFileSources.get(realId);
250
+ }
236
251
  }
237
252
  return virtualFiles.get(id) || null;
238
253
  },
@@ -247,6 +262,7 @@ function markoPlugin(opts = {}) {
247
262
  if (query && !query.startsWith(virtualFileQuery)) {
248
263
  id = id.slice(0, -query.length);
249
264
  if (query === serverEntryQuery) {
265
+ devEntryFileSources.set(id, source);
250
266
  id = `${id.slice(0, -markoExt.length)}.entry.marko`;
251
267
  }
252
268
  }
@@ -274,7 +290,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
274
290
  ]);
275
291
  transformWatchFiles.set(id, meta.watchFiles);
276
292
  }
277
- return { code, map };
293
+ return { code, map, meta: isBuild ? { source } : void 0 };
278
294
  }
279
295
  },
280
296
  {
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.3.4",
4
+ "version": "2.3.5",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {