@danielx/civet 0.6.60 → 0.6.62

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
@@ -80,7 +80,7 @@ function implicitCivet(file) {
80
80
  return civet2;
81
81
  return;
82
82
  }
83
- var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
83
+ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) => {
84
84
  if (options.dts)
85
85
  options.emitDeclaration = options.dts;
86
86
  if (options.js)
@@ -92,6 +92,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
92
92
  const sourceMaps = /* @__PURE__ */ new Map();
93
93
  let compilerOptions;
94
94
  let rootDir = process.cwd();
95
+ let esbuildOptions;
95
96
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
96
97
  const getFormatHost = (sys) => {
97
98
  return {
@@ -175,13 +176,20 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
175
176
  );
176
177
  }
177
178
  if (options.emitDeclaration) {
179
+ if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
180
+ console.log("WARNING: Civet unplugin's `emitDeclaration` requires esbuild's `outdir` option to be set;");
181
+ }
182
+ for (const file of fsMap.keys()) {
183
+ const slashed = slash(file);
184
+ if (file !== slashed) {
185
+ fsMap.delete(slashed);
186
+ }
187
+ }
178
188
  for (const file of fsMap.keys()) {
179
189
  const sourceFile = program.getSourceFile(file);
180
190
  program.emit(
181
191
  sourceFile,
182
- async (filePath, content) => {
183
- const dir = import_path.default.dirname(filePath);
184
- await fs.promises.mkdir(dir, { recursive: true });
192
+ (filePath, content) => {
185
193
  const pathFromDistDir = import_path.default.relative(
186
194
  compilerOptions.outDir ?? process.cwd(),
187
195
  filePath
@@ -240,16 +248,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
240
248
  js: false,
241
249
  sourceMap: true
242
250
  });
251
+ const resolved = import_path.default.resolve(process.cwd(), id);
243
252
  sourceMaps.set(
244
- import_path.default.resolve(process.cwd(), id),
253
+ resolved,
245
254
  compiledTS.sourceMap
246
255
  );
247
256
  if (transformTS) {
248
- const resolved = import_path.default.resolve(process.cwd(), id);
249
257
  fsMap.set(resolved, compiledTS.code);
250
258
  const slashed = slash(resolved);
251
259
  if (resolved !== slashed)
252
- fsMap.set(slashed, rawCivetSource);
260
+ fsMap.set(slashed, compiledTS.code);
253
261
  }
254
262
  switch (options.ts) {
255
263
  case "esbuild": {
@@ -304,6 +312,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
304
312
  transformed = await options.transformOutput(transformed.code, id);
305
313
  return transformed;
306
314
  },
315
+ esbuild: {
316
+ config(options2) {
317
+ esbuildOptions = options2;
318
+ }
319
+ },
307
320
  vite: {
308
321
  config(config) {
309
322
  var _a;