@danielx/civet 0.7.11 → 0.7.13

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/astro.js CHANGED
@@ -108,6 +108,7 @@ var rawPlugin = (options = {}, meta) => {
108
108
  getCanonicalFileName: sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
109
109
  };
110
110
  };
111
+ const cache = options.cache ? /* @__PURE__ */ new Map() : void 0;
111
112
  return {
112
113
  name: "unplugin-civet",
113
114
  enforce: "pre",
@@ -320,6 +321,14 @@ var rawPlugin = (options = {}, meta) => {
320
321
  return null;
321
322
  const basename = id.slice(0, match.index + match[1].length);
322
323
  const filename = import_path.default.resolve(rootDir, basename);
324
+ let mtime;
325
+ if (cache) {
326
+ mtime = (await fs.promises.stat(filename)).mtimeMs;
327
+ const cached = cache?.get(filename);
328
+ if (cached && cached.mtime === mtime) {
329
+ return cached.result;
330
+ }
331
+ }
323
332
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
324
333
  this.addWatchFile(filename);
325
334
  let compiled;
@@ -403,6 +412,7 @@ var rawPlugin = (options = {}, meta) => {
403
412
  };
404
413
  if (options.transformOutput)
405
414
  transformed = await options.transformOutput(transformed.code, id);
415
+ cache?.set(filename, { mtime, result: transformed });
406
416
  return transformed;
407
417
  },
408
418
  esbuild: {