@danielx/civet 0.7.8 → 0.7.9

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/README.md CHANGED
@@ -219,60 +219,18 @@ could be a valid property `1.e10` → `1..e10`. The workaround is to add a trail
219
219
  console.log "hi"
220
220
  ```
221
221
 
222
- Comparison to CoffeeScript
223
- ---
222
+ ### Comparison to CoffeeScript
224
223
 
225
224
  Take a look at this [detailed Civet // CoffeeScript comparision](./notes/Comparison-to-CoffeeScript.md)
226
225
 
227
- ECMAScript Compatibility
228
- ---
229
-
230
- You can specify `"civet"` prologue directives to increase
231
- compatibility with ECMAScript/TypeScript:
232
-
233
- | Configuration | What it enables |
234
- |---------------------|---------------------------------------|
235
- | -implicit-returns | turn off implicit return of last value in functions |
236
-
237
- Put them at the top of your file:
238
-
239
- ```
240
- "civet -implicit-returns"
241
- ```
242
-
243
- Your can separate multiple options with spaces.
244
-
245
- Deno Compatibility
246
- ---
247
-
248
- TypeScript only allows importing `.ts` files as `.js`. Deno follows ESM and requires importing files with the correct extension.
249
-
250
- Civet automatically rewrites imports to work around [this issue](https://github.com/microsoft/TypeScript/issues/42151) in TS.
251
-
252
- When Civet detects it is running in Deno rewriting imports is turned off. If for some reason Civet fails to detect running in Deno
253
- you can turn off rewriting imports manually with these configuration options:
254
-
255
- | Configuration | What it enables |
256
- |-----------------------|------------------------------------------|
257
- | -rewrite-ts-imports | disable rewriting .ts -> .js in imports |
258
- | deno | currently just disables rewriting imports but could add more deno specific options in the future |
226
+ ### Directives
259
227
 
260
- Other Options
261
- ---
262
-
263
- The `"civet"` prologue directive can also specify the following options:
264
-
265
- | Configuration | What it enables |
266
- |---------------------|---------------------------------------|
267
- | rewrite-civet-imports=.ext | Rewrite `import "file.civet"` to `import "file.ext"` |
268
- | tab=NNN | treat tab like NNN spaces (default=1) |
228
+ Civet is not just one language; it can be configured in a variety of ways
229
+ via directives to add or remove language features, or improve behavior
230
+ in certain environments.
231
+ See [config documentation](https://civet.dev/config).
269
232
 
270
- For example, `"civet tab=2"` or `"civet tab=4"` lets you mix tabs and spaces
271
- in a file and be treated like they'd render in VSCode with `editor.tabSize`
272
- set accordingly.
273
-
274
- Using Civet in your Node.js Environment
275
- ---
233
+ ### Using Civet in your Node.js Environment
276
234
 
277
235
  You have now been convinced that Civet is right for your current/next project. Here is how
278
236
  to set up your environment to get productive right away and have a Good Time℠.
package/dist/astro.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PluginOptions } from './unplugin.mjs';
2
2
  import 'unplugin';
3
+ import '@danielx/civet';
3
4
 
4
5
  interface AstroIntegration {
5
6
  name: string;
package/dist/astro.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PluginOptions } from './unplugin.js';
2
2
  import 'unplugin';
3
+ import '@danielx/civet';
3
4
 
4
5
  interface AstroIntegration {
5
6
  name: string;
package/dist/astro.js CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(astro_exports);
37
37
  // src/index.ts
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
package/dist/browser.js CHANGED
@@ -38,9 +38,9 @@ var Civet = (() => {
38
38
  ));
39
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
40
 
41
- // node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js
41
+ // ../Hera/dist/machine.js
42
42
  var require_machine = __commonJS({
43
- "node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
43
+ "../Hera/dist/machine.js"(exports, module) {
44
44
  "use strict";
45
45
  var __defProp2 = Object.defineProperty;
46
46
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -7035,7 +7035,7 @@ ${js}`
7035
7035
  var $R3 = (0, import_lib3.$R)(new RegExp("[0-9]", "suy"));
7036
7036
  var $R4 = (0, import_lib3.$R)(new RegExp("(?!\\p{ID_Start}|[_$0-9(\\[{])", "suy"));
7037
7037
  var $R5 = (0, import_lib3.$R)(new RegExp("[ \\t]", "suy"));
