@danielx/civet 0.6.62 → 0.6.64

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/browser.js CHANGED
@@ -2563,19 +2563,7 @@ ${input.slice(result.pos)}
2563
2563
  const { initializer } = binding;
2564
2564
  if (initializer) {
2565
2565
  const exp = initializer[2];
2566
- if (exp?.type === "PipelineExpression") {
2567
- if (exp.children.at(-2) === ",") {
2568
- const { parent } = exp;
2569
- const parenthesizedExpression = makeLeftHandSideExpression(exp);
2570
- parenthesizedExpression.parent = parent;
2571
- exp.parent = parenthesizedExpression;
2572
- return initializer[2] = parenthesizedExpression;
2573
- }
2574
- ;
2575
- return;
2576
- }
2577
- ;
2578
- return;
2566
+ return exp;
2579
2567
  }
2580
2568
  ;
2581
2569
  return;
@@ -3316,6 +3304,14 @@ ${input.slice(result.pos)}
3316
3304
  };
3317
3305
  }
3318
3306
  children.push(arg);
3307
+ if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
3308
+ const { parent } = s;
3309
+ const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
3310
+ Object.assign(s, parenthesizedExpression, {
3311
+ parent,
3312
+ hoistDec: void 0
3313
+ });
3314
+ }
3319
3315
  return addParentPointers(s, s.parent);
3320
3316
  });
3321
3317
  }
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
  },
@@ -174,6 +178,29 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
174
178
  getFormatHost(ts.sys)
175
179
  )
176
180
  );
181
+ if (options.typecheck) {
182
+ let failures = [];
183
+ if (typeof options.typecheck === "string") {
184
+ if (options.typecheck.includes("error"))
185
+ failures.push(1 /* Error */);
186
+ if (options.typecheck.includes("warning"))
187
+ failures.push(0 /* Warning */);
188
+ if (options.typecheck.includes("suggestion"))
189
+ failures.push(2 /* Suggestion */);
190
+ if (options.typecheck.includes("message"))
191
+ failures.push(3 /* Message */);
192
+ if (options.typecheck.includes("all")) {
193
+ failures = { includes: () => true };
194
+ }
195
+ } else {
196
+ failures.push(1 /* Error */);
197
+ }
198
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
199
+ if (count) {
200
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
201
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
202
+ }
203
+ }
177
204
  }
178
205
  if (options.emitDeclaration) {
179
206
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -235,7 +262,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
235
262
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
236
263
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
237
264
  this.addWatchFile(filename);
238
- let compiled = void 0;
265
+ let compiled;
239
266
  if (options.ts === "civet" && !transformTS) {
240
267
  compiled = import_civet.default.compile(rawCivetSource, {
241
268
  filename: id,
@@ -248,15 +275,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
248
275
  js: false,
249
276
  sourceMap: true
250
277
  });
251
- const resolved = import_path.default.resolve(process.cwd(), id);
278
+ const resolved = filename + outExt;
252
279
  sourceMaps.set(
253
280
  resolved,
254
281
  compiledTS.sourceMap
255
282
  );
256
283
  if (transformTS) {
257
- fsMap.set(resolved, compiledTS.code);
258
- const slashed = slash(resolved);
259
- if (resolved !== slashed)
284
+ const tsx = filename + ".tsx";
285
+ fsMap.set(tsx, compiledTS.code);
286
+ const slashed = slash(tsx);
287
+ if (tsx !== slashed)
260
288
  fsMap.set(slashed, compiledTS.code);
261
289
  }
262
290
  switch (options.ts) {
@@ -273,10 +301,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
273
301
  }
274
302
  case "tsc": {
275
303
  const tsTranspile = (await tsPromise).transpileModule;
276
- const result = tsTranspile(compiledTS.code, { compilerOptions });
304
+ const result = tsTranspile(
305
+ compiledTS.code,
306
+ { compilerOptions: compilerOptionsWithSourceMap }
307
+ );
277
308
  compiled = {
278
309
  code: result.outputText,
279
- sourceMap: result.sourceMapText ?? ""
310
+ sourceMap: result.sourceMapText
280
311
  };
281
312
  break;
282
313
  }
@@ -300,10 +331,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
300
331
  }
301
332
  }
302
333
  }
303
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
334
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
304
335
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
305
336
  import_path.default.basename(id)
