@danielx/civet 0.7.7 → 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/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
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,7 +13,9 @@ 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];
@@ -1,5 +1,6 @@
1
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,7 +13,9 @@ 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];
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.7",
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",