@danielx/civet 0.11.5 → 0.11.7
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 +306 -0
- package/README.md +2 -7
- package/dist/babel-plugin.js +7 -6
- package/dist/babel-plugin.mjs +3 -3
- package/dist/browser.js +807 -540
- package/dist/civet +24 -18
- package/dist/config.js +7313 -7
- package/dist/config.mjs +7338 -4
- package/dist/esbuild-plugin.js +7 -6
- package/dist/esm.mjs +10 -16
- package/dist/main.js +1787 -895
- package/dist/main.mjs +1782 -891
- package/dist/node-worker.mjs +1 -2
- package/dist/ts-diagnostic.js +5 -4
- package/dist/ts-diagnostic.mjs +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/unplugin/astro.js +8 -7
- package/dist/unplugin/astro.mjs +6 -4
- package/dist/unplugin/esbuild.d.ts +1 -1
- package/dist/unplugin/esbuild.js +7 -6
- package/dist/unplugin/esbuild.mjs +5 -3
- package/dist/unplugin/farm.d.ts +3 -1
- package/dist/unplugin/farm.js +7 -6
- package/dist/unplugin/farm.mjs +6 -4
- package/dist/unplugin/rolldown.d.ts +1 -1
- package/dist/unplugin/rolldown.js +7 -6
- package/dist/unplugin/rolldown.mjs +5 -3
- package/dist/unplugin/rollup.d.ts +1 -1
- package/dist/unplugin/rollup.js +7 -6
- package/dist/unplugin/rollup.mjs +5 -3
- package/dist/unplugin/rspack.d.ts +1 -1
- package/dist/unplugin/rspack.js +7 -6
- package/dist/unplugin/rspack.mjs +5 -3
- package/dist/unplugin/unplugin.d.ts +27 -3
- package/dist/unplugin/unplugin.js +68 -42
- package/dist/unplugin/unplugin.mjs +53 -30
- package/dist/unplugin/vite.d.ts +1 -1
- package/dist/unplugin/vite.js +7 -6
- package/dist/unplugin/vite.mjs +5 -3
- package/dist/unplugin/webpack.d.ts +1 -1
- package/dist/unplugin/webpack.js +7 -6
- package/dist/unplugin/webpack.mjs +5 -3
- package/package.json +33 -17
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,14 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
));
|
|
27
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
default: () =>
|
|
30
|
+
// source/unplugin/unplugin.civet
|
|
31
|
+
var unplugin_exports = {};
|
|
32
|
+
__export(unplugin_exports, {
|
|
33
|
+
default: () => unplugin_default,
|
|
33
34
|
rawPlugin: () => rawPlugin,
|
|
34
35
|
slash: () => slash
|
|
35
36
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(unplugin_exports);
|
|
37
38
|
var import_unplugin = require("unplugin");
|
|
38
39
|
var import_civet = __toESM(require("@danielx/civet"));
|
|
39
40
|
var import_config = require("@danielx/civet/config");
|
|
@@ -41,7 +42,7 @@ var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
|
|
|
41
42
|
var fs = __toESM(require("fs"));
|
|
42
43
|
var import_path = __toESM(require("path"));
|
|
43
44
|
|
|
44
|
-
// node_modules/@typescript/vfs/dist/vfs.esm.js
|
|
45
|
+
// node_modules/.pnpm/@typescript+vfs@1.6.4_typescript@5.8.3/node_modules/@typescript/vfs/dist/vfs.esm.js
|
|
45
46
|
function _extends() {
|
|
46
47
|
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
47
48
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -211,32 +212,38 @@ var requirePath = function requirePath2() {
|
|
|
211
212
|
return require(String.fromCharCode(112, 97, 116, 104));
|
|
212
213
|
};
|
|
213
214
|
|
|
214
|
-
//
|
|
215
|
+
// source/unplugin/unplugin.civet
|
|
215
216
|
var import_os = __toESM(require("os"));
|
|
216
|
-
|
|
217
|
-
// source/unplugin/constants.mjs
|
|
218
217
|
var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
|
|
219
|
-
|
|
220
|
-
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
|
|
221
218
|
var DiagnosticCategory = {};
|
|
222
219
|
DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
|
|
223
220
|
DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
|
|
224
221
|
DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
|
|
225
222
|
DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
|
|
226
|
-
var
|
|
223
|
+
var queryPostfixRE = /\?.*$/s;
|
|
224
|
+
var escapedHashRE = /\0#/g;
|
|
227
225
|
var isWindows = import_os.default.platform() === "win32";
|
|
228
226
|
var windowsSlashRE = /\\/g;
|
|
229
227
|
var civetSuffix = ".civet";
|
|
230
228
|
var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
|
|
231
229
|
function extractCivetFilename(id, outputExtension) {
|
|
232
230
|
let postfix = "";
|
|
233
|
-
|
|
231
|
+
id = id.replace(escapedHashRE, "#");
|
|
232
|
+
let filename = id.replace(queryPostfixRE, (match) => {
|
|
234
233
|
postfix = match;
|
|
235
234
|
return "";
|
|
236
235
|
});
|
|
237
236
|
if (filename.endsWith(outputExtension)) {
|
|
238
237
|
filename = filename.slice(0, -outputExtension.length);
|
|
239
238
|
}
|
|
239
|
+
const hashIndex = filename.lastIndexOf("#");
|
|
240
|
+
if (hashIndex >= 0 && !tryStatSync(filename)) {
|
|
241
|
+
postfix = filename.slice(hashIndex) + postfix;
|
|
242
|
+
filename = filename.slice(0, hashIndex);
|
|
243
|
+
if (filename.endsWith(outputExtension)) {
|
|
244
|
+
filename = filename.slice(0, -outputExtension.length);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
240
247
|
return { filename, postfix };
|
|
241
248
|
}
|
|
242
249
|
function tryStatSync(file) {
|
|
@@ -296,6 +303,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
296
303
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
297
304
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
298
305
|
let rootDir = process.cwd();
|
|
306
|
+
let outDir = import_path.default.join(rootDir, "dist");
|
|
299
307
|
let esbuildOptions;
|
|
300
308
|
let configErrors;
|
|
301
309
|
let configFileNames;
|
|
@@ -335,7 +343,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
335
343
|
compileOptions.threads = options.threads;
|
|
336
344
|
}
|
|
337
345
|
if (transformTS || ts === "tsc") {
|
|
338
|
-
let
|
|
346
|
+
let mogrify2 = function(key) {
|
|
339
347
|
if (key in config && Array.isArray(config[key])) {
|
|
340
348
|
return config[key] = config[key].map((item) => {
|
|
341
349
|
if (!(typeof item === "string")) {
|
|
@@ -347,20 +355,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
347
355
|
;
|
|
348
356
|
return;
|
|
349
357
|
};
|
|
358
|
+
var mogrify = mogrify2;
|
|
350
359
|
const ts2 = await tsPromise;
|
|
351
|
-
|
|
352
|
-
if (
|
|
353
|
-
|
|
360
|
+
let config, error, tsConfigPath;
|
|
361
|
+
if (options.tsConfig) {
|
|
362
|
+
config = options.tsConfig;
|
|
363
|
+
if (options.tsConfig.rootDir) {
|
|
364
|
+
tsConfigPath = import_path.default.join(options.tsConfig.rootDir, "tsconfig.json");
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
|
|
368
|
+
if (!tsConfigPath) {
|
|
369
|
+
throw new Error("Could not find 'tsconfig.json'");
|
|
370
|
+
}
|
|
371
|
+
;
|
|
372
|
+
({ config, error } = ts2.readConfigFile(
|
|
373
|
+
tsConfigPath,
|
|
374
|
+
ts2.sys.readFile
|
|
375
|
+
));
|
|
354
376
|
}
|
|
355
|
-
const { config, error } = ts2.readConfigFile(
|
|
356
|
-
tsConfigPath,
|
|
357
|
-
ts2.sys.readFile
|
|
358
|
-
);
|
|
359
377
|
if (error) {
|
|
360
378
|
console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
|
|
361
379
|
throw error;
|
|
362
380
|
}
|
|
363
|
-
|
|
381
|
+
mogrify2("files");
|
|
364
382
|
const system = { ...ts2.sys };
|
|
365
383
|
const { readDirectory: systemReadDirectory } = system;
|
|
366
384
|
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
@@ -370,7 +388,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
370
388
|
const configContents = ts2.parseJsonConfigFileContent(
|
|
371
389
|
config,
|
|
372
390
|
system,
|
|
373
|
-
process.cwd()
|
|
391
|
+
tsConfigPath ? import_path.default.dirname(tsConfigPath) : process.cwd(),
|
|
392
|
+
void 0,
|
|
393
|
+
tsConfigPath
|
|
374
394
|
);
|
|
375
395
|
configErrors = configContents.errors;
|
|
376
396
|
configFileNames = configContents.fileNames;
|
|
@@ -411,7 +431,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
411
431
|
};
|
|
412
432
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
413
433
|
if (import_path.default.basename(filename) === "package.json") {
|
|
414
|
-
let
|
|
434
|
+
let recurse2 = function(node) {
|
|
415
435
|
if (node != null && typeof node === "object") {
|
|
416
436
|
for (const key in node) {
|
|
417
437
|
const value = node[key];
|
|
@@ -421,18 +441,19 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
421
441
|
modified = true;
|
|
422
442
|
}
|
|
423
443
|
} else if (value) {
|
|
424
|
-
|
|
444
|
+
recurse2(value);
|
|
425
445
|
}
|
|
426
446
|
}
|
|
427
447
|
}
|
|
428
448
|
};
|
|
449
|
+
var recurse = recurse2;
|
|
429
450
|
const json = systemReadFile(filename, encoding);
|
|
430
451
|
if (!json) {
|
|
431
452
|
return json;
|
|
432
453
|
}
|
|
433
454
|
const parsed = JSON.parse(json);
|
|
434
455
|
let modified = false;
|
|
435
|
-
|
|
456
|
+
recurse2(parsed.imports);
|
|
436
457
|
return modified ? JSON.stringify(parsed) : json;
|
|
437
458
|
}
|
|
438
459
|
if (!filename.endsWith(".civet.tsx")) return systemReadFile(filename, encoding);
|
|
@@ -585,7 +606,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
585
606
|
if (options2.scan && meta.framework === "vite") {
|
|
586
607
|
resolved = `\0${resolved}`;
|
|
587
608
|
}
|
|
588
|
-
return resolved + outExt + postfix;
|
|
609
|
+
return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
|
|
589
610
|
},
|
|
590
611
|
loadInclude(id) {
|
|
591
612
|
const { filename, postfix } = extractCivetFilename(id, outExt);
|
|
@@ -623,18 +644,19 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
623
644
|
}
|
|
624
645
|
}
|
|
625
646
|
try {
|
|
626
|
-
let
|
|
647
|
+
let checkErrors2 = function() {
|
|
627
648
|
if (civetOptions.errors.length) {
|
|
628
649
|
throw new import_civet.default.ParseErrors(civetOptions.errors);
|
|
629
650
|
}
|
|
630
651
|
;
|
|
631
652
|
return;
|
|
632
653
|
};
|
|
654
|
+
var checkErrors = checkErrors2;
|
|
633
655
|
let compiled;
|
|
634
656
|
let sourceMap;
|
|
635
657
|
const civetOptions = {
|
|
636
658
|
...compileOptions,
|
|
637
|
-
filename
|
|
659
|
+
filename,
|
|
638
660
|
errors: []
|
|
639
661
|
};
|
|
640
662
|
const rawCivetSource = (0, import_civet.decode)(await fs.promises.readFile(filename));
|
|
@@ -642,7 +664,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
642
664
|
...civetOptions,
|
|
643
665
|
ast: true
|
|
644
666
|
});
|
|
645
|
-
const civetSourceMap = new import_civet.SourceMap(
|
|
667
|
+
const civetSourceMap = new import_civet.SourceMap(
|
|
668
|
+
rawCivetSource,
|
|
669
|
+
normalizePath(import_path.default.relative(outDir, filename))
|
|
670
|
+
);
|
|
646
671
|
if (ts === "civet") {
|
|
647
672
|
compiled = await import_civet.default.generate(ast, {
|
|
648
673
|
...civetOptions,
|
|
@@ -650,21 +675,21 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
650
675
|
sourceMap: civetSourceMap
|
|
651
676
|
});
|
|
652
677
|
sourceMap = civetSourceMap;
|
|
653
|
-
|
|
678
|
+
checkErrors2();
|
|
654
679
|
} else {
|
|
655
680
|
const compiledTS = await import_civet.default.generate(ast, {
|
|
656
681
|
...civetOptions,
|
|
657
682
|
js: false,
|
|
658
683
|
sourceMap: civetSourceMap
|
|
659
684
|
});
|
|
660
|
-
|
|
685
|
+
checkErrors2();
|
|
661
686
|
switch (ts) {
|
|
662
687
|
case "esbuild": {
|
|
663
688
|
const esbuildTransform = (await import("esbuild")).transform;
|
|
664
689
|
const result = await esbuildTransform(compiledTS, {
|
|
665
690
|
jsx: "preserve",
|
|
666
691
|
loader: "tsx",
|
|
667
|
-
sourcefile:
|
|
692
|
+
sourcefile: filename,
|
|
668
693
|
sourcemap: "external"
|
|
669
694
|
});
|
|
670
695
|
compiled = result.code;
|
|
@@ -688,7 +713,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
688
713
|
}
|
|
689
714
|
}
|
|
690
715
|
if (transformTS) {
|
|
691
|
-
for (let ref3 = import_civet.lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
|
|
716
|
+
for (let ref3 = import_civet.lib.gatherRecursive(ast, (($) => $.type === "ModuleSpecifier")), i = 0, len = ref3.length; i < len; i++) {
|
|
692
717
|
const _spec = ref3[i];
|
|
693
718
|
const spec = _spec;
|
|
694
719
|
if (spec.module?.input) {
|
|
@@ -700,7 +725,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
700
725
|
js: false,
|
|
701
726
|
sourceMap: civetSourceMap
|
|
702
727
|
});
|
|
703
|
-
|
|
728
|
+
checkErrors2();
|
|
704
729
|
const tsx = filename + ".tsx";
|
|
705
730
|
fsMap.set(tsx, compiledTS);
|
|
706
731
|
sourceMaps.set(tsx, civetSourceMap);
|
|
@@ -710,10 +735,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
710
735
|
sourceMaps.set(slashed, civetSourceMap);
|
|
711
736
|
}
|
|
712
737
|
}
|
|
713
|
-
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
|
|
714
|
-
import_path.default.relative(rootDir, extractCivetFilename(id, outExt).filename),
|
|
715
|
-
import_path.default.relative(rootDir, id)
|
|
716
|
-
));
|
|
738
|
+
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(import_path.default.relative(outDir, id))));
|
|
717
739
|
let transformed = {
|
|
718
740
|
code: compiled,
|
|
719
741
|
map: jsonSourceMap
|
|
@@ -731,8 +753,12 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
731
753
|
}
|
|
732
754
|
},
|
|
733
755
|
esbuild: {
|
|
756
|
+
// Explicitly set the loader so esbuild handles the compiled output
|
|
757
|
+
// correctly even though the virtual module id no longer ends in .jsx/.tsx.
|
|
758
|
+
loader: ts === "preserve" ? "tsx" : "jsx",
|
|
734
759
|
config(options2) {
|
|
735
760
|
esbuildOptions = options2;
|
|
761
|
+
outDir = options2.outdir || import_path.default.dirname(options2.outfile);
|
|
736
762
|
}
|
|
737
763
|
},
|
|
738
764
|
vite: {
|
|
@@ -741,13 +767,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
741
767
|
skipWorker = true;
|
|
742
768
|
}
|
|
743
769
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
770
|
+
outDir = import_path.default.resolve(rootDir, config.build?.outDir ?? "dist");
|
|
744
771
|
if (implicitExtension) {
|
|
745
772
|
config.resolve ??= {};
|
|
746
773
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
747
774
|
config.resolve.extensions.push(".civet");
|
|
748
775
|
}
|
|
749
776
|
},
|
|
750
|
-
|
|
777
|
+
transformIndexHtml(html) {
|
|
751
778
|
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
752
779
|
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
753
780
|
return script.replace(
|
|
@@ -790,7 +817,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
790
817
|
},
|
|
791
818
|
webpack(compiler) {
|
|
792
819
|
if (implicitExtension) {
|
|
793
|
-
compiler.options ??= {};
|
|
794
820
|
compiler.options.resolve ??= {};
|
|
795
821
|
compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
|
|
796
822
|
compiler.options.resolve.extensions.unshift(".civet");
|
|
@@ -819,7 +845,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
819
845
|
return plugin;
|
|
820
846
|
};
|
|
821
847
|
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
822
|
-
var
|
|
848
|
+
var unplugin_default = unplugin;
|
|
823
849
|
// Annotate the CommonJS export names for ESM import in node:
|
|
824
850
|
0 && (module.exports = {
|
|
825
851
|
rawPlugin,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
|
|
1
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
4
|
}) : x)(function(x) {
|
|
@@ -5,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
7
|
});
|
|
7
8
|
|
|
8
|
-
// unplugin-civet
|
|
9
|
+
// unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet
|
|
9
10
|
import { createUnplugin } from "unplugin";
|
|
10
11
|
import civet, { decode, lib, SourceMap } from "@danielx/civet";
|
|
11
12
|
import { findInDir, loadConfig } from "@danielx/civet/config";
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
import * as fs from "fs";
|
|
17
18
|
import path from "path";
|
|
18
19
|
|
|
19
|
-
// node_modules/@typescript/vfs/dist/vfs.esm.js
|
|
20
|
+
// node_modules/.pnpm/@typescript+vfs@1.6.4_typescript@5.8.3/node_modules/@typescript/vfs/dist/vfs.esm.js
|
|
20
21
|
function _extends() {
|
|
21
22
|
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
22
23
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -186,32 +187,38 @@ var requirePath = function requirePath2() {
|
|
|
186
187
|
return __require(String.fromCharCode(112, 97, 116, 104));
|
|
187
188
|
};
|
|
188
189
|
|
|
189
|
-
// unplugin-civet
|
|
190
|
+
// unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/unplugin.civet
|
|
190
191
|
import os from "os";
|
|
191
|
-
|
|
192
|
-
// source/unplugin/constants.mjs
|
|
193
192
|
var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
|
|
194
|
-
|
|
195
|
-
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
|
|
196
193
|
var DiagnosticCategory = {};
|
|
197
194
|
DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
|
|
198
195
|
DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
|
|
199
196
|
DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
|
|
200
197
|
DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
|
|
201
|
-
var
|
|
198
|
+
var queryPostfixRE = /\?.*$/s;
|
|
199
|
+
var escapedHashRE = /\0#/g;
|
|
202
200
|
var isWindows = os.platform() === "win32";
|
|
203
201
|
var windowsSlashRE = /\\/g;
|
|
204
202
|
var civetSuffix = ".civet";
|
|
205
203
|
var workerRE = /(?:\?|&)(?:worker|sharedworker)(?:&|$|#)/;
|
|
206
204
|
function extractCivetFilename(id, outputExtension) {
|
|
207
205
|
let postfix = "";
|
|
208
|
-
|
|
206
|
+
id = id.replace(escapedHashRE, "#");
|
|
207
|
+
let filename = id.replace(queryPostfixRE, (match) => {
|
|
209
208
|
postfix = match;
|
|
210
209
|
return "";
|
|
211
210
|
});
|
|
212
211
|
if (filename.endsWith(outputExtension)) {
|
|
213
212
|
filename = filename.slice(0, -outputExtension.length);
|
|
214
213
|
}
|
|
214
|
+
const hashIndex = filename.lastIndexOf("#");
|
|
215
|
+
if (hashIndex >= 0 && !tryStatSync(filename)) {
|
|
216
|
+
postfix = filename.slice(hashIndex) + postfix;
|
|
217
|
+
filename = filename.slice(0, hashIndex);
|
|
218
|
+
if (filename.endsWith(outputExtension)) {
|
|
219
|
+
filename = filename.slice(0, -outputExtension.length);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
215
222
|
return { filename, postfix };
|
|
216
223
|
}
|
|
217
224
|
function tryStatSync(file) {
|
|
@@ -271,6 +278,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
271
278
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
272
279
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
273
280
|
let rootDir = process.cwd();
|
|
281
|
+
let outDir = path.join(rootDir, "dist");
|
|
274
282
|
let esbuildOptions;
|
|
275
283
|
let configErrors;
|
|
276
284
|
let configFileNames;
|
|
@@ -323,14 +331,23 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
323
331
|
return;
|
|
324
332
|
};
|
|
325
333
|
const ts2 = await tsPromise;
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
|
|
334
|
+
let config, error, tsConfigPath;
|
|
335
|
+
if (options.tsConfig) {
|
|
336
|
+
config = options.tsConfig;
|
|
337
|
+
if (options.tsConfig.rootDir) {
|
|
338
|
+
tsConfigPath = path.join(options.tsConfig.rootDir, "tsconfig.json");
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
tsConfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
|
|
342
|
+
if (!tsConfigPath) {
|
|
343
|
+
throw new Error("Could not find 'tsconfig.json'");
|
|
344
|
+
}
|
|
345
|
+
;
|
|
346
|
+
({ config, error } = ts2.readConfigFile(
|
|
347
|
+
tsConfigPath,
|
|
348
|
+
ts2.sys.readFile
|
|
349
|
+
));
|
|
329
350
|
}
|
|
330
|
-
const { config, error } = ts2.readConfigFile(
|
|
331
|
-
tsConfigPath,
|
|
332
|
-
ts2.sys.readFile
|
|
333
|
-
);
|
|
334
351
|
if (error) {
|
|
335
352
|
console.error(ts2.formatDiagnostic(error, getFormatHost(ts2.sys)));
|
|
336
353
|
throw error;
|
|
@@ -345,7 +362,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
345
362
|
const configContents = ts2.parseJsonConfigFileContent(
|
|
346
363
|
config,
|
|
347
364
|
system,
|
|
348
|
-
process.cwd()
|
|
365
|
+
tsConfigPath ? path.dirname(tsConfigPath) : process.cwd(),
|
|
366
|
+
void 0,
|
|
367
|
+
tsConfigPath
|
|
349
368
|
);
|
|
350
369
|
configErrors = configContents.errors;
|
|
351
370
|
configFileNames = configContents.fileNames;
|
|
@@ -560,7 +579,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
560
579
|
if (options2.scan && meta.framework === "vite") {
|
|
561
580
|
resolved = `\0${resolved}`;
|
|
562
581
|
}
|
|
563
|
-
return resolved + outExt + postfix;
|
|
582
|
+
return resolved + (meta.framework === "esbuild" ? "" : outExt) + postfix;
|
|
564
583
|
},
|
|
565
584
|
loadInclude(id) {
|
|
566
585
|
const { filename, postfix } = extractCivetFilename(id, outExt);
|
|
@@ -609,7 +628,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
609
628
|
let sourceMap;
|
|
610
629
|
const civetOptions = {
|
|
611
630
|
...compileOptions,
|
|
612
|
-
filename
|
|
631
|
+
filename,
|
|
613
632
|
errors: []
|
|
614
633
|
};
|
|
615
634
|
const rawCivetSource = decode(await fs.promises.readFile(filename));
|
|
@@ -617,7 +636,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
617
636
|
...civetOptions,
|
|
618
637
|
ast: true
|
|
619
638
|
});
|
|
620
|
-
const civetSourceMap = new SourceMap(
|
|
639
|
+
const civetSourceMap = new SourceMap(
|
|
640
|
+
rawCivetSource,
|
|
641
|
+
normalizePath(path.relative(outDir, filename))
|
|
642
|
+
);
|
|
621
643
|
if (ts === "civet") {
|
|
622
644
|
compiled = await civet.generate(ast, {
|
|
623
645
|
...civetOptions,
|
|
@@ -639,7 +661,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
639
661
|
const result = await esbuildTransform(compiledTS, {
|
|
640
662
|
jsx: "preserve",
|
|
641
663
|
loader: "tsx",
|
|
642
|
-
sourcefile:
|
|
664
|
+
sourcefile: filename,
|
|
643
665
|
sourcemap: "external"
|
|
644
666
|
});
|
|
645
667
|
compiled = result.code;
|
|
@@ -663,7 +685,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
663
685
|
}
|
|
664
686
|
}
|
|
665
687
|
if (transformTS) {
|
|
666
|
-
for (let ref3 = lib.gatherRecursive(ast, ($) => $.type === "ModuleSpecifier"), i = 0, len = ref3.length; i < len; i++) {
|
|
688
|
+
for (let ref3 = lib.gatherRecursive(ast, (($) => $.type === "ModuleSpecifier")), i = 0, len = ref3.length; i < len; i++) {
|
|
667
689
|
const _spec = ref3[i];
|
|
668
690
|
const spec = _spec;
|
|
669
691
|
if (spec.module?.input) {
|
|
@@ -685,10 +707,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
685
707
|
sourceMaps.set(slashed, civetSourceMap);
|
|
686
708
|
}
|
|
687
709
|
}
|
|
688
|
-
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(
|
|
689
|
-
path.relative(rootDir, extractCivetFilename(id, outExt).filename),
|
|
690
|
-
path.relative(rootDir, id)
|
|
691
|
-
));
|
|
710
|
+
const jsonSourceMap = sourceMap && (typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap.json(normalizePath(path.relative(outDir, id))));
|
|
692
711
|
let transformed = {
|
|
693
712
|
code: compiled,
|
|
694
713
|
map: jsonSourceMap
|
|
@@ -706,8 +725,12 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
706
725
|
}
|
|
707
726
|
},
|
|
708
727
|
esbuild: {
|
|
728
|
+
// Explicitly set the loader so esbuild handles the compiled output
|
|
729
|
+
// correctly even though the virtual module id no longer ends in .jsx/.tsx.
|
|
730
|
+
loader: ts === "preserve" ? "tsx" : "jsx",
|
|
709
731
|
config(options2) {
|
|
710
732
|
esbuildOptions = options2;
|
|
733
|
+
outDir = options2.outdir || path.dirname(options2.outfile);
|
|
711
734
|
}
|
|
712
735
|
},
|
|
713
736
|
vite: {
|
|
@@ -716,13 +739,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
716
739
|
skipWorker = true;
|
|
717
740
|
}
|
|
718
741
|
rootDir = path.resolve(process.cwd(), config.root ?? "");
|
|
742
|
+
outDir = path.resolve(rootDir, config.build?.outDir ?? "dist");
|
|
719
743
|
if (implicitExtension) {
|
|
720
744
|
config.resolve ??= {};
|
|
721
745
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
722
746
|
config.resolve.extensions.push(".civet");
|
|
723
747
|
}
|
|
724
748
|
},
|
|
725
|
-
|
|
749
|
+
transformIndexHtml(html) {
|
|
726
750
|
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
727
751
|
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
728
752
|
return script.replace(
|
|
@@ -765,7 +789,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
765
789
|
},
|
|
766
790
|
webpack(compiler) {
|
|
767
791
|
if (implicitExtension) {
|
|
768
|
-
compiler.options ??= {};
|
|
769
792
|
compiler.options.resolve ??= {};
|
|
770
793
|
compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
|
|
771
794
|
compiler.options.resolve.extensions.unshift(".civet");
|
|
@@ -794,9 +817,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
794
817
|
return plugin;
|
|
795
818
|
};
|
|
796
819
|
var unplugin = createUnplugin(rawPlugin);
|
|
797
|
-
var
|
|
820
|
+
var unplugin_default = unplugin;
|
|
798
821
|
export {
|
|
799
|
-
|
|
822
|
+
unplugin_default as default,
|
|
800
823
|
rawPlugin,
|
|
801
824
|
slash
|
|
802
825
|
};
|
package/dist/unplugin/vite.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (options
|
|
1
|
+
declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
|
2
2
|
export default _default;
|
package/dist/unplugin/vite.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
));
|
|
27
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
default: () =>
|
|
30
|
+
// source/unplugin/vite.civet
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
default: () => vite_default
|
|
33
34
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(vite_exports);
|
|
35
36
|
var import_unplugin = __toESM(require("./unplugin.js"));
|
|
36
|
-
var
|
|
37
|
+
var vite_default = import_unplugin.default.vite;
|
package/dist/unplugin/vite.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/vite.civet
|
|
2
4
|
import civetUnplugin from "./unplugin.mjs";
|
|
3
|
-
var
|
|
5
|
+
var vite_default = civetUnplugin.vite;
|
|
4
6
|
export {
|
|
5
|
-
|
|
7
|
+
vite_default as default
|
|
6
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (options
|
|
1
|
+
declare const _default: (options?: import("./unplugin.js").PluginOptions | undefined) => import("unplugin").WebpackPluginInstance;
|
|
2
2
|
export default _default;
|
package/dist/unplugin/webpack.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
));
|
|
27
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
default: () =>
|
|
30
|
+
// source/unplugin/webpack.civet
|
|
31
|
+
var webpack_exports = {};
|
|
32
|
+
__export(webpack_exports, {
|
|
33
|
+
default: () => webpack_default
|
|
33
34
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(webpack_exports);
|
|
35
36
|
var import_unplugin = __toESM(require("./unplugin.js"));
|
|
36
|
-
var
|
|
37
|
+
var webpack_default = import_unplugin.default.webpack;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire as __civetCreateRequire } from 'node:module'; const require = __civetCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// unplugin-civet:/home/runner/work/Civet/Civet/source/unplugin/webpack.civet
|
|
2
4
|
import civetUnplugin from "./unplugin.mjs";
|
|
3
|
-
var
|
|
5
|
+
var webpack_default = civetUnplugin.webpack;
|
|
4
6
|
export {
|
|
5
|
-
|
|
7
|
+
webpack_default as default
|
|
6
8
|
};
|