7038
- var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.])", "suy"));
7038
+ var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])", "suy"));
7039
7039
  var $R7 = (0, import_lib3.$R)(new RegExp("[&=]", "suy"));
7040
7040
  var $R8 = (0, import_lib3.$R)(new RegExp("(?=['\"`])", "suy"));
7041
7041
  var $R9 = (0, import_lib3.$R)(new RegExp("(?=[\\/?])", "suy"));
@@ -8009,7 +8009,7 @@ ${js}`
8009
8009
  function ParenthesizedExpression(ctx, state2) {
8010
8010
  return (0, import_lib3.$EVENT)(ctx, state2, "ParenthesizedExpression", ParenthesizedExpression$0);
8011
8011
  }
8012
- var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
8012
+ var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
8013
8013
  var dot = $1;
8014
8014
  var typeSuffix = $3;
8015
8015
  return {
package/dist/config.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var config_exports = {};
32
32
  __export(config_exports, {
33
33
  findConfig: () => findConfig,
34
+ findInDir: () => findInDir,
34
35
  loadConfig: () => loadConfig
35
36
  });
36
37
  module.exports = __toCommonJS(config_exports);
@@ -41,14 +42,16 @@ var configFileNames = /* @__PURE__ */ new Set([
41
42
  "\u{1F408}.json",
42
43
  "\u{1F408}.civet",
43
44
  "civetconfig.json",
44
- "civetconfig.civet"
45
+ "civetconfig.civet",
46
+ "civet.config.json",
47
+ "civet.config.civet"
45
48
  ]);
46
49
  async function findInDir(dirPath) {
47
50
  for (const entryName of await import_promises.default.readdir(dirPath)) {
48
51
  const entryPath = import_path.default.join(dirPath, entryName);
49
52
  if (entryName === ".config" && await (async () => {
50
53
  try {
51
- return (await import_promises.default.stat(entryPath)).isDir();
54
+ return (await import_promises.default.stat(entryPath)).isDirectory();
52
55
  } catch (e) {
53
56
  return;
54
57
  }
@@ -119,5 +122,6 @@ async function loadConfig(path2) {
119
122
  // Annotate the CommonJS export names for ESM import in node:
120
123
  0 && (module.exports = {
121
124
  findConfig,
125
+ findInDir,
122
126
  loadConfig
123
127
  });
@@ -1,6 +1,7 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import { PluginOptions } from './unplugin.mjs';
3
3
  import 'unplugin';
4
+ import '@danielx/civet';
4
5
 
5
6
  declare const _default: (options: PluginOptions) => esbuild.Plugin;
6
7
 
package/dist/esbuild.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import { PluginOptions } from './unplugin.js';
3
3
  import 'unplugin';
4
+ import '@danielx/civet';
4
5
 
5
6
  declare const _default: (options: PluginOptions) => esbuild.Plugin;
6
7
 
package/dist/esbuild.js CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(esbuild_exports);
37
37
  // src/index.ts
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
package/dist/main.js CHANGED
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js
33
+ // ../Hera/dist/machine.js
34
34
  var require_machine = __commonJS({
35
- "node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js"(exports2, module2) {
35
+ "../Hera/dist/machine.js"(exports2, module2) {
36
36
  "use strict";
37
37
  var __defProp2 = Object.defineProperty;
38
38
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -7013,7 +7013,7 @@ var $R2 = (0, import_lib3.$R)(new RegExp("(as|of|satisfies|then|when|implements|
7013
7013
  var $R3 = (0, import_lib3.$R)(new RegExp("[0-9]", "suy"));
7014
7014
  var $R4 = (0, import_lib3.$R)(new RegExp("(?!\\p{ID_Start}|[_$0-9(\\[{])", "suy"));
7015
7015
  var $R5 = (0, import_lib3.$R)(new RegExp("[ \\t]", "suy"));
7016
- var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.])", "suy"));
7016
+ var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])", "suy"));
7017
7017
  var $R7 = (0, import_lib3.$R)(new RegExp("[&=]", "suy"));
7018
7018
  var $R8 = (0, import_lib3.$R)(new RegExp("(?=['\"`])", "suy"));
7019
7019
  var $R9 = (0, import_lib3.$R)(new RegExp("(?=[\\/?])", "suy"));
