@danielx/civet 0.6.61 → 0.6.63

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/esbuild.js CHANGED
@@ -90,7 +90,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
90
90
  const implicitExtension = options.implicitExtension ?? true;
91
91
  let fsMap = /* @__PURE__ */ new Map();
92
92
  const sourceMaps = /* @__PURE__ */ new Map();
93
- let compilerOptions;
93
+ let compilerOptions, compilerOptionsWithSourceMap;
94
94
  let rootDir = process.cwd();
95
95
  let esbuildOptions;
96
96
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
@@ -128,6 +128,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
128
128
  ...configContents.options,
129
129
  target: ts.ScriptTarget.ESNext
130
130
  };
131
+ compilerOptionsWithSourceMap = {
132
+ ...compilerOptions,
133
+ sourceMap: true
134
+ };
131
135
  fsMap = /* @__PURE__ */ new Map();
132
136
  }
133
137
  },
@@ -235,7 +239,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
235
239
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
236
240
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
237
241
  this.addWatchFile(filename);
238
- let compiled = void 0;
242
+ let compiled;
239
243
  if (options.ts === "civet" && !transformTS) {
240
244
  compiled = import_civet.default.compile(rawCivetSource, {
241
245
  filename: id,
@@ -248,15 +252,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
248
252
  js: false,
249
253
  sourceMap: true
250
254
  });
251
- const resolved = import_path.default.resolve(process.cwd(), id);
255
+ const resolved = filename + outExt;
252
256
  sourceMaps.set(
253
257
  resolved,
254
258
  compiledTS.sourceMap
255
259
  );
256
260
  if (transformTS) {
257
- fsMap.set(resolved, compiledTS.code);
258
- const slashed = slash(resolved);
259
- if (resolved !== slashed)
261
+ const tsx = filename + ".tsx";
262
+ fsMap.set(tsx, compiledTS.code);
263
+ const slashed = slash(tsx);
264
+ if (tsx !== slashed)
260
265
  fsMap.set(slashed, compiledTS.code);
261
266
  }
262
267
  switch (options.ts) {
@@ -273,10 +278,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
273
278
  }
274
279
  case "tsc": {
275
280
  const tsTranspile = (await tsPromise).transpileModule;
276
- const result = tsTranspile(compiledTS.code, { compilerOptions });
281
+ const result = tsTranspile(
282
+ compiledTS.code,
283
+ { compilerOptions: compilerOptionsWithSourceMap }
284
+ );
277
285
  compiled = {
278
286
  code: result.outputText,
279
- sourceMap: result.sourceMapText ?? ""
287
+ sourceMap: result.sourceMapText
280
288
  };
281
289
  break;
282
290
  }
@@ -300,10 +308,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
300
308
  }
301
309
  }
302
310
  }
303
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
311
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
304
312
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
305
313
  import_path.default.basename(id)
306
- );
314
+ ));
307
315
  let transformed = {
308
316
  code: compiled.code,
309
317
  map: jsonSourceMap