@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/README.md +7 -49
- package/dist/astro.d.mts +1 -0
- package/dist/astro.d.ts +1 -0
- package/dist/astro.js +16 -8
- package/dist/browser.js +221 -122
- package/dist/config.js +6 -2
- package/dist/esbuild.d.mts +1 -0
- package/dist/esbuild.d.ts +1 -0
- package/dist/esbuild.js +16 -8
- package/dist/main.js +221 -122
- package/dist/main.mjs +221 -122
- package/dist/rollup.d.mts +1 -0
- package/dist/rollup.d.ts +1 -0
- package/dist/rollup.js +16 -8
- package/dist/types.d.ts +9 -6
- package/dist/unplugin-shared.mjs +16 -8
- package/dist/unplugin.d.mts +4 -1
- package/dist/unplugin.d.ts +4 -1
- package/dist/unplugin.js +16 -8
- package/dist/vite.d.mts +1 -0
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +16 -8
- package/dist/webpack.d.mts +1 -0
- package/dist/webpack.d.ts +1 -0
- package/dist/webpack.js +16 -8
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
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
package/dist/astro.d.ts
CHANGED
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
|
|
116
|
-
if (
|
|
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
|
-
|
|
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, {
|