@danielx/civet 0.11.1 → 0.11.2

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/types.d.ts CHANGED
@@ -53,6 +53,10 @@ declare module "@danielx/civet" {
53
53
  * in sourcemaps and error messages.
54
54
  */
55
55
  filename?: string
56
+ /**
57
+ * Output (transpiled) filename to record in inline source maps.
58
+ */
59
+ outputFilename?: string
56
60
  /**
57
61
  * Whether to return a source map in addition to transpiled code.
58
62
  * If false (the default), `compile` just returns transpiled code.
@@ -56,6 +56,7 @@ var postfixRE = /[?#].*$/s;
56
56
  var isWindows = import_os.default.platform() === "win32";
57
57
  var windowsSlashRE = /\\/g;
58
58
  var civetSuffix = ".civet";
59
+ var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
59
60
  function extractCivetFilename(id, outputExtension) {
60
61
  let postfix = "";
61
62
  let filename = id.replace(postfixRE, (match) => {
@@ -127,6 +128,7 @@ var rawPlugin = (options = {}, meta) => {
127
128
  let esbuildOptions;
128
129
  let configErrors;
129
130
  let configFileNames;
131
+ let skipWorker = false;
130
132
  let ref;
131
133
  if (transformTS || ts === "tsc") {
132
134
  ref = import("typescript").then(($1) => $1.default);
@@ -415,13 +417,14 @@ var rawPlugin = (options = {}, meta) => {
415
417
  return resolved + outExt + postfix;
416
418
  },
417
419
  loadInclude(id) {
418
- return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
420
+ const { filename, postfix } = extractCivetFilename(id, outExt);
421
+ if (skipWorker && workerRE.test(postfix)) {
422
+ return false;
423
+ }
424
+ return filename.endsWith(civetSuffix);
419
425
  },
420
426
  async load(id) {
421
427
  let { filename } = extractCivetFilename(id, outExt);
422
- if (!filename.endsWith(civetSuffix)) {
423
- return null;
424
- }
425
428
  filename = import_path.default.resolve(rootDir, filename);
426
429
  this.addWatchFile(filename);
427
430
  let mtime, cached, resolve;
@@ -563,6 +566,9 @@ var rawPlugin = (options = {}, meta) => {
563
566
  },
564
567
  vite: {
565
568
  config(config) {
569
+ if (this?.meta?.viteVersion && 7 <= Number(this.meta.viteVersion.split(".")[0])) {
570
+ skipWorker = true;
571
+ }
566
572
  rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
567
573
  if (implicitExtension) {
568
574
  config.resolve ??= {};
@@ -592,10 +598,11 @@ var rawPlugin = (options = {}, meta) => {
592
598
  return;
593
599
  }
594
600
  const resolvedId = slash(import_path.default.resolve(file) + outExt);
595
- const module2 = server.moduleGraph.getModuleById(resolvedId);
596
- if (module2) {
601
+ let ref4;
602
+ if (ref4 = server.moduleGraph.getModulesByFile(resolvedId)) {
603
+ const fileModules = ref4;
597
604
  server.moduleGraph.onFileChange(resolvedId);
598
- return [...modules, module2];
605
+ return [...modules, ...fileModules];
599
606
  }
600
607
  return modules;
601
608
  }
@@ -618,9 +625,9 @@ var rawPlugin = (options = {}, meta) => {
618
625
  compiler.options.resolve.extensions.unshift(".civet");
619
626
  }
620
627
  return aliasResolver = (id) => {
621
- let ref4;
622
- for (const key in ref4 = compiler.options.resolve.alias) {
623
- const value = ref4[key];
628
+ let ref5;
629
+ for (const key in ref5 = compiler.options.resolve.alias) {
630
+ const value = ref5[key];
624
631
  if (key.endsWith("$")) {
625
632
  if (id === key.slice(0, -1)) {
626
633
  return typeof value === "string" ? value : "\0";
@@ -24,6 +24,7 @@ var postfixRE = /[?#].*$/s;
24
24
  var isWindows = os.platform() === "win32";
25
25
  var windowsSlashRE = /\\/g;
26
26
  var civetSuffix = ".civet";
27
+ var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
27
28
  function extractCivetFilename(id, outputExtension) {
28
29
  let postfix = "";
29
30
  let filename = id.replace(postfixRE, (match) => {
@@ -95,6 +96,7 @@ var rawPlugin = (options = {}, meta) => {
95
96
  let esbuildOptions;
96
97
  let configErrors;
97
98
  let configFileNames;
99
+ let skipWorker = false;
98
100
  let ref;
99
101
  if (transformTS || ts === "tsc") {
100
102
  ref = import("typescript").then(($1) => $1.default);
@@ -383,13 +385,14 @@ var rawPlugin = (options = {}, meta) => {
383
385
  return resolved + outExt + postfix;
384
386
  },
385
387
  loadInclude(id) {
386
- return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
388
+ const { filename, postfix } = extractCivetFilename(id, outExt);
389
+ if (skipWorker && workerRE.test(postfix)) {
390
+ return false;
391
+ }
392
+ return filename.endsWith(civetSuffix);
387
393
  },
388
394
  async load(id) {
389
395
  let { filename } = extractCivetFilename(id, outExt);
390
- if (!filename.endsWith(civetSuffix)) {
391
- return null;
392
- }
393
396
  filename = path.resolve(rootDir, filename);
394
397
  this.addWatchFile(filename);
395
398
  let mtime, cached, resolve;
@@ -531,6 +534,9 @@ var rawPlugin = (options = {}, meta) => {
531
534
  },
532
535
  vite: {
533
536
  config(config) {
537
+ if (this?.meta?.viteVersion && 7 <= Number(this.meta.viteVersion.split(".")[0])) {
538
+ skipWorker = true;
539
+ }
534
540
  rootDir = path.resolve(process.cwd(), config.root ?? "");
535
541
  if (implicitExtension) {
536
542
  config.resolve ??= {};
@@ -560,10 +566,11 @@ var rawPlugin = (options = {}, meta) => {
560
566
  return;
561
567
  }
562
568
  const resolvedId = slash(path.resolve(file) + outExt);
563
- const module = server.moduleGraph.getModuleById(resolvedId);
564
- if (module) {
569
+ let ref4;
570
+ if (ref4 = server.moduleGraph.getModulesByFile(resolvedId)) {
571
+ const fileModules = ref4;
565
572
  server.moduleGraph.onFileChange(resolvedId);
566
- return [...modules, module];
573
+ return [...modules, ...fileModules];
567
574
  }
568
575
  return modules;
569
576
  }
@@ -586,9 +593,9 @@ var rawPlugin = (options = {}, meta) => {
586
593
  compiler.options.resolve.extensions.unshift(".civet");
587
594
  }
588
595
  return aliasResolver = (id) => {
589
- let ref4;
590
- for (const key in ref4 = compiler.options.resolve.alias) {
591
- const value = ref4[key];
596
+ let ref5;
597
+ for (const key in ref5 = compiler.options.resolve.alias) {
598
+ const value = ref5[key];
592
599
  if (key.endsWith("$")) {
593
600
  if (id === key.slice(0, -1)) {
594
601
  return typeof value === "string" ? value : "\0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.11.1",
4
+ "version": "0.11.2",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",