306
- );
337
+ ));
307
338
  let transformed = {
308
339
  code: compiled.code,
309
340
  map: jsonSourceMap
package/dist/main.js CHANGED
@@ -2555,19 +2555,7 @@ var require_lib = __commonJS({
2555
2555
  const { initializer } = binding;
2556
2556
  if (initializer) {
2557
2557
  const exp = initializer[2];
2558
- if (exp?.type === "PipelineExpression") {
2559
- if (exp.children.at(-2) === ",") {
2560
- const { parent } = exp;
2561
- const parenthesizedExpression = makeLeftHandSideExpression(exp);
2562
- parenthesizedExpression.parent = parent;
2563
- exp.parent = parenthesizedExpression;
2564
- return initializer[2] = parenthesizedExpression;
2565
- }
2566
- ;
2567
- return;
2568
- }
2569
- ;
2570
- return;
2558
+ return exp;
2571
2559
  }
2572
2560
  ;
2573
2561
  return;
@@ -3308,6 +3296,14 @@ var require_lib = __commonJS({
3308
3296
  };
3309
3297
  }
3310
3298
  children.push(arg);
3299
+ if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
3300
+ const { parent } = s;
3301
+ const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
3302
+ Object.assign(s, parenthesizedExpression, {
3303
+ parent,
3304
+ hoistDec: void 0
3305
+ });
3306
+ }
3311
3307
  return addParentPointers(s, s.parent);
3312
3308
  });
3313
3309
  }
package/dist/main.mjs CHANGED
@@ -2553,19 +2553,7 @@ var require_lib = __commonJS({
2553
2553
  const { initializer } = binding;
2554
2554
  if (initializer) {
2555
2555
  const exp = initializer[2];
2556
- if (exp?.type === "PipelineExpression") {
2557
- if (exp.children.at(-2) === ",") {
2558
- const { parent } = exp;
2559
- const parenthesizedExpression = makeLeftHandSideExpression(exp);
2560
- parenthesizedExpression.parent = parent;
2561
- exp.parent = parenthesizedExpression;
2562
- return initializer[2] = parenthesizedExpression;
2563
- }
2564
- ;
2565
- return;
2566
- }
2567
- ;
2568
- return;
2556
+ return exp;
2569
2557
  }
2570
2558
  ;
2571
2559
  return;
@@ -3306,6 +3294,14 @@ var require_lib = __commonJS({
3306
3294
  };
3307
3295
  }
3308
3296
  children.push(arg);
3297
+ if (!children.some(($3) => $3?.type === "ReturnStatement") && children.some(($4) => $4 === ",")) {
3298
+ const { parent } = s;
3299
+ const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
3300
+ Object.assign(s, parenthesizedExpression, {
3301
+ parent,
3302
+ hoistDec: void 0
3303
+ });
3304
+ }
3309
3305
  return addParentPointers(s, s.parent);
3310
3306
  });
3311
3307
  }
package/dist/rollup.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
  },
@@ -174,6 +178,29 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
174
178
  getFormatHost(ts.sys)
175
179
  )
176
180
  );
181
+ if (options.typecheck) {
182
+ let failures = [];
183
+ if (typeof options.typecheck === "string") {
184
+ if (options.typecheck.includes("error"))
185
+ failures.push(1 /* Error */);
186
+ if (options.typecheck.includes("warning"))
187
+ failures.push(0 /* Warning */);
188
+ if (options.typecheck.includes("suggestion"))
189
+ failures.push(2 /* Suggestion */);
190
+ if (options.typecheck.includes("message"))
191
+ failures.push(3 /* Message */);
192
+ if (options.typecheck.includes("all")) {
193
+ failures = { includes: () => true };
194
+ }
195
+ } else {
196
+ failures.push(1 /* Error */);
197
+ }
198
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
199
+ if (count) {
200
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
201
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
202
+ }
203
+ }
177
204
  }
