@marko/vite 2.3.10 → 2.3.12

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/README.md CHANGED
@@ -118,6 +118,26 @@ marko({ runtimeId: "MY_MARKO_RUNTIME_ID" });
118
118
 
119
119
  Set this to `false` to opt out of [linked mode](#linked-mode). When this is false, the plugin will only handle resolving and transforming `.marko` files.
120
120
 
121
+ ### options.store
122
+
123
+ Storage mechanism to preserve data between SSR and client builds when building in linked mode. Two implementations are available:
124
+
125
+ - FileStore _(default)_
126
+
127
+ ```js
128
+ import { FileStore } from "@marko/vite";
129
+ const store = new FileStore();
130
+ ```
131
+
132
+ Reads/writes data to the file system. Use this when running the SSR and client builds in seperate processes such as when using Vite from the command line or npm scripts.
133
+
134
+ - MemoryStore
135
+ ```js
136
+ import { MemoryStore } from "@marko/vite";
137
+ const store = new MemoryStore();
138
+ ```
139
+ Reads/writes data to memory. This option can be used when building with Vite programatically.
140
+
121
141
  ## Code of Conduct
122
142
 
123
143
  This project adheres to the [eBay Code of Conduct](./.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
@@ -0,0 +1,20 @@
1
+ // src/store/memory-store.ts
2
+ var MemoryStore = class {
3
+ _store;
4
+ constructor() {
5
+ this._store = /* @__PURE__ */ new Map();
6
+ }
7
+ async has(key) {
8
+ return Promise.resolve(this._store.has(key));
9
+ }
10
+ async get(key) {
11
+ return Promise.resolve(this._store.get(key));
12
+ }
13
+ async set(key, value) {
14
+ this._store.set(key, value);
15
+ }
16
+ };
17
+
18
+ export {
19
+ MemoryStore
20
+ };
@@ -0,0 +1,63 @@
1
+ // src/store/file-store.ts
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import os from "os";
5
+ var FileStore = class {
6
+ _id;
7
+ _temp;
8
+ _cache;
9
+ constructor(id) {
10
+ this._id = id;
11
+ this._cache = /* @__PURE__ */ new Map();
12
+ }
13
+ async _getKeyPath(key) {
14
+ this._temp ?? (this._temp = getTempDir(this._id));
15
+ return path.join(await this._temp, key);
16
+ }
17
+ async has(key) {
18
+ if (!this._cache.has(key)) {
19
+ const path2 = await this._getKeyPath(key);
20
+ try {
21
+ await fs.promises.access(path2);
22
+ } catch (e) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ }
28
+ async get(key) {
29
+ let value = this._cache.get(key);
30
+ if (value === void 0) {
31
+ const path2 = await this._getKeyPath(key);
32
+ try {
33
+ value = await fs.promises.readFile(path2, "utf-8");
34
+ } catch (e) {
35
+ return void 0;
36
+ }
37
+ this._cache.set(key, value);
38
+ }
39
+ return value;
40
+ }
41
+ async set(key, value) {
42
+ this._cache.set(key, value);
43
+ const path2 = await this._getKeyPath(key);
44
+ await fs.promises.writeFile(path2, value, "utf-8");
45
+ }
46
+ };
47
+ async function getTempDir(id) {
48
+ const dir = path.join(os.tmpdir(), id);
49
+ try {
50
+ const stat = await fs.promises.stat(dir);
51
+ if (stat.isDirectory()) {
52
+ return dir;
53
+ }
54
+ } catch {
55
+ await fs.promises.mkdir(dir);
56
+ return dir;
57
+ }
58
+ throw new Error("Unable to create temp directory");
59
+ }
60
+
61
+ export {
62
+ FileStore
63
+ };
File without changes
package/dist/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import type * as vite from "vite";
2
2
  import type * as Compiler from "@marko/compiler";
3
+ import { BuildStore } from "./store";
4
+ export * from "./store";
5
+ export type { BuildStore } from "./store";
3
6
  export interface Options {
4
7
  linked?: boolean;
5
8
  compiler?: string;
6
9
  runtimeId?: string;
7
10
  translator?: string;
8
11
  babelConfig?: Compiler.Config["babelConfig"];
12
+ store?: BuildStore;
9
13
  }
10
14
  export default function markoPlugin(opts?: Options): vite.Plugin[];
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -31,7 +32,6 @@ __export(src_exports, {
31
32
  default: () => markoPlugin
32
33
  });
33
34
  module.exports = __toCommonJS(src_exports);
34
- var import_os = __toESM(require("os"));
35
35
  var import_fs = __toESM(require("fs"));
36
36
  var import_path = __toESM(require("path"));
37
37
  var import_crypto = __toESM(require("crypto"));
@@ -41,6 +41,8 @@ var import_relative_import_path = require("relative-import-path");
41
41
  var import_server_entry_template = __toESM(require("./server-entry-template"));
42
42
  var import_manifest_generator = require("./manifest-generator");
43
43
  var import_esbuild_plugin = __toESM(require("./esbuild-plugin"));
44
+ var import_store = require("./store");
45
+ __reExport(src_exports, require("./store"), module.exports);
44
46
  const import_meta = {};
45
47
  const normalizePath = import_path.default.sep === "\\" ? (id) => id.replace(/\\/g, "/") : (id) => id;
46
48
  const virtualFiles = /* @__PURE__ */ new Map();
@@ -48,12 +50,12 @@ const queryReg = /\?marko-.+$/;
48
50
  const browserEntryQuery = "?marko-browser-entry";
49
51
  const serverEntryQuery = "?marko-server-entry";
50
52
  const virtualFileQuery = "?marko-virtual";
53
+ const manifestFileName = "manifest.json";
51
54
  const markoExt = ".marko";
52
55
  const htmlExt = ".html";
53
56
  const resolveOpts = { skipSelf: true };
54
57
  const cache = /* @__PURE__ */ new Map();
55
58
  const thisFile = typeof __filename === "string" ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
56
- let tempDir;
57
59
  function markoPlugin(opts = {}) {
58
60
  var _a;
59
61
  let compiler;
@@ -80,10 +82,8 @@ function markoPlugin(opts = {}) {
80
82
  const id = normalizePath(from) + query;
81
83
  if (devServer) {
82
84
  const prev = virtualFiles.get(id);
83
- if (prev && prev.code !== dep.code) {
84
- devServer.moduleGraph.invalidateModule(
85
- devServer.moduleGraph.getModuleById(id)
86
- );
85
+ if (isDeferredPromise(prev)) {
86
+ prev.resolve(dep);
87
87
  }
88
88
  }
89
89
  virtualFiles.set(id, dep);
@@ -111,6 +111,7 @@ function markoPlugin(opts = {}) {
111
111
  let devServer;
112
112
  let registeredTag = false;
113
113
  let serverManifest;
114
+ let store;
114
115
  const entrySources = /* @__PURE__ */ new Map();
115
116
  const transformWatchFiles = /* @__PURE__ */ new Map();
116
117
  const transformOptionalFiles = /* @__PURE__ */ new Map();
@@ -125,6 +126,9 @@ function markoPlugin(opts = {}) {
125
126
  devEntryFile = import_path.default.join(root, "index.html");
126
127
  isBuild = env.command === "build";
127
128
  isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
129
+ store = opts.store || new import_store.FileStore(
130
+ `marko-vite-${import_crypto.default.createHash("SHA1").update(root).digest("hex")}`
131
+ );
128
132
  if (linked && !registeredTag) {
129
133
  const transformer = import_path.default.resolve(
130
134
  thisFile,
@@ -182,6 +186,8 @@ function markoPlugin(opts = {}) {
182
186
  devServer.watcher.on("all", (type, filename) => {
183
187
  if (type === "unlink") {
184
188
  entrySources.delete(filename);
189
+ transformWatchFiles.delete(filename);
190
+ transformOptionalFiles.delete(filename);
185
191
  }
186
192
  for (const [id, files] of transformWatchFiles) {
187
193
  if ((0, import_anymatch.default)(files, filename)) {
@@ -189,26 +195,28 @@ function markoPlugin(opts = {}) {
189
195
  }
190
196
  }
191
197
  if (type === "add" || type === "unlink") {
192
- let clearedCache = false;
193
198
  for (const [id, files] of transformOptionalFiles) {
194
199
  if ((0, import_anymatch.default)(files, filename)) {
195
- if (!clearedCache) {
196
- baseConfig.cache.clear();
197
- clearedCache = true;
198
- }
199
200
  devServer.watcher.emit("change", id);
200
201
  }
201
202
  }
202
203
  }
203
204
  });
204
205
  },
206
+ handleHotUpdate(ctx) {
207
+ compiler.taglib.clearCaches();
208
+ baseConfig.cache.clear();
209
+ for (const mod of ctx.modules) {
210
+ if (mod.id && virtualFiles.has(mod.id)) {
211
+ virtualFiles.set(mod.id, createDeferredPromise());
212
+ }
213
+ }
214
+ },
205
215
  async buildStart(inputOptions) {
206
216
  if (isBuild && linked && !isSSRBuild) {
207
- const serverMetaFile = await getServerManifestFile(root);
208
- this.addWatchFile(serverMetaFile);
209
217
  try {
210
218
  serverManifest = JSON.parse(
211
- await import_fs.default.promises.readFile(serverMetaFile, "utf-8")
219
+ await store.get(manifestFileName)
212
220
  );
213
221
  inputOptions.input = toHTMLEntries(root, serverManifest.entries);
214
222
  for (const entry in serverManifest.entrySources) {
@@ -339,7 +347,7 @@ function markoPlugin(opts = {}) {
339
347
  let { code } = compiled;
340
348
  if (query !== browserEntryQuery && devServer) {
341
349
  code += `
342
- if (import.meta.hot) import.meta.hot.accept();`;
350
+ if (import.meta.hot) import.meta.hot.accept(() => {});`;
343
351
  }
344
352
  if (devServer) {
345
353
  const templateName = getBasenameWithoutExt(id);
@@ -392,10 +400,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
392
400
  }
393
401
  }
394
402
  }
395
- await import_fs.default.promises.writeFile(
396
- await getServerManifestFile(root),
397
- JSON.stringify(serverManifest)
398
- );
403
+ await store.set(manifestFileName, JSON.stringify(serverManifest));
399
404
  } else {
400
405
  const browserManifest = {};
401
406
  for (const entryId in serverManifest.entries) {
@@ -448,27 +453,6 @@ function toHTMLEntries(root, serverEntries) {
448
453
  }
449
454
  return result;
450
455
  }
451
- async function getServerManifestFile(root) {
452
- return import_path.default.join(await getTempDir(root), "manifest.json");
453
- }
454
- function getTempDir(root) {
455
- return tempDir || (tempDir = (async () => {
456
- const dir = import_path.default.join(
457
- import_os.default.tmpdir(),
458
- `marko-vite-${import_crypto.default.createHash("SHA1").update(root).digest("hex")}`
459
- );
460
- try {
461
- const stat = await import_fs.default.promises.stat(dir);
462
- if (stat.isDirectory()) {
463
- return dir;
464
- }
465
- } catch {
466
- await import_fs.default.promises.mkdir(dir);
467
- return dir;
468
- }
469
- throw new Error("Unable to create temp directory");
470
- })());
471
- }
472
456
  function toEntryId(id) {
473
457
  const lastSepIndex = id.lastIndexOf(import_path.default.sep);
474
458
  let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
@@ -497,6 +481,20 @@ function getBasenameWithoutExt(file) {
497
481
  const extStart = file.indexOf(".", baseStart + 1);
498
482
  return file.slice(baseStart, extStart);
499
483
  }
484
+ function createDeferredPromise() {
485
+ let resolve;
486
+ let reject;
487
+ const promise = new Promise((res, rej) => {
488
+ resolve = res;
489
+ reject = rej;
490
+ });
491
+ promise.resolve = resolve;
492
+ promise.reject = reject;
493
+ return promise;
494
+ }
495
+ function isDeferredPromise(obj) {
496
+ return typeof (obj == null ? void 0 : obj.then) === "function";
497
+ }
500
498
  function isEmpty(obj) {
501
499
  for (const _ in obj) {
502
500
  return false;
package/dist/index.mjs CHANGED
@@ -9,9 +9,15 @@ import "./chunk-VL2HLMVE.mjs";
9
9
  import {
10
10
  server_entry_template_default
11
11
  } from "./chunk-HWRQJHCN.mjs";
12
+ import "./chunk-KIYHBIE6.mjs";
13
+ import {
14
+ MemoryStore
15
+ } from "./chunk-DCBMHGK4.mjs";
16
+ import {
17
+ FileStore
18
+ } from "./chunk-FCWFM7VD.mjs";
12
19
 
13
20
  // src/index.ts
14
- import os from "os";
15
21
  import fs from "fs";
16
22
  import path from "path";
17
23
  import crypto from "crypto";
@@ -24,12 +30,12 @@ var queryReg = /\?marko-.+$/;
24
30
  var browserEntryQuery = "?marko-browser-entry";
25
31
  var serverEntryQuery = "?marko-server-entry";
26
32
  var virtualFileQuery = "?marko-virtual";
33
+ var manifestFileName = "manifest.json";
27
34
  var markoExt = ".marko";
28
35
  var htmlExt = ".html";
29
36
  var resolveOpts = { skipSelf: true };
30
37
  var cache = /* @__PURE__ */ new Map();
31
38
  var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
32
- var tempDir;
33
39
  function markoPlugin(opts = {}) {
34
40
  var _a;
35
41
  let compiler;
@@ -56,10 +62,8 @@ function markoPlugin(opts = {}) {
56
62
  const id = normalizePath(from) + query;
57
63
  if (devServer) {
58
64
  const prev = virtualFiles.get(id);
59
- if (prev && prev.code !== dep.code) {
60
- devServer.moduleGraph.invalidateModule(
61
- devServer.moduleGraph.getModuleById(id)
62
- );
65
+ if (isDeferredPromise(prev)) {
66
+ prev.resolve(dep);
63
67
  }
64
68
  }
65
69
  virtualFiles.set(id, dep);
@@ -87,6 +91,7 @@ function markoPlugin(opts = {}) {
87
91
  let devServer;
88
92
  let registeredTag = false;
89
93
  let serverManifest;
94
+ let store;
90
95
  const entrySources = /* @__PURE__ */ new Map();
91
96
  const transformWatchFiles = /* @__PURE__ */ new Map();
92
97
  const transformOptionalFiles = /* @__PURE__ */ new Map();
@@ -101,6 +106,9 @@ function markoPlugin(opts = {}) {
101
106
  devEntryFile = path.join(root, "index.html");
102
107
  isBuild = env.command === "build";
103
108
  isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
109
+ store = opts.store || new FileStore(
110
+ `marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
111
+ );
104
112
  if (linked && !registeredTag) {
105
113
  const transformer = path.resolve(
106
114
  thisFile,
@@ -158,6 +166,8 @@ function markoPlugin(opts = {}) {
158
166
  devServer.watcher.on("all", (type, filename) => {
159
167
  if (type === "unlink") {
160
168
  entrySources.delete(filename);
169
+ transformWatchFiles.delete(filename);
170
+ transformOptionalFiles.delete(filename);
161
171
  }
162
172
  for (const [id, files] of transformWatchFiles) {
163
173
  if (anyMatch(files, filename)) {
@@ -165,26 +175,28 @@ function markoPlugin(opts = {}) {
165
175
  }
166
176
  }
167
177
  if (type === "add" || type === "unlink") {
168
- let clearedCache = false;
169
178
  for (const [id, files] of transformOptionalFiles) {
170
179
  if (anyMatch(files, filename)) {
171
- if (!clearedCache) {
172
- baseConfig.cache.clear();
173
- clearedCache = true;
174
- }
175
180
  devServer.watcher.emit("change", id);
176
181
  }
177
182
  }
178
183
  }
179
184
  });
180
185
  },
186
+ handleHotUpdate(ctx) {
187
+ compiler.taglib.clearCaches();
188
+ baseConfig.cache.clear();
189
+ for (const mod of ctx.modules) {
190
+ if (mod.id && virtualFiles.has(mod.id)) {
191
+ virtualFiles.set(mod.id, createDeferredPromise());
192
+ }
193
+ }
194
+ },
181
195
  async buildStart(inputOptions) {
182
196
  if (isBuild && linked && !isSSRBuild) {
183
- const serverMetaFile = await getServerManifestFile(root);
184
- this.addWatchFile(serverMetaFile);
185
197
  try {
186
198
  serverManifest = JSON.parse(
187
- await fs.promises.readFile(serverMetaFile, "utf-8")
199
+ await store.get(manifestFileName)
188
200
  );
189
201
  inputOptions.input = toHTMLEntries(root, serverManifest.entries);
190
202
  for (const entry in serverManifest.entrySources) {
@@ -315,7 +327,7 @@ function markoPlugin(opts = {}) {
315
327
  let { code } = compiled;
316
328
  if (query !== browserEntryQuery && devServer) {
317
329
  code += `
318
- if (import.meta.hot) import.meta.hot.accept();`;
330
+ if (import.meta.hot) import.meta.hot.accept(() => {});`;
319
331
  }
320
332
  if (devServer) {
321
333
  const templateName = getBasenameWithoutExt(id);
@@ -368,10 +380,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
368
380
  }
369
381
  }
370
382
  }
371
- await fs.promises.writeFile(
372
- await getServerManifestFile(root),
373
- JSON.stringify(serverManifest)
374
- );
383
+ await store.set(manifestFileName, JSON.stringify(serverManifest));
375
384
  } else {
376
385
  const browserManifest = {};
377
386
  for (const entryId in serverManifest.entries) {
@@ -424,27 +433,6 @@ function toHTMLEntries(root, serverEntries) {
424
433
  }
425
434
  return result;
426
435
  }
427
- async function getServerManifestFile(root) {
428
- return path.join(await getTempDir(root), "manifest.json");
429
- }
430
- function getTempDir(root) {
431
- return tempDir || (tempDir = (async () => {
432
- const dir = path.join(
433
- os.tmpdir(),
434
- `marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
435
- );
436
- try {
437
- const stat = await fs.promises.stat(dir);
438
- if (stat.isDirectory()) {
439
- return dir;
440
- }
441
- } catch {
442
- await fs.promises.mkdir(dir);
443
- return dir;
444
- }
445
- throw new Error("Unable to create temp directory");
446
- })());
447
- }
448
436
  function toEntryId(id) {
449
437
  const lastSepIndex = id.lastIndexOf(path.sep);
450
438
  let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
@@ -473,6 +461,20 @@ function getBasenameWithoutExt(file) {
473
461
  const extStart = file.indexOf(".", baseStart + 1);
474
462
  return file.slice(baseStart, extStart);
475
463
  }
464
+ function createDeferredPromise() {
465
+ let resolve;
466
+ let reject;
467
+ const promise = new Promise((res, rej) => {
468
+ resolve = res;
469
+ reject = rej;
470
+ });
471
+ promise.resolve = resolve;
472
+ promise.reject = reject;
473
+ return promise;
474
+ }
475
+ function isDeferredPromise(obj) {
476
+ return typeof (obj == null ? void 0 : obj.then) === "function";
477
+ }
476
478
  function isEmpty(obj) {
477
479
  for (const _ in obj) {
478
480
  return false;
@@ -480,5 +482,7 @@ function isEmpty(obj) {
480
482
  return true;
481
483
  }
482
484
  export {
485
+ FileStore,
486
+ MemoryStore,
483
487
  markoPlugin as default
484
488
  };
@@ -0,0 +1,11 @@
1
+ import type { BuildStore } from "./types";
2
+ export default class FileStore implements BuildStore {
3
+ _id: string;
4
+ _temp: Promise<string> | undefined;
5
+ _cache: Map<string, string>;
6
+ constructor(id: string);
7
+ _getKeyPath(key: string): Promise<string>;
8
+ has(key: string): Promise<boolean>;
9
+ get(key: string): Promise<string | undefined>;
10
+ set(key: string, value: string): Promise<void>;
11
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var file_store_exports = {};
30
+ __export(file_store_exports, {
31
+ default: () => FileStore
32
+ });
33
+ module.exports = __toCommonJS(file_store_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_os = __toESM(require("os"));
37
+ class FileStore {
38
+ _id;
39
+ _temp;
40
+ _cache;
41
+ constructor(id) {
42
+ this._id = id;
43
+ this._cache = /* @__PURE__ */ new Map();
44
+ }
45
+ async _getKeyPath(key) {
46
+ this._temp ?? (this._temp = getTempDir(this._id));
47
+ return import_path.default.join(await this._temp, key);
48
+ }
49
+ async has(key) {
50
+ if (!this._cache.has(key)) {
51
+ const path2 = await this._getKeyPath(key);
52
+ try {
53
+ await import_fs.default.promises.access(path2);
54
+ } catch (e) {
55
+ return false;
56
+ }
57
+ }
58
+ return true;
59
+ }
60
+ async get(key) {
61
+ let value = this._cache.get(key);
62
+ if (value === void 0) {
63
+ const path2 = await this._getKeyPath(key);
64
+ try {
65
+ value = await import_fs.default.promises.readFile(path2, "utf-8");
66
+ } catch (e) {
67
+ return void 0;
68
+ }
69
+ this._cache.set(key, value);
70
+ }
71
+ return value;
72
+ }
73
+ async set(key, value) {
74
+ this._cache.set(key, value);
75
+ const path2 = await this._getKeyPath(key);
76
+ await import_fs.default.promises.writeFile(path2, value, "utf-8");
77
+ }
78
+ }
79
+ async function getTempDir(id) {
80
+ const dir = import_path.default.join(import_os.default.tmpdir(), id);
81
+ try {
82
+ const stat = await import_fs.default.promises.stat(dir);
83
+ if (stat.isDirectory()) {
84
+ return dir;
85
+ }
86
+ } catch {
87
+ await import_fs.default.promises.mkdir(dir);
88
+ return dir;
89
+ }
90
+ throw new Error("Unable to create temp directory");
91
+ }
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {});
@@ -0,0 +1,6 @@
1
+ import {
2
+ FileStore
3
+ } from "../chunk-FCWFM7VD.mjs";
4
+ export {
5
+ FileStore as default
6
+ };
@@ -0,0 +1,3 @@
1
+ export { default as FileStore } from "./file-store";
2
+ export { default as MemoryStore } from "./memory-store";
3
+ export type { BuildStore } from "./types";
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var store_exports = {};
30
+ __export(store_exports, {
31
+ FileStore: () => import_file_store.default,
32
+ MemoryStore: () => import_memory_store.default
33
+ });
34
+ module.exports = __toCommonJS(store_exports);
35
+ var import_file_store = __toESM(require("./file-store"));
36
+ var import_memory_store = __toESM(require("./memory-store"));
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ FileStore,
40
+ MemoryStore
41
+ });
@@ -0,0 +1,11 @@
1
+ import "../chunk-KIYHBIE6.mjs";
2
+ import {
3
+ MemoryStore
4
+ } from "../chunk-DCBMHGK4.mjs";
5
+ import {
6
+ FileStore
7
+ } from "../chunk-FCWFM7VD.mjs";
8
+ export {
9
+ FileStore,
10
+ MemoryStore
11
+ };
@@ -0,0 +1,8 @@
1
+ import type { BuildStore } from "./types";
2
+ export default class MemoryStore implements BuildStore {
3
+ _store: Map<string, string>;
4
+ constructor();
5
+ has(key: string): Promise<boolean>;
6
+ get(key: string): Promise<string | undefined>;
7
+ set(key: string, value: string): Promise<void>;
8
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var memory_store_exports = {};
20
+ __export(memory_store_exports, {
21
+ default: () => MemoryStore
22
+ });
23
+ module.exports = __toCommonJS(memory_store_exports);
24
+ class MemoryStore {
25
+ _store;
26
+ constructor() {
27
+ this._store = /* @__PURE__ */ new Map();
28
+ }
29
+ async has(key) {
30
+ return Promise.resolve(this._store.has(key));
31
+ }
32
+ async get(key) {
33
+ return Promise.resolve(this._store.get(key));
34
+ }
35
+ async set(key, value) {
36
+ this._store.set(key, value);
37
+ }
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {});
@@ -0,0 +1,6 @@
1
+ import {
2
+ MemoryStore
3
+ } from "../chunk-DCBMHGK4.mjs";
4
+ export {
5
+ MemoryStore as default
6
+ };
@@ -0,0 +1,5 @@
1
+ export interface BuildStore {
2
+ has(key: string): Promise<boolean>;
3
+ get(key: string): Promise<string | undefined>;
4
+ set(key: string, value: string): Promise<void>;
5
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
File without changes
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.10",
4
+ "version": "2.3.12",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {