@danielx/civet 0.11.5 → 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,7 +42,7 @@ 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
47
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
47
48
  for (var e = 1; e < arguments.length; e++) {
@@ -211,32 +212,38 @@ var requirePath = function requirePath2() {
211
212
  return require(String.fromCharCode(112, 97, 116, 104));
212
213
  };
213
214
 
214
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
215
+ // source/unplugin/unplugin.civet
215
216
  var import_os = __toESM(require("os"));
216
-
217
- // source/unplugin/constants.mjs
218
217
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
219
-
220
- // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
221
218
  var DiagnosticCategory = {};
222
219
  DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
223
220
  DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
224
221
  DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
225
222
  DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
226
- var postfixRE = /[?#].*$/s;
223
+ var queryPostfixRE = /\?.*$/s;
224
+ var escapedHashRE = /\0#/g;
227
225
  var isWindows = import_os.default.platform() === "win32";
228
226
  var windowsSlashRE = /\\/g;
229
227
  var civetSuffix = ".civet";
230
228
  var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
231
229
  function extractCivetFilename(id, outputExtension) {
232
230
  let postfix = "";
233
- let filename = id.replace(postfixRE, (match) => {
231
+ id = id.replace(escapedHashRE, "#");
232
+ let filename = id.replace(queryPostfixRE, (match) => {
234
233
  postfix = match;
235
234
  return "";
236
235
  });
237
236
  if (filename.endsWith(outputExtension)) {
238
237
  filename = filename.slice(0, -outputExtension.length);
239
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
+ }
240
247
  return { filename, postfix };
241
248
  }
242
249
  function tryStatSync(file) {
@@ -296,6 +303,7 @@ var rawPlugin = (options = {}, meta) => {
296
303
  const sourceMaps = /* @__PURE__ */ new Map();
297
304
  let compilerOptions, compilerOptionsWithSourceMap;
298
305
  let rootDir = process.cwd();
306
+ let outDir = import_path.default.join(rootDir, "dist");
299
307
  let esbuildOptions;
300
308
  let configErrors;
301
309
  let configFileNames;
@@ -335,7 +343,7 @@ var rawPlugin = (options = {}, meta) => {
335
343
  compileOptions.threads = options.threads;
336
344
  }
337
345
  if (transformTS || ts === "tsc") {
338
- let mogrify = function(key) {
346
+ let mogrify2 = function(key) {
339
347
  if (key in config && Array.isArray(config[key])) {
340
348
  return config[key] = config[key].map((item) => {
341
349
  if (!(typeof item === "string")) {
@@ -347,6 +355,7 @@ var rawPlugin = (options = {}, meta) => {
347
355
  ;
348
356
  return;
349
357
  };
358
+ var mogrify = mogrify2;
350
359
  const ts2 = await tsPromise;
351
360
  const tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
352
361
  if (!tsConfigPath) {
@@ -360,7 +369,7 @@ var rawPlugin = (options = {}, meta) => {
360
369
  console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
361
370
  throw error;
362
371
  }
363
- mogrify("files");
372
+ mogrify2("files");
364
373
  const system = { ...ts2.sys };
365
374
  const { readDirectory: systemReadDirectory } = system;
366
375
  system.readDirectory = (path2, extensions, excludes, includes, depth) => {
@@ -411,7 +420,7 @@ var rawPlugin = (options = {}, meta) => {
411
420
  };
412
421
  system.readFile = (filename, encoding = "utf-8") => {
413
422
  if (import_path.default.basename(filename) === "package.json") {
414
- let recurse = function(node) {
423
+ let recurse2 = function(node) {
415
424
  if (node != null && typeof node === "object") {
416
425
  for (const key in node) {
417
426
  const value = node[key];
@@ -421,18 +430,19 @@ var rawPlugin = (options = {}, meta) => {
421
430
  modified = true;
422
431
  }
423
432
  } else if (value) {
424
- recurse(value);
433
+ recurse2(value);
425
434
  }
426
435
  }
427
436
  }
428
437
  };
438
+ var recurse = recurse2;
429
439
  const json = systemReadFile(filename, encoding);
430
440
  if (!json) {
431
441
  return json;
432
442
  }
433
443
  const parsed = JSON.parse(json);
434
444
  let modified = false;
435
- recurse(parsed.imports);
445
+ recurse2(parsed.imports);
436
446
  return modified ? JSON.stringify(parsed) : json;
437
447
  }
438
448
  if (!filename.endsWith(".civet.tsx")) return systemReadFile(filename, encoding);
@@ -585,7 +595,7 @@ var rawPlugin = (options = {}, meta) => {
585
595
  if (options2.scan && meta.framework === "vite") {
586
596
  resolved = `\0${resolved}`;
587
597
  }
588
- return resolved + outExt + postfix;
598
+ return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
589
599
  },
590
600
  loadInclude(id) {
591
601
  const { filename, postfix } = extractCivetFilename(id, outExt);
@@ -623,18 +633,19 @@ var rawPlugin = (options = {}, meta) => {
623
633
  }
624
634
  }
625
635
  try {
626
- let checkErrors = function() {
636
+ let checkErrors2 = function() {
627
637
  if (civetOptions.errors.length) {
628
638
  throw new import_civet.default.ParseErrors(civetOptions.errors);
629
639
  }
630
640
  ;
631
641
  return;
632
642
  };
643
+ var checkErrors = checkErrors2;
633
644
  let compiled;
634
645
  let sourceMap;
635
646
  const civetOptions = {
636
647
  ...compileOptions,
637
- filename: id,
648
+ filename,
638
649
  errors: []
639
650
  };
640
651
  const rawCivetSource = (0, import_civet.decode)(await fs.promises.readFile(filename));
@@ -642,7 +653,10 @@ var rawPlugin = (options = {}, meta) => {
642
653
  ...civetOptions,
643
654
  ast: true
644
655
  });
645
- 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
+ );
646
660
  if (ts === "civet") {
647
661
  compiled = await import_civet.default.generate(ast, {
648
662
  ...civetOptions,
@@ -650,21 +664,21 @@ var rawPlugin = (options = {}, meta) => {
650
664
  sourceMap: civetSourceMap
651
665
  });
652
666
  sourceMap = civetSourceMap;
653
- checkErrors();
667
+ checkErrors2();
654
668
  } else {
655
669
  const compiledTS = await import_civet.default.generate(ast, {
656
670
  ...civetOptions,
657
671
  js: false,
658
672
  sourceMap: civetSourceMap
659
673
  });
660
- checkErrors();
674
+ checkErrors2();
661
675
  switch (ts) {
662
676
  case "esbuild": {
663
677
  const esbuildTransform = (await import("esbuild")).transform;
664
678
  const result = await esbuildTransform(compiledTS, {
665
679
  jsx: "preserve",
666
680
  loader: "tsx",
667
- sourcefile: id,
681
+ sourcefile: filename,
668
682
  sourcemap: "external"
669
683
  });
670
684
  compiled = result.code;
@@ -688,7 +702,7 @@ var rawPlugin = (options = {}, meta) => {
688
702
  }
689
703
  }
690
704
  if (transformTS) {
691
- 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++) {
692
706
  const _spec = ref3[i];
693
707
  const spec = _spec;
694
708
  if (spec.module?.input) {
@@ -700,7 +714,7 @@ var rawPlugin = (options = {}, meta) => {
700
714
  js: false,
701
715
  sourceMap: civetSourceMap
702
716
  });
703
- checkErrors();
717
+ checkErrors2();
704
718
  const tsx = filename + ".tsx";
705
719
  fsMap.set(tsx, compiledTS);
706
720
  sourceMaps.set(tsx, civetSourceMap);
@@ -710,10 +724,7 @@ var rawPlugin = (options = {}, meta) => {
710
724
  sourceMaps.set(slashed, civetSourceMap);
711
725
  }
712
726
  }
713
- const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
714
- import_path.default.relative(rootDir, extractCivetFilename(id, outExt).filename),
715
- import_path.default.relative(rootDir, id)
716
- ));
727
+ const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(import_path.default.relative(outDir, id))));
717
728
  let transformed = {
718
729
  code: compiled,
719
730
  map: jsonSourceMap
@@ -731,8 +742,12 @@ var rawPlugin = (options = {}, meta) => {
731
742
  }
732
743
  },
733
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",
734
748
  config(options2) {
735
749
  esbuildOptions = options2;
750
+ outDir = options2.outdir || import_path.default.dirname(options2.outfile);
736
751
  }
737
752
  },
738
753
  vite: {
@@ -741,6 +756,7 @@ var rawPlugin = (options = {}, meta) => {
741
756
  skipWorker = true;
742
757
  }
743
758
  rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
759
+ outDir = import_path.default.resolve(rootDir, config.build?.outDir ?? "dist");
744
760
  if (implicitExtension) {
745
761
  config.resolve ??= {};
746
762
  config.resolve.extensions ??= DEFAULT_EXTENSIONS;
@@ -790,7 +806,6 @@ var rawPlugin = (options = {}, meta) => {
790
806
  },
791
807
  webpack(compiler) {
792
808
  if (implicitExtension) {
793
- compiler.options ??= {};
794
809
  compiler.options.resolve ??= {};
795
810
  compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
796
811
  compiler.options.resolve.extensions.unshift(".civet");
@@ -819,7 +834,7 @@ var rawPlugin = (options = {}, meta) => {
819
834
  return plugin;
820
835
  };
821
836
  var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
822
- var unplugin_civet_default = unplugin;
837
+ var unplugin_default = unplugin;
823
838
  // Annotate the CommonJS export names for ESM import in node:
824
839
  0 && (module.exports = {
825
840
  rawPlugin,