178
205
  if (options.emitDeclaration) {
179
206
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -235,7 +262,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
235
262
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
236
263
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
237
264
  this.addWatchFile(filename);
238
- let compiled = void 0;
265
+ let compiled;
239
266
  if (options.ts === "civet" && !transformTS) {
240
267
  compiled = import_civet.default.compile(rawCivetSource, {
241
268
  filename: id,
@@ -248,15 +275,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
248
275
  js: false,
249
276
  sourceMap: true
250
277
  });
251
- const resolved = import_path.default.resolve(process.cwd(), id);
278
+ const resolved = filename + outExt;
252
279
  sourceMaps.set(
253
280
  resolved,
254
281
  compiledTS.sourceMap
255
282
  );
256
283
  if (transformTS) {
257
- fsMap.set(resolved, compiledTS.code);
258
- const slashed = slash(resolved);
259
- if (resolved !== slashed)
284
+ const tsx = filename + ".tsx";
285
+ fsMap.set(tsx, compiledTS.code);
286
+ const slashed = slash(tsx);
287
+ if (tsx !== slashed)
260
288
  fsMap.set(slashed, compiledTS.code);
261
289
  }
262
290
  switch (options.ts) {
@@ -273,10 +301,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
273
301
  }
274
302
  case "tsc": {
275
303
  const tsTranspile = (await tsPromise).transpileModule;
276
- const result = tsTranspile(compiledTS.code, { compilerOptions });
304
+ const result = tsTranspile(
305
+ compiledTS.code,
306
+ { compilerOptions: compilerOptionsWithSourceMap }
307
+ );
277
308
  compiled = {
278
309
  code: result.outputText,
279
- sourceMap: result.sourceMapText ?? ""
310
+ sourceMap: result.sourceMapText
280
311
  };
281
312
  break;
282
313
  }
@@ -300,10 +331,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
300
331
  }
301
332
  }
302
333
  }
303
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
334
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
304
335
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
305
336
  import_path.default.basename(id)
306
- );
337
+ ));
307
338
  let transformed = {
308
339
  code: compiled.code,
309
340
  map: jsonSourceMap
@@ -57,7 +57,7 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
57
57
  const implicitExtension = options.implicitExtension ?? true;
58
58
  let fsMap = /* @__PURE__ */ new Map();
59
59
  const sourceMaps = /* @__PURE__ */ new Map();
60
- let compilerOptions;
60
+ let compilerOptions, compilerOptionsWithSourceMap;
61
61
  let rootDir = process.cwd();
62
62
  let esbuildOptions;
63
63
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
@@ -95,6 +95,10 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
95
95
  ...configContents.options,
96
96
  target: ts.ScriptTarget.ESNext
97
97
  };
98
+ compilerOptionsWithSourceMap = {
99
+ ...compilerOptions,
100
+ sourceMap: true
101
+ };
98
102
  fsMap = /* @__PURE__ */ new Map();
99
103
  }
100
104
  },
@@ -141,6 +145,29 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
141
145
  getFormatHost(ts.sys)
142
146
  )
143
147
  );
148
+ if (options.typecheck) {
149
+ let failures = [];
150
+ if (typeof options.typecheck === "string") {
151
+ if (options.typecheck.includes("error"))
152
+ failures.push(1 /* Error */);
153
+ if (options.typecheck.includes("warning"))
154
+ failures.push(0 /* Warning */);
155
+ if (options.typecheck.includes("suggestion"))
156
+ failures.push(2 /* Suggestion */);
157
+ if (options.typecheck.includes("message"))
158
+ failures.push(3 /* Message */);
159
+ if (options.typecheck.includes("all")) {
160
+ failures = { includes: () => true };
161
+ }
162
+ } else {
163
+ failures.push(1 /* Error */);
164
+ }
165
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
166
+ if (count) {
167
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
168
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
169
+ }
170
+ }
144
171
  }
