@danielx/civet 0.11.1 → 0.11.3

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.
@@ -40,7 +40,180 @@ var import_config = require("@danielx/civet/config");
40
40
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
41
  var fs = __toESM(require("fs"));
42
42
  var import_path = __toESM(require("path"));
43
- var tsvfs = __toESM(require("@typescript/vfs"));
43
+
44
+ // node_modules/@typescript/vfs/dist/vfs.esm.js
45
+ function _extends() {
46
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
47
+ for (var i = 1; i < arguments.length; i++) {
48
+ var source = arguments[i];
49
+ for (var key in source) {
50
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
51
+ target[key] = source[key];
52
+ }
53
+ }
54
+ }
55
+ return target;
56
+ };
57
+ return _extends.apply(this, arguments);
58
+ }
59
+ var hasLocalStorage = false;
60
+ try {
61
+ hasLocalStorage = typeof localStorage !== "undefined";
62
+ } catch (error) {
63
+ }
64
+ var hasProcess = typeof process !== "undefined";
65
+ var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
66
+ var debugLog = shouldDebug ? console.log : function(_message) {
67
+ return "";
68
+ };
69
+ function notImplemented(methodName) {
70
+ throw new Error("Method '" + methodName + "' is not implemented.");
71
+ }
72
+ function audit(name, fn) {
73
+ return function() {
74
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
75
+ args[_key] = arguments[_key];
76
+ }
77
+ var res = fn.apply(void 0, args);
78
+ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;
79
+ debugLog.apply(void 0, ["> " + name].concat(args));
80
+ debugLog("< " + smallres);
81
+ return res;
82
+ };
83
+ }
84
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
85
+ return _extends({}, ts.getDefaultCompilerOptions(), {
86
+ jsx: ts.JsxEmit.React,
87
+ strict: true,
88
+ esModuleInterop: true,
89
+ module: ts.ModuleKind.ESNext,
90
+ suppressOutputPathCheck: true,
91
+ skipLibCheck: true,
92
+ skipDefaultLibCheck: true,
93
+ moduleResolution: ts.ModuleResolutionKind.NodeJs
94
+ });
95
+ };
96
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
97
+ var root = _projectRoot + "/vfs";
98
+ var path2 = requirePath();
99
+ var nodeSys = ts.sys;
100
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path2.dirname(require.resolve("typescript"));
101
+ return {
102
+ // @ts-ignore
103
+ name: "fs-vfs",
104
+ root,
105
+ args: [],
106
+ createDirectory: function createDirectory() {
107
+ return notImplemented("createDirectory");
108
+ },
109
+ // TODO: could make a real file tree
110
+ directoryExists: audit("directoryExists", function(directory) {
111
+ return Array.from(files.keys()).some(function(path3) {
112
+ return path3.startsWith(directory);
113
+ }) || nodeSys.directoryExists(directory);
114
+ }),
115
+ exit: nodeSys.exit,
116
+ fileExists: audit("fileExists", function(fileName) {
117
+ if (files.has(fileName)) return true;
118
+ if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
119
+ if (fileName.startsWith("/lib")) {
120
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
121
+ return nodeSys.fileExists(tsLibName);
122
+ }
123
+ return nodeSys.fileExists(fileName);
124
+ }),
125
+ getCurrentDirectory: function getCurrentDirectory() {
126
+ return root;
127
+ },
128
+ getDirectories: nodeSys.getDirectories,
129
+ getExecutingFilePath: function getExecutingFilePath() {
130
+ return notImplemented("getExecutingFilePath");
131
+ },
132
+ readDirectory: audit("readDirectory", function() {
133
+ if ((arguments.length <= 0 ? void 0 : arguments[0]) === "/") {
134
+ return Array.from(files.keys());
135
+ } else {
136
+ return nodeSys.readDirectory.apply(nodeSys, arguments);
137
+ }
138
+ }),
139
+ readFile: audit("readFile", function(fileName) {
140
+ if (files.has(fileName)) return files.get(fileName);
141
+ if (fileName.startsWith("/lib")) {
142
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
143
+ var result = nodeSys.readFile(tsLibName);
144
+ if (!result) {
145
+ var libs = nodeSys.readDirectory(tsLib);
146
+ throw new Error("TSVFS: A request was made for " + tsLibName + " but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: " + libs + ".");
147
+ }
148
+ return result;
149
+ }
150
+ return nodeSys.readFile(fileName);
151
+ }),
152
+ resolvePath: function resolvePath(path3) {
153
+ if (files.has(path3)) return path3;
154
+ return nodeSys.resolvePath(path3);
155
+ },
156
+ newLine: "\n",
157
+ useCaseSensitiveFileNames: true,
158
+ write: function write() {
159
+ return notImplemented("write");
160
+ },
161
+ writeFile: function writeFile(fileName, contents) {
162
+ files.set(fileName, contents);
163
+ },
164
+ deleteFile: function deleteFile(fileName) {
165
+ files["delete"](fileName);
166
+ },
167
+ realpath: nodeSys.realpath
168
+ };
169
+ }
170
+ function createVirtualCompilerHost(sys, compilerOptions, ts) {
171
+ var sourceFiles = /* @__PURE__ */ new Map();
172
+ var save = function save2(sourceFile) {
173
+ sourceFiles.set(sourceFile.fileName, sourceFile);
174
+ return sourceFile;
175
+ };
176
+ var vHost = {
177
+ compilerHost: _extends({}, sys, {
178
+ getCanonicalFileName: function getCanonicalFileName(fileName) {
179
+ return fileName;
180
+ },
181
+ getDefaultLibFileName: function getDefaultLibFileName() {
182
+ return "/" + ts.getDefaultLibFileName(compilerOptions);
183
+ },
184
+ // '/lib.d.ts',
185
+ // getDefaultLibLocation: () => '/',
186
+ getNewLine: function getNewLine() {
187
+ return sys.newLine;
188
+ },
189
+ getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
190
+ var _ref;
191
+ return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
192
+ },
193
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
194
+ return sys.useCaseSensitiveFileNames;
195
+ }
196
+ }),
197
+ updateFile: function updateFile(sourceFile) {
198
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
199
+ sys.writeFile(sourceFile.fileName, sourceFile.text);
200
+ sourceFiles.set(sourceFile.fileName, sourceFile);
201
+ return alreadyExists;
202
+ },
203
+ deleteFile: function deleteFile(sourceFile) {
204
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
205
+ sourceFiles["delete"](sourceFile.fileName);
206
+ sys.deleteFile(sourceFile.fileName);
207
+ return alreadyExists;
208
+ }
209
+ };
210
+ return vHost;
211
+ }
212
+ var requirePath = function requirePath2() {
213
+ return require(String.fromCharCode(112, 97, 116, 104));
214
+ };
215
+
216
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
44
217
  var import_os = __toESM(require("os"));
