@danielx/civet 0.7.13 → 0.7.14
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/astro.js +31 -1
- package/dist/browser.js +176 -69
- package/dist/civet +9 -9
- package/dist/config.js +13 -2
- package/dist/esbuild.js +31 -1
- package/dist/main.js +176 -69
- package/dist/main.mjs +176 -69
- package/dist/rollup.js +31 -1
- package/dist/unplugin-shared.mjs +31 -1
- package/dist/unplugin.js +31 -1
- package/dist/vite.js +31 -1
- package/dist/webpack.js +31 -1
- package/package.json +10 -3
package/dist/civet
CHANGED
|
@@ -40,8 +40,8 @@ module.exports = __toCommonJS(cli_exports);
|
|
|
40
40
|
var import_main = require("./main.js");
|
|
41
41
|
var import_config = require("./config.js");
|
|
42
42
|
var import_unplugin = require("./unplugin");
|
|
43
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
44
|
-
var
|
|
43
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
|
44
|
+
var import_node_path = __toESM(require("node:path"));
|
|
45
45
|
var unplugin;
|
|
46
46
|
function version() {
|
|
47
47
|
return require("../package.json").version;
|
|
@@ -276,7 +276,7 @@ async function repl(options) {
|
|
|
276
276
|
const { pathToFileURL } = await import("node:url");
|
|
277
277
|
importModuleDynamically = (specifier) => {
|
|
278
278
|
if (/^\.\.?[/\\]/.test(specifier)) {
|
|
279
|
-
return import(pathToFileURL(
|
|
279
|
+
return import(pathToFileURL(import_node_path.default.join(process.cwd(), specifier)));
|
|
280
280
|
} else {
|
|
281
281
|
return import(specifier);
|
|
282
282
|
}
|
|
@@ -471,7 +471,7 @@ async function cli() {
|
|
|
471
471
|
ts: options.js ? "civet" : "preserve",
|
|
472
472
|
outputExtension: ".tsx"
|
|
473
473
|
};
|
|
474
|
-
(unpluginOptions.parseOptions ??= {}).rewriteCivetImports = ".civet.
|
|
474
|
+
(unpluginOptions.parseOptions ??= {}).rewriteCivetImports = ".civet.jsx";
|
|
475
475
|
unplugin = (0, import_unplugin.rawPlugin)(unpluginOptions, { framework: "civet-cli" });
|
|
476
476
|
await unplugin.buildStart();
|
|
477
477
|
}
|
|
@@ -484,14 +484,14 @@ async function cli() {
|
|
|
484
484
|
}
|
|
485
485
|
let outputDir, outputExt, outputPath;
|
|
486
486
|
if (options.output) {
|
|
487
|
-
const optionsPath =
|
|
487
|
+
const optionsPath = import_node_path.default.parse(options.output);
|
|
488
488
|
let stat;
|
|
489
489
|
try {
|
|
490
490
|
stat = await import_promises.default.stat(options.output);
|
|
491
491
|
} catch {
|
|
492
492
|
stat = null;
|
|
493
493
|
}
|
|
494
|
-
if (stat?.isDirectory() || options.output.endsWith(
|
|
494
|
+
if (stat?.isDirectory() || options.output.endsWith(import_node_path.default.sep) || options.output.endsWith("/")) {
|
|
495
495
|
outputDir = options.output;
|
|
496
496
|
} else if (/^(\.[^.]+)+$/.test(optionsPath.base)) {
|
|
497
497
|
outputExt = optionsPath.base;
|
|
@@ -543,7 +543,7 @@ async function cli() {
|
|
|
543
543
|
if (stdin && !options.output || options.output === "-") {
|
|
544
544
|
process.stdout.write(output);
|
|
545
545
|
} else {
|
|
546
|
-
let targetPath =
|
|
546
|
+
let targetPath = import_node_path.default.parse(filename);
|
|
547
547
|
delete targetPath.base;
|
|
548
548
|
if (options.js) {
|
|
549
549
|
targetPath.ext += ".jsx";
|
|
@@ -562,7 +562,7 @@ async function cli() {
|
|
|
562
562
|
if (targetPath.dir) {
|
|
563
563
|
await import_promises.default.mkdir(targetPath.dir, { recursive: true });
|
|
564
564
|
}
|
|
565
|
-
const targetFilename =
|
|
565
|
+
const targetFilename = import_node_path.default.format(targetPath);
|
|
566
566
|
try {
|
|
567
567
|
await import_promises.default.writeFile(targetFilename, output);
|
|
568
568
|
} catch (error2) {
|
|
@@ -627,7 +627,7 @@ async function cli() {
|
|
|
627
627
|
module.filename = filename;
|
|
628
628
|
}
|
|
629
629
|
process.argv = ["civet", module.filename, ...scriptArgs];
|
|
630
|
-
module.paths = require("module")._nodeModulePaths(
|
|
630
|
+
module.paths = require("module")._nodeModulePaths(import_node_path.default.dirname(module.filename));
|
|
631
631
|
try {
|
|
632
632
|
module._compile(output, module.filename);
|
|
633
633
|
} catch (error2) {
|
package/dist/config.js
CHANGED
|
@@ -44,7 +44,9 @@ var configFileNames = /* @__PURE__ */ new Set([
|
|
|
44
44
|
"civetconfig.json",
|
|
45
45
|
"civetconfig.civet",
|
|
46
46
|
"civet.config.json",
|
|
47
|
-
"civet.config.civet"
|
|
47
|
+
"civet.config.civet",
|
|
48
|
+
"package.json",
|
|
49
|
+
"package.yaml"
|
|
48
50
|
]);
|
|
49
51
|
async function findInDir(dirPath) {
|
|
50
52
|
for (const entryName of await import_promises.default.readdir(dirPath)) {
|
|
@@ -92,10 +94,19 @@ async function loadConfig(path2) {
|
|
|
92
94
|
let data = {};
|
|
93
95
|
if (path2.endsWith(".json")) {
|
|
94
96
|
try {
|
|
95
|
-
|
|
97
|
+
const json = JSON.parse(config);
|
|
98
|
+
data = json.civetConfig ?? json;
|
|
96
99
|
} catch (e) {
|
|
97
100
|
throw new Error(`Error parsing JSON config file ${path2}: ${e}`);
|
|
98
101
|
}
|
|
102
|
+
} else if (/\.ya?ml$/.test(path2)) {
|
|
103
|
+
try {
|
|
104
|
+
const { default: YAML } = await import("yaml");
|
|
105
|
+
const yaml = YAML.parse(config);
|
|
106
|
+
data = yaml.civetConfig ?? yaml;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
throw new Error(`Error parsing YAML config file ${path2}: ${e}`);
|
|
109
|
+
}
|
|
99
110
|
} else {
|
|
100
111
|
let js;
|
|
101
112
|
try {
|
package/dist/esbuild.js
CHANGED
|
@@ -100,6 +100,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
100
100
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
|
+
let configErrors;
|
|
103
104
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
104
105
|
const getFormatHost = (sys) => {
|
|
105
106
|
return {
|
|
@@ -140,12 +141,13 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
ts.sys,
|
|
141
142
|
process.cwd()
|
|
142
143
|
);
|
|
144
|
+
configErrors = configContents.errors;
|
|
143
145
|
compilerOptions = {
|
|
144
146
|
...configContents.options,
|
|
145
147
|
target: ts.ScriptTarget.ESNext,
|
|
146
148
|
composite: false
|
|
147
149
|
};
|
|
148
|
-
compilerOptions.jsx ?? (compilerOptions.jsx =
|
|
150
|
+
compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
|
|
149
151
|
compilerOptionsWithSourceMap = {
|
|
150
152
|
...compilerOptions,
|
|
151
153
|
sourceMap: true
|
|
@@ -166,6 +168,31 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
166
168
|
return systemFileExists(filename.slice(0, -4));
|
|
167
169
|
};
|
|
168
170
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
|
+
if (import_path.default.basename(filename) === "package.json") {
|
|
172
|
+
let recurse2 = function(node) {
|
|
173
|
+
if (node && typeof node === "object") {
|
|
174
|
+
for (const key in node) {
|
|
175
|
+
const value = node[key];
|
|
176
|
+
if (typeof value === "string") {
|
|
177
|
+
if (value.endsWith(".civet")) {
|
|
178
|
+
node[key] = value + ".tsx";
|
|
179
|
+
modified = true;
|
|
180
|
+
}
|
|
181
|
+
} else if (value) {
|
|
182
|
+
recurse2(value);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var recurse = recurse2;
|
|
188
|
+
const json = systemReadFile(filename);
|
|
189
|
+
if (!json)
|
|
190
|
+
return json;
|
|
191
|
+
const parsed = JSON.parse(json);
|
|
192
|
+
let modified = false;
|
|
193
|
+
recurse2(parsed.imports);
|
|
194
|
+
return modified ? JSON.stringify(parsed) : json;
|
|
195
|
+
}
|
|
169
196
|
if (!filename.endsWith(".civet.tsx"))
|
|
170
197
|
return systemReadFile(filename);
|
|
171
198
|
if (fsMap.has(filename))
|
|
@@ -216,6 +243,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
243
|
start: range.start
|
|
217
244
|
};
|
|
218
245
|
});
|
|
246
|
+
if (configErrors?.length) {
|
|
247
|
+
diagnostics.unshift(...configErrors);
|
|
248
|
+
}
|
|
219
249
|
if (diagnostics.length > 0) {
|
|
220
250
|
console.error(
|
|
221
251
|
ts.formatDiagnosticsWithColorAndContext(
|