145
172
  if (options.emitDeclaration) {
146
173
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -202,7 +229,7 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
202
229
  const filename = path.resolve(process.cwd(), id.slice(0, -outExt.length));
203
230
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
204
231
  this.addWatchFile(filename);
205
- let compiled = void 0;
232
+ let compiled;
206
233
  if (options.ts === "civet" && !transformTS) {
207
234
  compiled = civet.compile(rawCivetSource, {
208
235
  filename: id,
@@ -215,15 +242,16 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
215
242
  js: false,
216
243
  sourceMap: true
217
244
  });
218
- const resolved = path.resolve(process.cwd(), id);
245
+ const resolved = filename + outExt;
219
246
  sourceMaps.set(
220
247
  resolved,
221
248
  compiledTS.sourceMap
222
249
  );
223
250
  if (transformTS) {
224
- fsMap.set(resolved, compiledTS.code);
225
- const slashed = slash(resolved);
226
- if (resolved !== slashed)
251
+ const tsx = filename + ".tsx";
252
+ fsMap.set(tsx, compiledTS.code);
253
+ const slashed = slash(tsx);
254
+ if (tsx !== slashed)
227
255
  fsMap.set(slashed, compiledTS.code);
228
256
  }
229
257
  switch (options.ts) {
@@ -240,10 +268,13 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
240
268
  }
241
269
  case "tsc": {
242
270
  const tsTranspile = (await tsPromise).transpileModule;
243
- const result = tsTranspile(compiledTS.code, { compilerOptions });
271
+ const result = tsTranspile(
272
+ compiledTS.code,
273
+ { compilerOptions: compilerOptionsWithSourceMap }
274
+ );
244
275
  compiled = {
245
276
  code: result.outputText,
246
- sourceMap: result.sourceMapText ?? ""
277
+ sourceMap: result.sourceMapText
247
278
  };
248
279
  break;
249
280
  }
@@ -267,10 +298,10 @@ var civetUnplugin = createUnplugin((options = {}, meta) => {
267
298
  }
268
299
  }
269
300
  }
270
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
301
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
271
302
  path.basename(id.replace(/\.[jt]sx$/, "")),
272
303
  path.basename(id)
273
- );
304
+ ));
274
305
  let transformed = {
275
306
  code: compiled.code,
276
307
  map: jsonSourceMap
@@ -6,7 +6,7 @@ type PluginOptions = {
6
6
  outputExtension?: string;
7
7
  transformOutput?: (code: string, id: string) => TransformResult | Promise<TransformResult>;
8
8
  emitDeclaration?: boolean;
9
- typecheck?: boolean;
9
+ typecheck?: boolean | string;
10
10
  ts?: 'civet' | 'esbuild' | 'tsc' | 'preserve';
11
11
  /** @deprecated Use "ts" option instead */
12
12
  js?: boolean;
@@ -6,7 +6,7 @@ type PluginOptions = {
6
6
  outputExtension?: string;
7
7
  transformOutput?: (code: string, id: string) => TransformResult | Promise<TransformResult>;
8
8
  emitDeclaration?: boolean;
9
- typecheck?: boolean;
9
+ typecheck?: boolean | string;
10
10
  ts?: 'civet' | 'esbuild' | 'tsc' | 'preserve';
11
11
  /** @deprecated Use "ts" option instead */
12
12
  js?: boolean;
package/dist/unplugin.js CHANGED
@@ -89,7 +89,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
89
89
  const implicitExtension = options.implicitExtension ?? true;
90
90
  let fsMap = /* @__PURE__ */ new Map();
91
91
  const sourceMaps = /* @__PURE__ */ new Map();
92
- let compilerOptions;
92
+ let compilerOptions, compilerOptionsWithSourceMap;
93
93
  let rootDir = process.cwd();
94
94
  let esbuildOptions;
95
95
  const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
@@ -127,6 +127,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
127
127
  ...configContents.options,
128
128
  target: ts.ScriptTarget.ESNext
129
129
  };
130
+ compilerOptionsWithSourceMap = {
131
+ ...compilerOptions,
132
+ sourceMap: true
133
+ };
130
134
  fsMap = /* @__PURE__ */ new Map();
131
135
  }
132
136
  },
@@ -173,6 +177,29 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
173
177
  getFormatHost(ts.sys)
174
178
  )
175
179
  );
180
+ if (options.typecheck) {
181
+ let failures = [];
182
+ if (typeof options.typecheck === "string") {
183
+ if (options.typecheck.includes("error"))
184
+ failures.push(1 /* Error */);
185
+ if (options.typecheck.includes("warning"))
186
+ failures.push(0 /* Warning */);
187
+ if (options.typecheck.includes("suggestion"))
188
+ failures.push(2 /* Suggestion */);
189
+ if (options.typecheck.includes("message"))
190
+ failures.push(3 /* Message */);
191
+ if (options.typecheck.includes("all")) {
192
+ failures = { includes: () => true };
193
+ }
194
+ } else {
195
+ failures.push(1 /* Error */);
196
+ }
197
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
198
+ if (count) {
199
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
200
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
201
+ }
202
+ }
176
203
  }