45
218
 
46
219
  // source/unplugin/constants.mjs
@@ -56,6 +229,7 @@ var postfixRE = /[?#].*$/s;
56
229
  var isWindows = import_os.default.platform() === "win32";
57
230
  var windowsSlashRE = /\\/g;
58
231
  var civetSuffix = ".civet";
232
+ var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
59
233
  function extractCivetFilename(id, outputExtension) {
60
234
  let postfix = "";
61
235
  let filename = id.replace(postfixRE, (match) => {
@@ -127,6 +301,7 @@ var rawPlugin = (options = {}, meta) => {
127
301
  let esbuildOptions;
128
302
  let configErrors;
129
303
  let configFileNames;
304
+ let skipWorker = false;
130
305
  let ref;
131
306
  if (transformTS || ts === "tsc") {
132
307
  ref = import("typescript").then(($1) => $1.default);
@@ -217,7 +392,7 @@ var rawPlugin = (options = {}, meta) => {
217
392
  async buildEnd(useConfigFileNames = false) {
218
393
  if (transformTS) {
219
394
  const ts2 = await tsPromise;
220
- const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts2);
395
+ const system = createFSBackedSystem(fsMap, process.cwd(), ts2);
221
396
  const {
222
397
  fileExists: systemFileExists,
223
398
  readFile: systemReadFile,
@@ -278,7 +453,7 @@ var rawPlugin = (options = {}, meta) => {
278
453
  sourceMaps.set(filename, sourceMap);
279
454
  return compiledTS;
280
455
  };
281
- const host = tsvfs.createVirtualCompilerHost(
456
+ const host = createVirtualCompilerHost(
282
457
  system,
283
458
  compilerOptions,
284
459
  ts2
@@ -415,13 +590,14 @@ var rawPlugin = (options = {}, meta) => {
415
590
  return resolved + outExt + postfix;
416
591
  },
417
592
  loadInclude(id) {
418
- return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
593
+ const { filename, postfix } = extractCivetFilename(id, outExt);
594
+ if (skipWorker && workerRE.test(postfix)) {
595
+ return false;
596
+ }
597
+ return filename.endsWith(civetSuffix);
419
598
  },
420
599
  async load(id) {
421
600
  let { filename } = extractCivetFilename(id, outExt);
422
- if (!filename.endsWith(civetSuffix)) {
423
- return null;
424
- }
425
601
  filename = import_path.default.resolve(rootDir, filename);
426
602
  this.addWatchFile(filename);
427
603
  let mtime, cached, resolve;
@@ -563,6 +739,9 @@ var rawPlugin = (options = {}, meta) => {
563
739
  },
564
740
  vite: {
565
741
  config(config) {
742
+ if (this?.meta?.viteVersion && 7 <= Number(this.meta.viteVersion.split(".")[0])) {
743
+ skipWorker = true;
744
+ }
566
745
  rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
567
746
  if (implicitExtension) {
568
747
  config.resolve ??= {};
@@ -592,10 +771,11 @@ var rawPlugin = (options = {}, meta) => {
592
771
  return;
593
772
  }
594
773
  const resolvedId = slash(import_path.default.resolve(file) + outExt);
595
- const module2 = server.moduleGraph.getModuleById(resolvedId);
596
- if (module2) {
774
+ let ref4;
775
+ if (ref4 = server.moduleGraph.getModulesByFile(resolvedId)) {
776
+ const fileModules = ref4;
597
777
  server.moduleGraph.onFileChange(resolvedId);
598
- return [...modules, module2];
778
+ return [...modules, ...fileModules];
599
779
  }
600
780
  return modules;
601
781
  }
@@ -618,9 +798,9 @@ var rawPlugin = (options = {}, meta) => {
618
798
  compiler.options.resolve.extensions.unshift(".civet");
619
799
  }
620
800
  return aliasResolver = (id) => {
621
- let ref4;
622
- for (const key in ref4 = compiler.options.resolve.alias) {
623
- const value = ref4[key];
801
+ let ref5;
802
+ for (const key in ref5 = compiler.options.resolve.alias) {
803
+ const value = ref5[key];
624
804
  if (key.endsWith("$")) {
625
805
  if (id === key.slice(0, -1)) {
626
806
  return typeof value === "string" ? value : "\0";
@@ -1,3 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
2
9
  import { createUnplugin } from "unplugin";
3
10
  import civet, { decode, lib, SourceMap } from "@danielx/civet";
@@ -8,7 +15,180 @@ import {
8
15
  } from "@danielx/civet/ts-diagnostic";
9
16
  import * as fs from "fs";
10
17
  import path from "path";
11
- import * as tsvfs from "@typescript/vfs";
18
+
19
+ // node_modules/@typescript/vfs/dist/vfs.esm.js
20
+ function _extends() {
21
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
22
+ for (var i = 1; i < arguments.length; i++) {
23
+ var source = arguments[i];
24
+ for (var key in source) {
25
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
26
+ target[key] = source[key];
27
+ }
28
+ }
29
+ }
30
+ return target;
31
+ };
32
+ return _extends.apply(this, arguments);
33
+ }
34
+ var hasLocalStorage = false;
35
+ try {
36
+ hasLocalStorage = typeof localStorage !== "undefined";
37
+ } catch (error) {
38
+ }
39
+ var hasProcess = typeof process !== "undefined";
40
+ var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
41
+ var debugLog = shouldDebug ? console.log : function(_message) {
42
+ return "";
43
+ };
44
+ function notImplemented(methodName) {
45
+ throw new Error("Method '" + methodName + "' is not implemented.");
46
+ }
47
+ function audit(name, fn) {
48
+ return function() {
49
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
+ args[_key] = arguments[_key];
51
+ }
52
+ var res = fn.apply(void 0, args);
53
+ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;
54
+ debugLog.apply(void 0, ["> " + name].concat(args));
55
+ debugLog("< " + smallres);
56
+ return res;
57
+ };
58
+ }
59
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
60
+ return _extends({}, ts.getDefaultCompilerOptions(), {
61
+ jsx: ts.JsxEmit.React,
62
+ strict: true,
63
+ esModuleInterop: true,
64
+ module: ts.ModuleKind.ESNext,
65
+ suppressOutputPathCheck: true,
66
+ skipLibCheck: true,
67
+ skipDefaultLibCheck: true,
68
+ moduleResolution: ts.ModuleResolutionKind.NodeJs
69
+ });
70
+ };
71
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
72
+ var root = _projectRoot + "/vfs";
73
+ var path2 = requirePath();
74
+ var nodeSys = ts.sys;
75
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path2.dirname(__require.resolve("typescript"));
76
+ return {
77
+ // @ts-ignore
78
+ name: "fs-vfs",
79
+ root,
80
+ args: [],
81
+ createDirectory: function createDirectory() {
82
+ return notImplemented("createDirectory");
83
+ },
84
+ // TODO: could make a real file tree
85
+ directoryExists: audit("directoryExists", function(directory) {
86
+ return Array.from(files.keys()).some(function(path3) {
87
+ return path3.startsWith(directory);
88
+ }) || nodeSys.directoryExists(directory);
89
+ }),
90
+ exit: nodeSys.exit,
91
+ fileExists: audit("fileExists", function(fileName) {
92
+ if (files.has(fileName)) return true;
93
+ if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
94
+ if (fileName.startsWith("/lib")) {
95
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
96
+ return nodeSys.fileExists(tsLibName);
97
+ }
98
+ return nodeSys.fileExists(fileName);
99
+ }),
100
+ getCurrentDirectory: function getCurrentDirectory() {
101
+ return root;
102
+ },
103
+ getDirectories: nodeSys.getDirectories,
104
+ getExecutingFilePath: function getExecutingFilePath() {
105
+ return notImplemented("getExecutingFilePath");
106
+ },
107
+ readDirectory: audit("readDirectory", function() {
108
+ if ((arguments.length <= 0 ? void 0 : arguments[0]) === "/") {
109
+ return Array.from(files.keys());
110
+ } else {
111
+ return nodeSys.readDirectory.apply(nodeSys, arguments);
112
+ }
113
+ }),
114
+ readFile: audit("readFile", function(fileName) {
115
+ if (files.has(fileName)) return files.get(fileName);
116
+ if (fileName.startsWith("/lib")) {
117
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
118
+ var result = nodeSys.readFile(tsLibName);
119
+ if (!result) {
120
+ var libs = nodeSys.readDirectory(tsLib);
121
+ throw new Error("TSVFS: A request was made for " + tsLibName + " but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: " + libs + ".");
122
+ }
123
+ return result;
124
+ }
125
+ return nodeSys.readFile(fileName);
126
+ }),
127
+ resolvePath: function resolvePath(path3) {
128
+ if (files.has(path3)) return path3;
129
+ return nodeSys.resolvePath(path3);
130
+ },
131
+ newLine: "\n",
132
+ useCaseSensitiveFileNames: true,
133
+ write: function write() {
134
+ return notImplemented("write");
135
+ },
136
+ writeFile: function writeFile(fileName, contents) {
137
+ files.set(fileName, contents);
138
+ },
139
+ deleteFile: function deleteFile(fileName) {
140
+ files["delete"](fileName);
141
+ },
142
+ realpath: nodeSys.realpath
143
+ };
144
+ }
145
+ function createVirtualCompilerHost(sys, compilerOptions, ts) {
146
+ var sourceFiles = /* @__PURE__ */ new Map();
147
+ var save = function save2(sourceFile) {
148
+ sourceFiles.set(sourceFile.fileName, sourceFile);
149
+ return sourceFile;
150
+ };
151
+ var vHost = {
152
+ compilerHost: _extends({}, sys, {
153
+ getCanonicalFileName: function getCanonicalFileName(fileName) {
154
+ return fileName;
155
+ },
156
+ getDefaultLibFileName: function getDefaultLibFileName() {
157
+ return "/" + ts.getDefaultLibFileName(compilerOptions);
158
+ },
159
+ // '/lib.d.ts',
160
+ // getDefaultLibLocation: () => '/',
161
+ getNewLine: function getNewLine() {
162
+ return sys.newLine;
163
+ },
164
+ getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
165
+ var _ref;
166
+ return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
167
+ },
168
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
169
+ return sys.useCaseSensitiveFileNames;
170
+ }
171
+ }),
172
+ updateFile: function updateFile(sourceFile) {
173
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
174
+ sys.writeFile(sourceFile.fileName, sourceFile.text);
175
+ sourceFiles.set(sourceFile.fileName, sourceFile);
176
+ return alreadyExists;
177
+ },
178
+ deleteFile: function deleteFile(sourceFile) {
179
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
180
+ sourceFiles["delete"](sourceFile.fileName);
181
+ sys.deleteFile(sourceFile.fileName);
182
+ return alreadyExists;
183
+ }
184
+ };
185
+ return vHost;
186
+ }
187
+ var requirePath = function requirePath2() {
188
+ return __require(String.fromCharCode(112, 97, 116, 104));
189
+ };
190
+
191
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
12
192
  import os from "os";
13
193
 
14
194
  // source/unplugin/constants.mjs
@@ -24,6 +204,7 @@ var postfixRE = /[?#].*$/s;
24
204
  var isWindows = os.platform() === "win32";
25
205
  var windowsSlashRE = /\\/g;
26
206
  var civetSuffix = ".civet";
207
+ var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
27
208
  function extractCivetFilename(id, outputExtension) {
28
209
  let postfix = "";
29
210
  let filename = id.replace(postfixRE, (match) => {
@@ -95,6 +276,7 @@ var rawPlugin = (options = {}, meta) => {
95
276
  let esbuildOptions;
96
277
  let configErrors;
97
278
  let configFileNames;
279
+ let skipWorker = false;
98
280
  let ref;
99
281
  if (transformTS || ts === "tsc") {
100
282
  ref = import("typescript").then(($1) => $1.default);
@@ -185,7 +367,7 @@ var rawPlugin = (options = {}, meta) => {
185
367
  async buildEnd(useConfigFileNames = false) {
186
368
  if (transformTS) {
187
369
  const ts2 = await tsPromise;
188
- const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts2);
370
+ const system = createFSBackedSystem(fsMap, process.cwd(), ts2);
189
371
  const {
190
372
  fileExists: systemFileExists,
191
373
  readFile: systemReadFile,
@@ -246,7 +428,7 @@ var rawPlugin = (options = {}, meta) => {
246
428
  sourceMaps.set(filename, sourceMap);
247
429
  return compiledTS;
248
430
  };
249
- const host = tsvfs.createVirtualCompilerHost(
431
+ const host = createVirtualCompilerHost(
250
432
  system,
251
433
  compilerOptions,
252
434
  ts2
@@ -383,13 +565,14 @@ var rawPlugin = (options = {}, meta) => {
383
565
  return resolved + outExt + postfix;
384
566
  },
385
567
  loadInclude(id) {
386
- return extractCivetFilename(id, outExt).filename.endsWith(civetSuffix);
568
+ const { filename, postfix } = extractCivetFilename(id, outExt);
569
+ if (skipWorker && workerRE.test(postfix)) {
570
+ return false;
571
+ }
572
+ return filename.endsWith(civetSuffix);
387
573
  },
388
574
  async load(id) {
389
575
  let { filename } = extractCivetFilename(id, outExt);
390
- if (!filename.endsWith(civetSuffix)) {
391
- return null;
392
- }
393
576
  filename = path.resolve(rootDir, filename);
394
577
  this.addWatchFile(filename);
395
578
  let mtime, cached, resolve;
@@ -531,6 +714,9 @@ var rawPlugin = (options = {}, meta) => {
531
714
  },
532
715
  vite: {
533
716
  config(config) {
717
+ if (this?.meta?.viteVersion && 7 <= Number(this.meta.viteVersion.split(".")[0])) {
718
+ skipWorker = true;
719
+ }
534
720
  rootDir = path.resolve(process.cwd(), config.root ?? "");
535
721
  if (implicitExtension) {
536
722
  config.resolve ??= {};
@@ -560,10 +746,11 @@ var rawPlugin = (options = {}, meta) => {
560
746
  return;
561
747
  }
562
748
  const resolvedId = slash(path.resolve(file) + outExt);
563
- const module = server.moduleGraph.getModuleById(resolvedId);
564
- if (module) {
749
+ let ref4;
750
+ if (ref4 = server.moduleGraph.getModulesByFile(resolvedId)) {
751
+ const fileModules = ref4;
565
752
  server.moduleGraph.onFileChange(resolvedId);
566
- return [...modules, module];
753
+ return [...modules, ...fileModules];
567
754
  }
568
755
  return modules;
569
756
  }
@@ -586,9 +773,9 @@ var rawPlugin = (options = {}, meta) => {
586
773
  compiler.options.resolve.extensions.unshift(".civet");
587
774
  }
588
775
  return aliasResolver = (id) => {
589
- let ref4;
590
- for (const key in ref4 = compiler.options.resolve.alias) {
591
- const value = ref4[key];
776
+ let ref5;
777
+ for (const key in ref5 = compiler.options.resolve.alias) {
778
+ const value = ref5[key];
592
779
  if (key.endsWith("$")) {
593
780
  if (id === key.slice(0, -1)) {
594
781
  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.3",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -95,6 +95,7 @@
95
95
  },
96
96
  "scripts": {
97
97
  "build": "bash ./build/build.sh",
98
+ "build:self": "yarn build && bash ./build/build-self.sh",
98
99
  "docs:dev": "yarn build && vitepress dev civet.dev",
99
100
  "docs:build": "yarn build && vitepress build civet.dev",
100
101
  "docs:preview": "yarn build && vitepress preview civet.dev",
@@ -107,7 +108,6 @@
107
108
  "license": "MIT",
108
109
  "dependencies": {
109
110
  "@cspotcode/source-map-support": "^0.8.1",
110
- "@typescript/vfs": "^1.6.0",
111
111
  "unplugin": "^2.3.2"
112
112
  },
113
113
  "devDependencies": {
@@ -117,6 +117,7 @@
117
117
  "@types/assert": "^1.5.6",
118
118
  "@types/mocha": "^10.0.8",
119
119
  "@types/node": "^22.10.2",
120
+ "@typescript/vfs": "^1.6.0",
120
121
  "c8": "^7.12.0",
121
122
  "esbuild": "0.24.0",
122
123
  "marked": "^4.2.4",
@@ -137,6 +138,9 @@
137
138
  "yaml": "^2.4.5"
138
139
  },
139
140
  "peerDependenciesMeta": {
141
+ "typescript": {
142
+ "optional": true
143
+ },
140
144
  "yaml": {
141
145
  "optional": true
142
146
  }