@@ -7987,7 +7987,7 @@ var ParenthesizedExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenPar
7987
7987
  function ParenthesizedExpression(ctx, state2) {
7988
7988
  return (0, import_lib3.$EVENT)(ctx, state2, "ParenthesizedExpression", ParenthesizedExpression$0);
7989
7989
  }
7990
- var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7990
+ var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7991
7991
  var dot = $1;
7992
7992
  var typeSuffix = $3;
7993
7993
  return {
package/dist/main.mjs CHANGED
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js
31
+ // ../Hera/dist/machine.js
32
32
  var require_machine = __commonJS({
33
- "node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js"(exports, module) {
33
+ "../Hera/dist/machine.js"(exports, module) {
34
34
  "use strict";
35
35
  var __defProp2 = Object.defineProperty;
36
36
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -6995,7 +6995,7 @@ var $R2 = (0, import_lib3.$R)(new RegExp("(as|of|satisfies|then|when|implements|
6995
6995
  var $R3 = (0, import_lib3.$R)(new RegExp("[0-9]", "suy"));
6996
6996
  var $R4 = (0, import_lib3.$R)(new RegExp("(?!\\p{ID_Start}|[_$0-9(\\[{])", "suy"));
6997
6997
  var $R5 = (0, import_lib3.$R)(new RegExp("[ \\t]", "suy"));
6998
- var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.])", "suy"));
6998
+ var $R6 = (0, import_lib3.$R)(new RegExp("(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])", "suy"));
6999
6999
  var $R7 = (0, import_lib3.$R)(new RegExp("[&=]", "suy"));
7000
7000
  var $R8 = (0, import_lib3.$R)(new RegExp("(?=['\"`])", "suy"));
7001
7001
  var $R9 = (0, import_lib3.$R)(new RegExp("(?=[\\/?])", "suy"));
@@ -7969,7 +7969,7 @@ var ParenthesizedExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenPar
7969
7969
  function ParenthesizedExpression(ctx, state2) {
7970
7970
  return (0, import_lib3.$EVENT)(ctx, state2, "ParenthesizedExpression", ParenthesizedExpression$0);
7971
7971
  }
7972
- var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7972
+ var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.#])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7973
7973
  var dot = $1;
7974
7974
  var typeSuffix = $3;
7975
7975
  return {
package/dist/rollup.d.mts CHANGED
@@ -1,6 +1,8 @@
1
- import * as unplugin from 'unplugin';
1
+ import * as rollup from 'rollup';
2
2
  import { PluginOptions } from './unplugin.mjs';
3
+ import 'unplugin';
4
+ import '@danielx/civet';
3
5
 
4
- declare const _default: (options: PluginOptions) => unplugin.RollupPlugin<any> | unplugin.RollupPlugin<any>[];
6
+ declare const _default: (options: PluginOptions) => rollup.Plugin | rollup.Plugin[];
5
7
 
6
8
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import * as unplugin from 'unplugin';
1
+ import * as rollup from 'rollup';
2
2
  import { PluginOptions } from './unplugin.js';
3
+ import 'unplugin';
4
+ import '@danielx/civet';
3
5
 
4
- declare const _default: (options: PluginOptions) => unplugin.RollupPlugin<any> | unplugin.RollupPlugin<any>[];
6
+ declare const _default: (options: PluginOptions) => rollup.Plugin | rollup.Plugin[];
5
7
 
6
8
  export { _default as default };
package/dist/rollup.js CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(rollup_exports);
37
37
  // src/index.ts
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
package/dist/types.d.ts CHANGED
@@ -112,11 +112,14 @@ declare module "@danielx/civet/esbuild-plugin" {
112
112
  }
113
113
 
114
114
  declare module "@danielx/civet/config" {
115
- const Config: {
116
- findConfig: (path: string) => Promise<string | null>
117
- loadConfig: (
118
- path: string
119
- ) => Promise<import("@danielx/civet").CompileOptions>
115
+ export function findInDir(dirPath: string): Promise<string | undefined>
116
+ export function findConfig(path: string): Promise<string | null>
117
+ export function loadConfig(
118
+ path: string
119
+ ): Promise<import("@danielx/civet").CompileOptions>
120
+ export default {
121
+ findInDir: typeof findInDir,
122
+ findConfig: typeof findConfig,
123
+ loadConfig: typeof loadConfig,
120
124
  }
121
- export default Config
122
125
  }
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import { createUnplugin } from "unplugin";
3
3
  import civet from "@danielx/civet";
4
+ import { findInDir, loadConfig } from "@danielx/civet/config";
4
5
  import {
5
6
  remapRange,
6
7
  flattenDiagnosticMessageText
@@ -57,6 +58,7 @@ var rawPlugin = (options = {}, meta) => {
57
58
  options.emitDeclaration = options.dts;
58
59
  if (options.js)
59
60
  options.ts = "civet";
61
+ let compileOptions = {};
60
62
  const transformTS = options.emitDeclaration || options.typecheck;
61
63
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
62
64
  const implicitExtension = options.implicitExtension ?? true;
@@ -79,12 +81,20 @@ var rawPlugin = (options = {}, meta) => {
79
81
  async buildStart() {
80
82
  if (transformTS || options.ts === "tsc") {
81
83
  const ts = await tsPromise;
82
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
83
- if (!configPath) {
84
+ const civetConfigPath = "config" in options ? options.config : await findInDir(process.cwd());
85
+ if (civetConfigPath) {
86
+ compileOptions = await loadConfig(civetConfigPath);
87
+ }
88
+ compileOptions.parseOptions = {
89
+ ...compileOptions.parseOptions,
90
+ ...options.parseOptions
91
+ };
92
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
93
+ if (!tsConfigPath) {
84
94
  throw new Error("Could not find 'tsconfig.json'");
85
95
  }
86
96
  const { config, error } = ts.readConfigFile(
87
- configPath,
97
+ tsConfigPath,
88
98
  ts.sys.readFile
89
99
  );
90
100
  if (error) {
@@ -131,9 +141,9 @@ var rawPlugin = (options = {}, meta) => {
131
141
  encoding
132
142
  });
133
143
  const compiledTS = civet.compile(rawCivetSource, {
144
+ ...compileOptions,
134
145
  filename,
135
146
  js: false,
136
- comptime: Boolean(options.comptime),
137
147
  sync: true
138
148
  // TS readFile API seems to need to be synchronous
139
149
  });
@@ -281,11 +291,9 @@ var rawPlugin = (options = {}, meta) => {
281
291
  this.addWatchFile(filename);
282
292
  let compiled;
283
293
  const civetOptions = {
294
+ ...compileOptions,
284
295
  filename: id,
285
- sourceMap: true,
286
- parseOptions: {
287
- comptime: Boolean(options.comptime)
288
- }
296
+ sourceMap: true
289
297
  };
290
298
  if (options.ts === "civet" && !transformTS) {
291
299
  compiled = await civet.compile(rawCivetSource, {
@@ -1,5 +1,6 @@
1
- import * as unplugin$1 from 'unplugin';
1
+ import * as _unplugin from 'unplugin';
2
2
  import { TransformResult, createUnplugin } from 'unplugin';
3
+ import { ParseOptions } from '@danielx/civet';
3
4
 
4
5
  type PluginOptions = {
5
6
  implicitExtension?: boolean;
@@ -12,10 +13,12 @@ type PluginOptions = {
12
13
  js?: boolean;
13
14
  /** @deprecated Use "emitDeclaration" instead */
14
15
  dts?: boolean;
15
- comptime?: boolean;
16
+ /** config filename, or null to not look for default config file */
17
+ config?: string | null | undefined;
18
+ parseOptions?: ParseOptions;
16
19
  };
17
20
  declare function slash(p: string): string;
18
21
  declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
19
- declare var unplugin: unplugin$1.UnpluginInstance<PluginOptions, boolean>;
22
+ declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
20
23
 
21
- export { type PluginOptions, unplugin as default, rawPlugin, slash };
24
+ export { PluginOptions, unplugin as default, rawPlugin, slash };
@@ -1,5 +1,6 @@
1
- import * as unplugin$1 from 'unplugin';
1
+ import * as _unplugin from 'unplugin';
2
2
  import { TransformResult, createUnplugin } from 'unplugin';
3
+ import { ParseOptions } from '@danielx/civet';
3
4
 
4
5
  type PluginOptions = {
5
6
  implicitExtension?: boolean;
@@ -12,10 +13,12 @@ type PluginOptions = {
12
13
  js?: boolean;
13
14
  /** @deprecated Use "emitDeclaration" instead */
14
15
  dts?: boolean;
15
- comptime?: boolean;
16
+ /** config filename, or null to not look for default config file */
17
+ config?: string | null | undefined;
18
+ parseOptions?: ParseOptions;
16
19
  };
17
20
  declare function slash(p: string): string;
18
21
  declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
19
- declare var unplugin: unplugin$1.UnpluginInstance<PluginOptions, boolean>;
22
+ declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
20
23
 
21
- export { type PluginOptions, unplugin as default, rawPlugin, slash };
24
+ export { PluginOptions, unplugin as default, rawPlugin, slash };
package/dist/unplugin.js CHANGED
@@ -37,6 +37,7 @@ __export(src_exports, {
37
37
  module.exports = __toCommonJS(src_exports);
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as vite from 'vite';
2
2
  import { PluginOptions } from './unplugin.mjs';
3
3
  import 'unplugin';
4
+ import '@danielx/civet';
4
5
 
5
6
  declare const _default: (options: PluginOptions) => vite.Plugin | vite.Plugin[];
6
7
 
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as vite from 'vite';
2
2
  import { PluginOptions } from './unplugin.js';
3
3
  import 'unplugin';
4
+ import '@danielx/civet';
4
5
 
5
6
  declare const _default: (options: PluginOptions) => vite.Plugin | vite.Plugin[];
6
7
 
package/dist/vite.js CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(vite_exports);
37
37
  // src/index.ts
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
@@ -1,5 +1,6 @@
1
1
  import { PluginOptions } from './unplugin.mjs';
2
2
  import 'unplugin';
3
+ import '@danielx/civet';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => WebpackPluginInstance;
5
6
 
package/dist/webpack.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PluginOptions } from './unplugin.js';
2
2
  import 'unplugin';
3
+ import '@danielx/civet';
3
4
 
4
5
  declare const _default: (options: PluginOptions) => WebpackPluginInstance;
5
6
 
package/dist/webpack.js CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(webpack_exports);
37
37
  // src/index.ts
38
38
  var import_unplugin = require("unplugin");
39
39
  var import_civet = __toESM(require("@danielx/civet"));
40
+ var import_config = require("@danielx/civet/config");
40
41
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
42
  var fs = __toESM(require("fs"));
42
43
  var import_path = __toESM(require("path"));
@@ -90,6 +91,7 @@ var rawPlugin = (options = {}, meta) => {
90
91
  options.emitDeclaration = options.dts;
91
92
  if (options.js)
92
93
  options.ts = "civet";
94
+ let compileOptions = {};
93
95
  const transformTS = options.emitDeclaration || options.typecheck;
94
96
  const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
95
97
  const implicitExtension = options.implicitExtension ?? true;
@@ -112,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
112
114
  async buildStart() {
113
115
  if (transformTS || options.ts === "tsc") {
114
116
  const ts = await tsPromise;
115
- const configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
116
- if (!configPath) {
117
+ const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
118
+ if (civetConfigPath) {
119
+ compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
120
+ }
121
+ compileOptions.parseOptions = {
122
+ ...compileOptions.parseOptions,
123
+ ...options.parseOptions
124
+ };
125
+ const tsConfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
126
+ if (!tsConfigPath) {
117
127
  throw new Error("Could not find 'tsconfig.json'");
118
128
  }
119
129
  const { config, error } = ts.readConfigFile(
120
- configPath,
130
+ tsConfigPath,
121
131
  ts.sys.readFile
122
132
  );
123
133
  if (error) {
@@ -164,9 +174,9 @@ var rawPlugin = (options = {}, meta) => {
164
174
  encoding
165
175
  });
166
176
  const compiledTS = import_civet.default.compile(rawCivetSource, {
177
+ ...compileOptions,
167
178
  filename,
168
179
  js: false,
169
- comptime: Boolean(options.comptime),
170
180
  sync: true
171
181
  // TS readFile API seems to need to be synchronous
172
182
  });
@@ -314,11 +324,9 @@ var rawPlugin = (options = {}, meta) => {
314
324
  this.addWatchFile(filename);
315
325
  let compiled;
316
326
  const civetOptions = {
327
+ ...compileOptions,
317
328
  filename: id,
318
- sourceMap: true,
319
- parseOptions: {
320
- comptime: Boolean(options.comptime)
321
- }
329
+ sourceMap: true
322
330
  };
323
331
  if (options.ts === "civet" && !transformTS) {
324
332
  compiled = await import_civet.default.compile(rawCivetSource, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.7.8",
4
+ "version": "0.7.9",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",