177
204
  if (options.emitDeclaration) {
178
205
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -234,7 +261,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
234
261
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
235
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
236
263
  this.addWatchFile(filename);
237
- let compiled = void 0;
264
+ let compiled;
238
265
  if (options.ts === "civet" && !transformTS) {
239
266
  compiled = import_civet.default.compile(rawCivetSource, {
240
267
  filename: id,
@@ -247,15 +274,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
247
274
  js: false,
248
275
  sourceMap: true
249
276
  });
250
- const resolved = import_path.default.resolve(process.cwd(), id);
277
+ const resolved = filename + outExt;
251
278
  sourceMaps.set(
252
279
  resolved,
253
280
  compiledTS.sourceMap
254
281
  );
255
282
  if (transformTS) {
256
- fsMap.set(resolved, compiledTS.code);
257
- const slashed = slash(resolved);
258
- if (resolved !== slashed)
283
+ const tsx = filename + ".tsx";
284
+ fsMap.set(tsx, compiledTS.code);
285
+ const slashed = slash(tsx);
286
+ if (tsx !== slashed)
259
287
  fsMap.set(slashed, compiledTS.code);
260
288
  }
261
289
  switch (options.ts) {
@@ -272,10 +300,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
272
300
  }
273
301
  case "tsc": {
274
302
  const tsTranspile = (await tsPromise).transpileModule;
275
- const result = tsTranspile(compiledTS.code, { compilerOptions });
303
+ const result = tsTranspile(
304
+ compiledTS.code,
305
+ { compilerOptions: compilerOptionsWithSourceMap }
306
+ );
276
307
  compiled = {
277
308
  code: result.outputText,
278
- sourceMap: result.sourceMapText ?? ""
309
+ sourceMap: result.sourceMapText
279
310
  };
280
311
  break;
281
312
  }
@@ -299,10 +330,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
299
330
  }
300
331
  }
301
332
  }
302
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
333
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
303
334
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
304
335
  import_path.default.basename(id)
305
- );
336
+ ));
306
337
  let transformed = {
307
338
  code: compiled.code,
308
339
  map: jsonSourceMap
package/dist/vite.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
  },
@@ -174,6 +178,29 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
174
178
  getFormatHost(ts.sys)
175
179
  )
176
180
  );
181
+ if (options.typecheck) {
182
+ let failures = [];
183
+ if (typeof options.typecheck === "string") {
184
+ if (options.typecheck.includes("error"))
185
+ failures.push(1 /* Error */);
186
+ if (options.typecheck.includes("warning"))
187
+ failures.push(0 /* Warning */);
188
+ if (options.typecheck.includes("suggestion"))
189
+ failures.push(2 /* Suggestion */);
190
+ if (options.typecheck.includes("message"))
191
+ failures.push(3 /* Message */);
192
+ if (options.typecheck.includes("all")) {
193
+ failures = { includes: () => true };
194
+ }
195
+ } else {
196
+ failures.push(1 /* Error */);
197
+ }
198
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
199
+ if (count) {
200
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
201
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
202
+ }
203
+ }
177
204
  }
178
205
  if (options.emitDeclaration) {
179
206
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -235,7 +262,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
235
262
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
236
263
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
237
264
  this.addWatchFile(filename);
238
- let compiled = void 0;
265
+ let compiled;
239
266
  if (options.ts === "civet" && !transformTS) {
240
267
  compiled = import_civet.default.compile(rawCivetSource, {
241
268
  filename: id,
@@ -248,15 +275,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
248
275
  js: false,
249
276
  sourceMap: true
250
277
  });
251
- const resolved = import_path.default.resolve(process.cwd(), id);
278
+ const resolved = filename + outExt;
252
279
  sourceMaps.set(
253
280
  resolved,
254
281
  compiledTS.sourceMap
255
282
  );
256
283
  if (transformTS) {
257
- fsMap.set(resolved, compiledTS.code);
258
- const slashed = slash(resolved);
259
- if (resolved !== slashed)
284
+ const tsx = filename + ".tsx";
285
+ fsMap.set(tsx, compiledTS.code);
286
+ const slashed = slash(tsx);
287
+ if (tsx !== slashed)
260
288
  fsMap.set(slashed, compiledTS.code);
261
289
  }
262
290
  switch (options.ts) {
@@ -273,10 +301,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
273
301
  }
274
302
  case "tsc": {
275
303
  const tsTranspile = (await tsPromise).transpileModule;
276
- const result = tsTranspile(compiledTS.code, { compilerOptions });
304
+ const result = tsTranspile(
305
+ compiledTS.code,
306
+ { compilerOptions: compilerOptionsWithSourceMap }
307
+ );
277
308
  compiled = {
278
309
  code: result.outputText,
279
- sourceMap: result.sourceMapText ?? ""
310
+ sourceMap: result.sourceMapText
280
311
  };
281
312
  break;
282
313
  }
@@ -300,10 +331,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
300
331
  }
301
332
  }
