@danielx/civet 0.7.10 → 0.7.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/dist/civet CHANGED
@@ -122,6 +122,12 @@ function parseArgs(args) {
122
122
  while (i < args.length) {
123
123
  const arg = args[i];
124
124
  if (/^-\w{2,}$/.test(arg)) {
125
+ const results = [];
126
+ for (let ref = arg.slice(1), i1 = 0, len = ref.length; i1 < len; i1++) {
127
+ const char = ref[i1];
128
+ results.push(`-${char}`);
129
+ }
130
+ ;
125
131
  args.splice(i, 1 + i - i, ...results);
126
132
  continue;
127
133
  }
@@ -218,8 +224,8 @@ function parseArgs(args) {
218
224
  }
219
225
  async function* readFiles(filenames) {
220
226
  const results1 = [];
221
- for (let i1 = 0, len = filenames.length; i1 < len; i1++) {
222
- let filename = filenames[i1];
227
+ for (let i2 = 0, len1 = filenames.length; i2 < len1; i2++) {
228
+ let filename = filenames[i2];
223
229
  const stdin = filename === "-";
224
230
  try {
225
231
  let content;
@@ -418,18 +424,17 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
418
424
  return callback(error, void 0);
419
425
  }
420
426
  if (topLevelAwait) {
421
- let threw = false;
427
+ let ok = true;
422
428
  try {
423
- result = await result;
429
+ return result = await result;
424
430
  } catch (error) {
425
- threw = true;
426
- callback(error, void 0);
427
- }
428
- if (!threw) {
429
- return callback(null, result);
431
+ ok = false;
432
+ return callback(error, void 0);
433
+ } finally {
434
+ if (ok) {
435
+ callback(null, result);
436
+ }
430
437
  }
431
- ;
432
- return;
433
438
  } else {
434
439
  return callback(null, result);
435
440
  }
@@ -642,9 +647,9 @@ async function cli() {
642
647
  }
643
648
  });
644
649
  } catch (error) {
645
- let ref;
646
- if (ref = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
647
- const match = ref;
650
+ let ref1;
651
+ if (ref1 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
652
+ const match = ref1;
648
653
  return process.exitCode = Math.min(255, errors + +match[1]);
649
654
  } else {
650
655
  process.exitCode = 1;
package/dist/esbuild.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: {
package/dist/esm.mjs CHANGED
@@ -1,39 +1,10 @@
1
1
  // source/esm.civet
2
2
  import { readFileSync } from "fs";
3
3
  import { pathToFileURL, fileURLToPath } from "url";
4
- import sourceMapSupport from "@cspotcode/source-map-support";
5
4
  import Civet from "./main.js";
6
5
  var { compile, SourceMap } = Civet;
7
6
  var baseURL = pathToFileURL(process.cwd() + "/").href;
8
7
  var extensionsRegex = /\.civet$/;
9
- var registered = false;
10
- var outputCache = /* @__PURE__ */ new Map();
11
- var directorySeparator = "/";
12
- var backslashRegExp = /\\/g;
13
- function normalizeSlashes(value) {
14
- return value.replace(backslashRegExp, directorySeparator);
15
- }
16
- var ensureRegister = function() {
17
- if (registered) {
18
- return;
19
- }
20
- const installation = {
21
- environment: "node",
22
- retrieveFile(pathOrUrl) {
23
- let path = pathOrUrl;
24
- if (path.startsWith("file:")) {
25
- try {
26
- path = fileURLToPath(path);
27
- } catch (e) {
28
- }
29
- }
30
- path = normalizeSlashes(path);
31
- return outputCache.get(path);
32
- }
33
- };
34
- sourceMapSupport.install(installation);
35
- return registered = true;
36
- };
37
8
  function resolve(specifier, context, next) {
38
9
  const { parentURL = baseURL } = context;
39
10
  if (extensionsRegex.test(specifier)) {
@@ -62,10 +33,8 @@ async function load(url, context, next) {
62
33
  // NOTE: Setting the source in the context makes it available when ts-node uses defaultLoad
63
34
  source: tsSource
64
35
  });
65
- ensureRegister();
66
36
  result.responseURL = (result.responseURL ?? transpiledUrl).replace(/.tsx$/, "");
67
37
  result.source = SourceMap.remap(result.source, sourceMap, url, result.responseURL);
68
- outputCache.set(normalizeSlashes(path), result.source);
69
38
  return result;
70
39
  }
71
40
  return next(url, context);