@danielx/civet 0.10.1 → 0.10.3
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/CHANGELOG.md +9 -0
- package/dist/civet +2 -2
- package/dist/esm.mjs +30 -9
- package/dist/unplugin/unplugin.d.ts +2 -2
- package/dist/unplugin/unplugin.js +6 -3
- package/dist/unplugin/unplugin.mjs +6 -3
- package/package.json +3 -2
- package/register.js +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ This changelog is generated automatically by [`build/changelog.civet`](build/cha
|
|
|
4
4
|
For each version of Civet, it lists and links to all incorporated PRs,
|
|
5
5
|
as well as a full diff and commit list.
|
|
6
6
|
|
|
7
|
+
## 0.10.3 (2025-04-28, [diff](https://github.com/DanielXMoore/Civet/compare/v0.10.2...v0.10.3), [commits](https://github.com/DanielXMoore/Civet/commits/v0.10.3))
|
|
8
|
+
* Explicit changelog build script shell [[#1727](https://github.com/DanielXMoore/Civet/pull/1727)]
|
|
9
|
+
* ESM loader supports civetconfig by default, and overriding configuration [[#1734](https://github.com/DanielXMoore/Civet/pull/1734)]
|
|
10
|
+
* BREAKING CHANGE: If you don't use civetconfig files and want to be robust against their existence in ancestor directories, or want to maximize performance, use `@danielx/civet/register-noconfig` instead of `@danielx/civet/register`
|
|
11
|
+
* BREAKING CHANGE: In unplugin settings, `config: undefined` no longer disables searching for config files. Use `config: false` or `config: null` instead.
|
|
12
|
+
|
|
13
|
+
## 0.10.2 (2025-04-13, [diff](https://github.com/DanielXMoore/Civet/compare/v0.10.1...v0.10.2), [commits](https://github.com/DanielXMoore/Civet/commits/v0.10.2))
|
|
14
|
+
* Fix unplugin source map directories [[#1726](https://github.com/DanielXMoore/Civet/pull/1726)]
|
|
15
|
+
|
|
7
16
|
## 0.10.1 (2025-03-22, [diff](https://github.com/DanielXMoore/Civet/compare/v0.10.0...v0.10.1), [commits](https://github.com/DanielXMoore/Civet/commits/v0.10.1))
|
|
8
17
|
* More general expressions in indented forms of `implements` and `with` [[#1720](https://github.com/DanielXMoore/Civet/pull/1720)]
|
|
9
18
|
* Allow `>code` to continue an implicit JSX fragment [[#1721](https://github.com/DanielXMoore/Civet/pull/1721)]
|
package/dist/civet
CHANGED
|
@@ -503,8 +503,8 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
503
503
|
`);
|
|
504
504
|
process.exit(0);
|
|
505
505
|
}
|
|
506
|
-
if (options.config
|
|
507
|
-
options.config
|
|
506
|
+
if (options.config === void 0) {
|
|
507
|
+
options.config = await (0, import_config.findConfig)(process.cwd());
|
|
508
508
|
}
|
|
509
509
|
if (options.config) {
|
|
510
510
|
const parsed = await (0, import_config.loadConfig)(options.config);
|
package/dist/esm.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\esm.civet.jsx
|
|
2
|
-
import {
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { dirname } from "path";
|
|
3
4
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
4
|
-
import
|
|
5
|
-
|
|
5
|
+
import { compile, SourceMap } from "./main.mjs";
|
|
6
|
+
import { findConfig, loadConfig } from "./config.mjs";
|
|
6
7
|
var baseURL = pathToFileURL(process.cwd() + "/").href;
|
|
7
8
|
var extensionsRegex = /\.civet$/;
|
|
9
|
+
var globalOptions = {};
|
|
10
|
+
function initialize(options = {}) {
|
|
11
|
+
return globalOptions = options;
|
|
12
|
+
}
|
|
8
13
|
function resolve(specifier, context, next) {
|
|
9
14
|
const { parentURL = baseURL } = context;
|
|
10
15
|
if (extensionsRegex.test(specifier)) {
|
|
@@ -19,14 +24,29 @@ function resolve(specifier, context, next) {
|
|
|
19
24
|
async function load(url, context, next) {
|
|
20
25
|
if (context.format === "civet") {
|
|
21
26
|
const path = fileURLToPath(url);
|
|
22
|
-
const source =
|
|
27
|
+
const source = await readFile(path, "utf8");
|
|
28
|
+
let loadedConfig;
|
|
29
|
+
let { config } = globalOptions;
|
|
30
|
+
if (config === void 0) {
|
|
31
|
+
config = await findConfig(dirname(path));
|
|
32
|
+
}
|
|
33
|
+
if (config) {
|
|
34
|
+
loadedConfig = await loadConfig(config);
|
|
35
|
+
}
|
|
36
|
+
const options = {
|
|
37
|
+
filename: path,
|
|
38
|
+
sourceMap: true,
|
|
39
|
+
js: true
|
|
40
|
+
};
|
|
41
|
+
if (globalOptions.parseOptions) {
|
|
42
|
+
options.parseOptions = globalOptions.parseOptions;
|
|
43
|
+
}
|
|
44
|
+
if (loadedConfig?.parseOptions) {
|
|
45
|
+
options.parseOptions = { ...options.parseOptions, ...loadedConfig.parseOptions };
|
|
46
|
+
}
|
|
23
47
|
let tsSource, sourceMap;
|
|
24
48
|
try {
|
|
25
|
-
({ code: tsSource, sourceMap } = await compile(source,
|
|
26
|
-
filename: path,
|
|
27
|
-
sourceMap: true,
|
|
28
|
-
js: true
|
|
29
|
-
}));
|
|
49
|
+
({ code: tsSource, sourceMap } = await compile(source, options));
|
|
30
50
|
} catch (e) {
|
|
31
51
|
console.error(`Civet failed to compile ${url}:`, e);
|
|
32
52
|
throw e;
|
|
@@ -46,6 +66,7 @@ async function load(url, context, next) {
|
|
|
46
66
|
return next(url, context);
|
|
47
67
|
}
|
|
48
68
|
export {
|
|
69
|
+
initialize,
|
|
49
70
|
load,
|
|
50
71
|
resolve
|
|
51
72
|
};
|
|
@@ -16,8 +16,8 @@ export type PluginOptions = {
|
|
|
16
16
|
threads?: number;
|
|
17
17
|
/** Cache compilation results based on file mtime (useful for serve or watch mode) */
|
|
18
18
|
cache?: boolean;
|
|
19
|
-
/** config filename, or null to not look for default config file */
|
|
20
|
-
config?:
|
|
19
|
+
/** config filename, or false/null to not look for default config file */
|
|
20
|
+
config?: string | false | null;
|
|
21
21
|
parseOptions?: ParseOptions;
|
|
22
22
|
};
|
|
23
23
|
export declare function slash(p: string): string;
|
|
@@ -145,7 +145,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
145
145
|
name: "unplugin-civet",
|
|
146
146
|
enforce: "pre",
|
|
147
147
|
async buildStart() {
|
|
148
|
-
|
|
148
|
+
let civetConfigPath = options.config;
|
|
149
|
+
if (civetConfigPath === void 0) {
|
|
150
|
+
civetConfigPath = await (0, import_config.findInDir)(process.cwd());
|
|
151
|
+
}
|
|
149
152
|
if (civetConfigPath) {
|
|
150
153
|
compileOptions = await (0, import_config.loadConfig)(civetConfigPath);
|
|
151
154
|
}
|
|
@@ -538,8 +541,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
538
541
|
}
|
|
539
542
|
}
|
|
540
543
|
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
|
|
541
|
-
import_path.default.
|
|
542
|
-
import_path.default.
|
|
544
|
+
import_path.default.relative(rootDir, id.replace(/\.[jt]sx$/, "")),
|
|
545
|
+
import_path.default.relative(rootDir, id)
|
|
543
546
|
));
|
|
544
547
|
let transformed = {
|
|
545
548
|
code: compiled,
|
|
@@ -113,7 +113,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
113
113
|
name: "unplugin-civet",
|
|
114
114
|
enforce: "pre",
|
|
115
115
|
async buildStart() {
|
|
116
|
-
|
|
116
|
+
let civetConfigPath = options.config;
|
|
117
|
+
if (civetConfigPath === void 0) {
|
|
118
|
+
civetConfigPath = await findInDir(process.cwd());
|
|
119
|
+
}
|
|
117
120
|
if (civetConfigPath) {
|
|
118
121
|
compileOptions = await loadConfig(civetConfigPath);
|
|
119
122
|
}
|
|
@@ -506,8 +509,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
506
509
|
}
|
|
507
510
|
}
|
|
508
511
|
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
|
|
509
|
-
path.
|
|
510
|
-
path.
|
|
512
|
+
path.relative(rootDir, id.replace(/\.[jt]sx$/, "")),
|
|
513
|
+
path.relative(rootDir, id)
|
|
511
514
|
));
|
|
512
515
|
let transformed = {
|
|
513
516
|
code: compiled,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.3",
|
|
5
5
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/main.mjs",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"./esm": "./dist/esm.mjs",
|
|
24
24
|
"./esbuild-plugin": "./dist/esbuild-plugin.js",
|
|
25
25
|
"./register": "./register.js",
|
|
26
|
+
"./register-noconfig": "./register-noconfig.js",
|
|
26
27
|
"./config": {
|
|
27
28
|
"types": "./dist/config.d.ts",
|
|
28
29
|
"require": "./dist/config.js",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"dependencies": {
|
|
108
109
|
"@cspotcode/source-map-support": "^0.8.1",
|
|
109
110
|
"@typescript/vfs": "^1.6.0",
|
|
110
|
-
"unplugin": "^2.2
|
|
111
|
+
"unplugin": "^2.3.2"
|
|
111
112
|
},
|
|
112
113
|
"devDependencies": {
|
|
113
114
|
"@danielx/civet": "0.9.4",
|
package/register.js
CHANGED
|
@@ -9,6 +9,14 @@ for both ESM `import`s and CJS `require`s.
|
|
|
9
9
|
node --import @danielx/civet/register source.civet
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
If you don't want the loader to search for/use accompanying civetconfig files,
|
|
13
|
+
you can use the `-noconfig` version (where `NOCONFIG` comments are removed):
|
|
14
|
+
|
|
15
|
+
@example
|
|
16
|
+
```bash
|
|
17
|
+
node --import @danielx/civet/register-noconfig source.civet
|
|
18
|
+
```
|
|
19
|
+
|
|
12
20
|
On older Node, `require`ing this file will register the `.civet` extension
|
|
13
21
|
for CJS `require`s.
|
|
14
22
|
|
|
@@ -16,13 +24,30 @@ for CJS `require`s.
|
|
|
16
24
|
```bash
|
|
17
25
|
node -r @danielx/civet/register source.civet
|
|
18
26
|
```
|
|
27
|
+
|
|
28
|
+
If you want to configure the loader, you can make your own
|
|
29
|
+
`register.mjs` along these lines:
|
|
30
|
+
|
|
31
|
+
@example
|
|
32
|
+
```javascript
|
|
33
|
+
import { register } from 'node:module';
|
|
34
|
+
register('@danielx/civet/esm', import.meta.url, {data: {
|
|
35
|
+
//config: 'path/config.json',
|
|
36
|
+
parseOptions: {
|
|
37
|
+
// Add your parse options here
|
|
38
|
+
},
|
|
39
|
+
}});
|
|
40
|
+
```
|
|
41
|
+
|
|
19
42
|
*/
|
|
20
43
|
|
|
21
44
|
try {
|
|
22
45
|
const { register } = require('node:module');
|
|
23
46
|
const { pathToFileURL } = require('node:url');
|
|
24
47
|
|
|
25
|
-
register('./dist/esm.mjs', pathToFileURL(__filename)
|
|
48
|
+
register('./dist/esm.mjs', pathToFileURL(__filename)
|
|
49
|
+
//NOCONFIG//, {data: {config: null}}
|
|
50
|
+
);
|
|
26
51
|
} catch (e) {
|
|
27
52
|
// older Node lacking module register
|
|
28
53
|
}
|
|
@@ -38,6 +63,7 @@ if (require.extensions) {
|
|
|
38
63
|
js: true,
|
|
39
64
|
inlineMap: true,
|
|
40
65
|
sync: true,
|
|
66
|
+
//NOCONFIG//config: null,
|
|
41
67
|
});
|
|
42
68
|
module._compile(js, filename);
|
|
43
69
|
};
|