302
333
  }
303
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
334
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
304
335
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
305
336
  import_path.default.basename(id)
306
- );
337
+ ));
307
338
  let transformed = {
308
339
  code: compiled.code,
309
340
  map: jsonSourceMap
package/dist/webpack.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
  },
@@ -174,6 +178,29 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
174
178
  getFormatHost(ts.sys)
175
179
  )
176
180
  );
181
+ if (options.typecheck) {
182
+ let failures = [];
183
+ if (typeof options.typecheck === "string") {
184
+ if (options.typecheck.includes("error"))
185
+ failures.push(1 /* Error */);
186
+ if (options.typecheck.includes("warning"))
187
+ failures.push(0 /* Warning */);
188
+ if (options.typecheck.includes("suggestion"))
189
+ failures.push(2 /* Suggestion */);
190
+ if (options.typecheck.includes("message"))
191
+ failures.push(3 /* Message */);
192
+ if (options.typecheck.includes("all")) {
193
+ failures = { includes: () => true };
194
+ }
195
+ } else {
196
+ failures.push(1 /* Error */);
197
+ }
198
+ const count = diagnostics.filter((d) => failures.includes(d.category)).length;
199
+ if (count) {
200
+ const reason = count === diagnostics.length ? count : `${count} out of ${diagnostics.length}`;
201
+ throw new Error(`Aborting build because of ${reason} TypeScript diagnostic${diagnostics.length > 1 ? "s" : ""} above`);
202
+ }
203
+ }
177
204
  }
178
205
  if (options.emitDeclaration) {
179
206
  if (meta.framework === "esbuild" && !esbuildOptions.outdir) {
@@ -235,7 +262,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
235
262
  const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
236
263
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
237
264
  this.addWatchFile(filename);
238
- let compiled = void 0;
265
+ let compiled;
239
266
  if (options.ts === "civet" && !transformTS) {
240
267
  compiled = import_civet.default.compile(rawCivetSource, {
241
268
  filename: id,
@@ -248,15 +275,16 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
248
275
  js: false,
249
276
  sourceMap: true
250
277
  });
251
- const resolved = import_path.default.resolve(process.cwd(), id);
278
+ const resolved = filename + outExt;
252
279
  sourceMaps.set(
253
280
  resolved,
254
281
  compiledTS.sourceMap
255
282
  );
256
283
  if (transformTS) {
257
- fsMap.set(resolved, compiledTS.code);
258
- const slashed = slash(resolved);
259
- if (resolved !== slashed)
284
+ const tsx = filename + ".tsx";
285
+ fsMap.set(tsx, compiledTS.code);
286
+ const slashed = slash(tsx);
287
+ if (tsx !== slashed)
260
288
  fsMap.set(slashed, compiledTS.code);
261
289
  }
262
290
  switch (options.ts) {
@@ -273,10 +301,13 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
273
301
  }
274
302
  case "tsc": {
275
303
  const tsTranspile = (await tsPromise).transpileModule;
276
- const result = tsTranspile(compiledTS.code, { compilerOptions });
304
+ const result = tsTranspile(
305
+ compiledTS.code,
306
+ { compilerOptions: compilerOptionsWithSourceMap }
307
+ );
277
308
  compiled = {
278
309
  code: result.outputText,
279
- sourceMap: result.sourceMapText ?? ""
310
+ sourceMap: result.sourceMapText
280
311
  };
281
312
  break;
282
313
  }
@@ -300,10 +331,10 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}, meta) =>
300
331
  }
301
332
  }
302
333
  }
303
- const jsonSourceMap = typeof compiled.sourceMap == "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
334
+ const jsonSourceMap = compiled.sourceMap && (typeof compiled.sourceMap === "string" ? JSON.parse(compiled.sourceMap) : compiled.sourceMap.json(
304
335
  import_path.default.basename(id.replace(/\.[jt]sx$/, "")),
305
336
  import_path.default.basename(id)
306
- );
337
+ ));
307
338
  let transformed = {
308
339
  code: compiled.code,
309
340
  map: jsonSourceMap
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.62",
4
+ "version": "0.6.64",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",