@danielx/civet 0.11.4 → 0.11.6

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.
@@ -1,4 +1,4 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\node-worker.civet.jsx
1
+ // source/node-worker.civet
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import module from "node:module";
4
4
  try {
@@ -22,7 +22,6 @@ try {
22
22
  }
23
23
  return parentPort.postMessage({ id, result, errors: args[1]?.errors });
24
24
  } catch (error) {
25
- console.log(`Civet worker failed to compile:`, error);
26
25
  return parentPort.postMessage({ id, error: {
27
26
  type: error.constructor.name,
28
27
  name: error.name,
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -15,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
15
16
  return to;
16
17
  };
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var ts_diagnostic_civet_exports = {};
19
- __export(ts_diagnostic_civet_exports, {
19
+ var ts_diagnostic_exports = {};
20
+ __export(ts_diagnostic_exports, {
20
21
  flattenDiagnosticMessageText: () => flattenDiagnosticMessageText,
21
22
  remapPosition: () => remapPosition,
22
23
  remapRange: () => remapRange
23
24
  });
24
- module.exports = __toCommonJS(ts_diagnostic_civet_exports);
25
+ module.exports = __toCommonJS(ts_diagnostic_exports);
25
26
  function remapPosition(position, sourcemapLines) {
26
27
  if (!sourcemapLines) return position;
27
28
  const { line, character } = position;
package/dist/types.d.ts CHANGED
@@ -70,6 +70,10 @@ declare module "@danielx/civet" {
70
70
  * Default is false.
71
71
  */
72
72
  inlineMap?: boolean
73
+ /**
74
+ * Upstream source map to chain with Civet's generated source map.
75
+ */
76
+ upstreamSourceMap?: string | object
73
77
  /**
74
78
  * Whether to return an AST of the parsed code instead of transpiled code.
75
79
  * Default is false.
@@ -142,10 +146,13 @@ declare module "@danielx/civet" {
142
146
  export type SourceMapping = [number] | [number, number, number, number]
143
147
 
144
148
  export class SourceMap {
145
- constructor(source: string)
149
+ constructor(source: string, sourceFileName: string)
146
150
  updateSourceMap?(outputStr: string, inputPos: number): void
147
- json(srcFileName: string, outFileName: string): unknown
151
+ json(outFileName: string): unknown
152
+ composeUpstream(upstreamMap: string | object): void
153
+ composeDownstream(downstreamMap: string | object): void
148
154
  source: string
155
+ sourceFileName: string
149
156
  lines: SourceMapping[][]
150
157
  /** @deprecated */
151
158
  data: { lines: SourceMapping[][] }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,14 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\astro.civet.jsx
30
- var astro_civet_exports = {};
31
- __export(astro_civet_exports, {
32
- default: () => astro_civet_default
30
+ // source/unplugin/astro.civet
31
+ var astro_exports = {};
32
+ __export(astro_exports, {
33
+ default: () => astro_default
33
34
  });
34
- module.exports = __toCommonJS(astro_civet_exports);
35
+ module.exports = __toCommonJS(astro_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var astro_civet_default = function(opts = {}) {
37
+ var astro_default = (function(opts = {}) {
37
38
  return {
38
39
  name: "@danielx/civet",
39
40
  hooks: {
@@ -46,4 +47,4 @@ var astro_civet_default = function(opts = {}) {
46
47
  }
47
48
  }
48
49
  };
49
- };
50
+ });
@@ -1,6 +1,8 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\astro.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/astro.civet.jsx
2
4
  import civetUnplugin, {} from "./unplugin.mjs";
3
- var astro_civet_default = function(opts = {}) {
5
+ var astro_civet_default = (function(opts = {}) {
4
6
  return {
5
7
  name: "@danielx/civet",
6
8
  hooks: {
@@ -13,7 +15,7 @@ var astro_civet_default = function(opts = {}) {
13
15
  }
14
16
  }
15
17
  };
16
- };
18
+ });
17
19
  export {
18
20
  astro_civet_default as default
19
21
  };
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\esbuild.civet.jsx
30
- var esbuild_civet_exports = {};
31
- __export(esbuild_civet_exports, {
32
- default: () => esbuild_civet_default
30
+ // source/unplugin/esbuild.civet
31
+ var esbuild_exports = {};
32
+ __export(esbuild_exports, {
33
+ default: () => esbuild_default
33
34
  });
34
- module.exports = __toCommonJS(esbuild_civet_exports);
35
+ module.exports = __toCommonJS(esbuild_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var esbuild_civet_default = import_unplugin.default.esbuild;
37
+ var esbuild_default = import_unplugin.default.esbuild;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\esbuild.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/esbuild.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var esbuild_civet_default = civetUnplugin.esbuild;
4
6
  export {
@@ -1,2 +1,4 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => JsPlugin;
1
+ import type { UnpluginInstance } from "unplugin";
2
+ import { type PluginOptions } from "./unplugin.js";
3
+ declare const _default: UnpluginInstance<PluginOptions>["farm"];
2
4
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\farm.civet.jsx
30
- var farm_civet_exports = {};
31
- __export(farm_civet_exports, {
32
- default: () => farm_civet_default
30
+ // source/unplugin/farm.civet
31
+ var farm_exports = {};
32
+ __export(farm_exports, {
33
+ default: () => farm_default
33
34
  });
34
- module.exports = __toCommonJS(farm_civet_exports);
35
+ module.exports = __toCommonJS(farm_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var farm_civet_default = import_unplugin.default.farm;
37
+ var farm_default = import_unplugin.default.farm;
@@ -1,5 +1,7 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\farm.civet.jsx
2
- import civetUnplugin from "./unplugin.mjs";
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/farm.civet.jsx
4
+ import civetUnplugin, {} from "./unplugin.mjs";
3
5
  var farm_civet_default = civetUnplugin.farm;
4
6
  export {
5
7
  farm_civet_default as default
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => any;
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rolldown.civet.jsx
30
- var rolldown_civet_exports = {};
31
- __export(rolldown_civet_exports, {
32
- default: () => rolldown_civet_default
30
+ // source/unplugin/rolldown.civet
31
+ var rolldown_exports = {};
32
+ __export(rolldown_exports, {
33
+ default: () => rolldown_default
33
34
  });
34
- module.exports = __toCommonJS(rolldown_civet_exports);
35
+ module.exports = __toCommonJS(rolldown_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rolldown_civet_default = import_unplugin.default.rolldown;
37
+ var rolldown_default = import_unplugin.default.rolldown;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rolldown.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rolldown.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var rolldown_civet_default = civetUnplugin.rolldown;
4
6
  export {
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./unplugin.js").PluginOptions) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => import("unplugin").RollupPlugin<any> | import("unplugin").RollupPlugin<any>[];
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rollup.civet.jsx
30
- var rollup_civet_exports = {};
31
- __export(rollup_civet_exports, {
32
- default: () => rollup_civet_default
30
+ // source/unplugin/rollup.civet
31
+ var rollup_exports = {};
32
+ __export(rollup_exports, {
33
+ default: () => rollup_default
33
34
  });
34
- module.exports = __toCommonJS(rollup_civet_exports);
35
+ module.exports = __toCommonJS(rollup_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rollup_civet_default = import_unplugin.default.rollup;
37
+ var rollup_default = import_unplugin.default.rollup;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rollup.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rollup.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var rollup_civet_default = civetUnplugin.rollup;
4
6
  export {
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rspack.civet.jsx
30
- var rspack_civet_exports = {};
31
- __export(rspack_civet_exports, {
32
- default: () => rspack_civet_default
30
+ // source/unplugin/rspack.civet
31
+ var rspack_exports = {};
32
+ __export(rspack_exports, {
33
+ default: () => rspack_default
33
34
  });
34
- module.exports = __toCommonJS(rspack_civet_exports);
35
+ module.exports = __toCommonJS(rspack_exports);
35
36
  var import_unplugin = __toESM(require("./unplugin.js"));
36
- var rspack_civet_default = import_unplugin.default.rspack;
37
+ var rspack_default = import_unplugin.default.rspack;
@@ -1,4 +1,6 @@
1
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\rspack.civet.jsx
1
+ import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
2
+
3
+ // unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/rspack.civet.jsx
2
4
  import civetUnplugin from "./unplugin.mjs";
3
5
  var rspack_civet_default = civetUnplugin.rspack;
4
6
  export {
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,14 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  ));
27
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29
 
29
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
30
- var unplugin_civet_exports = {};
31
- __export(unplugin_civet_exports, {
32
- default: () => unplugin_civet_default,
30
+ // source/unplugin/unplugin.civet
31
+ var unplugin_exports = {};
32
+ __export(unplugin_exports, {
33
+ default: () => unplugin_default,
33
34
  rawPlugin: () => rawPlugin,
34
35
  slash: () => slash
35
36
  });
36
- module.exports = __toCommonJS(unplugin_civet_exports);
37
+ module.exports = __toCommonJS(unplugin_exports);
37
38
  var import_unplugin = require("unplugin");
38
39
  var import_civet = __toESM(require("@danielx/civet"));
39
40
  var import_config = require("@danielx/civet/config");
@@ -41,20 +42,15 @@ var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
43
44
 
44
- // node_modules/@typescript/vfs/dist/vfs.esm.js
45
+ // node_modules/.pnpm/@typescript+vfs@1.6.4_typescript@5.8.3/node_modules/@typescript/vfs/dist/vfs.esm.js
45
46
  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
- }
47
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
48
+ for (var e = 1; e < arguments.length; e++) {
49
+ var t = arguments[e];
50
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
54
51
  }
55
- return target;
56
- };
57
- return _extends.apply(this, arguments);
52
+ return n;
53
+ }, _extends.apply(null, arguments);
58
54
  }
59
55
  var hasLocalStorage = false;
60
56
  try {
@@ -62,7 +58,7 @@ try {
62
58
  } catch (error) {
63
59
  }
64
60
  var hasProcess = typeof process !== "undefined";
65
- var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
61
+ var shouldDebug = hasLocalStorage && typeof localStorage.getItem === "function" && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
66
62
  var debugLog = shouldDebug ? console.log : function(_message) {
67
63
  return "";
68
64
  };
@@ -89,7 +85,10 @@ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
89
85
  module: ts.ModuleKind.ESNext,
90
86
  suppressOutputPathCheck: true,
91
87
  skipLibCheck: true,
92
- skipDefaultLibCheck: true,
88
+ skipDefaultLibCheck: true
89
+ }, ts.versionMajorMinor && Number(ts.versionMajorMinor.split(".")[0]) >= 6 ? {
90
+ ignoreDeprecations: "6.0"
91
+ } : {
93
92
  moduleResolution: ts.ModuleResolutionKind.NodeJs
94
93
  });
95
94
  };
@@ -213,32 +212,38 @@ var requirePath = function requirePath2() {
213
212
  return require(String.fromCharCode(112, 97, 116, 104));
214
213
  };
215
214
 
216
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
215
+ // source/unplugin/unplugin.civet
217
216
  var import_os = __toESM(require("os"));
218
-
219
- // source/unplugin/constants.mjs
220
217
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
221
-
222
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
223
218
  var DiagnosticCategory = {};
224
219
  DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
225
220
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
226
221
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
227
222
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
228
- var postfixRE = /[?#].*$/s;
223
+ var queryPostfixRE = /\?.*$/s;
224
+ var escapedHashRE = /\0#/g;
229
225
  var isWindows = import_os.default.platform() === "win32";
230
226
  var windowsSlashRE = /\\/g;
231
227
  var civetSuffix = ".civet";
232
228
  var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
233
229
  function extractCivetFilename(id, outputExtension) {
234
230
  let postfix = "";
235
- let filename = id.replace(postfixRE, (match) => {
231
+ id = id.replace(escapedHashRE, "#");
232
+ let filename = id.replace(queryPostfixRE, (match) => {
236
233
  postfix = match;
237
234
  return "";
238
235
  });
239
236
  if (filename.endsWith(outputExtension)) {
240
237
  filename = filename.slice(0, -outputExtension.length);
241
238
  }
239
+ const hashIndex = filename.lastIndexOf("#");
240
+ if (hashIndex >= 0 && !tryStatSync(filename)) {
241
+ postfix = filename.slice(hashIndex) + postfix;
242
+ filename = filename.slice(0, hashIndex);
243
+ if (filename.endsWith(outputExtension)) {
244
+ filename = filename.slice(0, -outputExtension.length);
245
+ }
246
+ }
242
247
  return { filename, postfix };
243
248
  }
244
249
  function tryStatSync(file) {
@@ -298,6 +303,7 @@ var rawPlugin = (options = {}, meta) => {
298
303
  const sourceMaps = /* @__PURE__ */ new Map();
299
304
  let compilerOptions, compilerOptionsWithSourceMap;
300
305
  let rootDir = process.cwd();
306
+ let outDir = import_path.default.join(rootDir, "dist");
301
307
  let esbuildOptions;
302
308
  let configErrors;
303
309
  let configFileNames;
@@ -337,7 +343,7 @@ var rawPlugin = (options = {}, meta) => {
337
343
  compileOptions.threads = options.threads;
338
344
  }
339
345
  if (transformTS || ts === "tsc") {
340
- let mogrify = function(key) {
346
+ let mogrify2 = function(key) {
341
347
  if (key in config && Array.isArray(config[key])) {
342
348
  return config[key] = config[key].map((item) => {
343
349
  if (!(typeof item === "string")) {
@@ -349,6 +355,7 @@ var rawPlugin = (options = {}, meta) => {
349
355
  ;
350
356
  return;
351
357
  };
358
+ var mogrify = mogrify2;
352
359
  const ts2 = await tsPromise;
353
360
  const tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
354
361
  if (!tsConfigPath) {
@@ -362,7 +369,7 @@ var rawPlugin = (options = {}, meta) => {
362
369
  console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
363
370
  throw error;
364
371
  }
365
- mogrify("files");
372
+ mogrify2("files");
366
373
  const system = { ...ts2.sys };
367
374
  const { readDirectory: systemReadDirectory } = system;
368
375
  system.readDirectory = (path2, extensions, excludes, includes, depth) => {
@@ -413,7 +420,7 @@ var rawPlugin = (options = {}, meta) => {
413
420
  };
414
421
  system.readFile = (filename, encoding = "utf-8") => {
415
422
  if (import_path.default.basename(filename) === "package.json") {
416
- let recurse = function(node) {
423
+ let recurse2 = function(node) {
417
424
  if (node != null && typeof node === "object") {
418
425
  for (const key in node) {
419
426
  const value = node[key];
@@ -423,18 +430,19 @@ var rawPlugin = (options = {}, meta) => {
423
430
  modified = true;
424
431
  }
425
432
  } else if (value) {
426
- recurse(value);
433
+ recurse2(value);
427
434
  }
428
435
  }
429
436
  }
430
437
  };
438
+ var recurse = recurse2;
431
439
  const json = systemReadFile(filename, encoding);
432
440
  if (!json) {
433
441
  return json;
434
442
  }
435
443
  const parsed = JSON.parse(json);
436
444
  let modified = false;
437
- recurse(parsed.imports);
445
+ recurse2(parsed.imports);
438
446
  return modified ? JSON.stringify(parsed) : json;
439
447
  }
440
448
  if (!filename.endsWith(".civet.tsx")) return systemReadFile(filename, encoding);
@@ -587,7 +595,7 @@ var rawPlugin = (options = {}, meta) => {
587
595
  if (options2.scan && meta.framework === "vite") {
588
596
  resolved = `\0${resolved}`;
589
597
  }
590
- return resolved + outExt + postfix;
598
+ return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
591
599
  },
592
600
  loadInclude(id) {
593
601
  const { filename, postfix } = extractCivetFilename(id, outExt);
@@ -625,18 +633,19 @@ var rawPlugin = (options = {}, meta) => {
625
633
  }
626
634
  }
627
635
  try {
628
- let checkErrors = function() {
636
+ let checkErrors2 = function() {
629
637
  if (civetOptions.errors.length) {
630
638
  throw new import_civet.default.ParseErrors(civetOptions.errors);
631
639
  }
632
640
  ;
633
641
  return;
634
642
  };
643
+ var checkErrors = checkErrors2;
635
644
  let compiled;
636
645
  let sourceMap;
637
646
  const civetOptions = {
638
647
  ...compileOptions,
639
- filename: id,
648
+ filename,
640
649
  errors: []
641
650
  };
642
651
  const rawCivetSource = (0, import_civet.decode)(await fs.promises.readFile(filename));
@@ -644,7 +653,10 @@ var rawPlugin = (options = {}, meta) => {
644
653
  ...civetOptions,
645
654
  ast: true
646
655
  });
647
- const civetSourceMap = new import_civet.SourceMap(rawCivetSource);
656
+ const civetSourceMap = new import_civet.SourceMap(
657
+ rawCivetSource,
658
+ normalizePath(import_path.default.relative(outDir, filename))
659
+ );
648
660
  if (ts === "civet") {
649
661
  compiled = await import_civet.default.generate(ast, {
650
662
  ...civetOptions,
@@ -652,21 +664,21 @@ var rawPlugin = (options = {}, meta) => {
652
664
  sourceMap: civetSourceMap
653
665
  });
654
666
  sourceMap = civetSourceMap;
655
- checkErrors();
667
+ checkErrors2();
656
668
  } else {
657
669
  const compiledTS = await import_civet.default.generate(ast, {
658
670
  ...civetOptions,
659
671
  js: false,
660
672
  sourceMap: civetSourceMap
661
673
  });
662
- checkErrors();
674
+ checkErrors2();
663
675
  switch (ts) {
664
676
  case "esbuild": {
665
677
  const esbuildTransform = (await import("esbuild")).transform;
666
678
  const result = await esbuildTransform(compiledTS, {
667
679
  jsx: "preserve",
668
680
  loader: "tsx",
669
- sourcefile: id,
681
+ sourcefile: filename,
670
682
  sourcemap: "external"
671
683
  });
672
684
  compiled = result.code;
@@ -690,7 +702,7 @@ var rawPlugin = (options = {}, meta) => {
690
702
  }
691
703
  }
692
704
  if (transformTS) {
693
- for (let ref3 = import_civet.lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
705
+ for (let ref3 = import_civet.lib.gatherRecursive(ast, (($) => $.type === "ModuleSpecifier")), i = 0, len = ref3.length; i < len; i++) {
694
706
  const _spec = ref3[i];
695
707
  const spec = _spec;
696
708
  if (spec.module?.input) {
@@ -702,7 +714,7 @@ var rawPlugin = (options = {}, meta) => {
702
714
  js: false,
703
715
  sourceMap: civetSourceMap
704
716
  });
705
- checkErrors();
717
+ checkErrors2();
706
718
  const tsx = filename + ".tsx";
707
719
  fsMap.set(tsx, compiledTS);
708
720
  sourceMaps.set(tsx, civetSourceMap);
@@ -712,10 +724,7 @@ var rawPlugin = (options = {}, meta) => {
712
724
  sourceMaps.set(slashed, civetSourceMap);
713
725
  }
714
726
  }
715
- const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
716
- import_path.default.relative(rootDir, extractCivetFilename(id, outExt).filename),
717
- import_path.default.relative(rootDir, id)
718
- ));
727
+ const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(import_path.default.relative(outDir, id))));
719
728
  let transformed = {
720
729
  code: compiled,
721
730
  map: jsonSourceMap
@@ -733,8 +742,12 @@ var rawPlugin = (options = {}, meta) => {
733
742
  }
734
743
  },
735
744
  esbuild: {
745
+ // Explicitly set the loader so esbuild handles the compiled output
746
+ // correctly even though the virtual module id no longer ends in .jsx/.tsx.
747
+ loader: ts === "preserve" ? "tsx" : "jsx",
736
748
  config(options2) {
737
749
  esbuildOptions = options2;
750
+ outDir = options2.outdir || import_path.default.dirname(options2.outfile);
738
751
  }
739
752
  },
740
753
  vite: {
@@ -743,6 +756,7 @@ var rawPlugin = (options = {}, meta) => {
743
756
  skipWorker = true;
744
757
  }
745
758
  rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
759
+ outDir = import_path.default.resolve(rootDir, config.build?.outDir ?? "dist");
746
760
  if (implicitExtension) {
747
761
  config.resolve ??= {};
748
762
  config.resolve.extensions ??= DEFAULT_EXTENSIONS;
@@ -792,7 +806,6 @@ var rawPlugin = (options = {}, meta) => {
792
806
  },
793
807
  webpack(compiler) {
794
808
  if (implicitExtension) {
795
- compiler.options ??= {};
796
809
  compiler.options.resolve ??= {};
797
810
  compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
798
811
  compiler.options.resolve.extensions.unshift(".civet");
@@ -821,7 +834,7 @@ var rawPlugin = (options = {}, meta) => {
821
834
  return plugin;
822
835
  };
823
836
  var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
824
- var unplugin_civet_default = unplugin;
837
+ var unplugin_default = unplugin;
825
838
  // Annotate the CommonJS export names for ESM import in node:
826
839
  0 && (module.exports = {
827
840
  rawPlugin,