@danielx/civet 0.7.14 → 0.7.16
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 -6
- package/dist/civet +16 -17
- package/dist/config.js +68 -47
- package/dist/esbuild.js +31 -6
- package/dist/rollup.js +31 -6
- package/dist/unplugin-shared.mjs +31 -6
- package/dist/unplugin.js +31 -6
- package/dist/vite.js +31 -6
- package/dist/webpack.js +31 -6
- package/package.json +1 -1
package/dist/astro.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|
package/dist/civet
CHANGED
|
@@ -98,12 +98,8 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
|
|
|
98
98
|
var encoding = "utf8";
|
|
99
99
|
function parseArgs(args) {
|
|
100
100
|
const options = {};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return !(this.ast || this.compile || this.typecheck || this.emitDeclaration);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
const filenames = [];
|
|
101
|
+
const isRun = () => !(options.ast || options.compile || options.typecheck || options.emitDeclaration);
|
|
102
|
+
let filenames = [];
|
|
107
103
|
let scriptArgs = [];
|
|
108
104
|
let i = 0;
|
|
109
105
|
let errors = 0;
|
|
@@ -208,7 +204,7 @@ function parseArgs(args) {
|
|
|
208
204
|
if (arg.startsWith("-") && arg !== "-") {
|
|
209
205
|
console.error(`Invalid command-line argument: ${arg}`);
|
|
210
206
|
errors++;
|
|
211
|
-
} else if (options.run) {
|
|
207
|
+
} else if (options.run = isRun()) {
|
|
212
208
|
endOfArgs(i);
|
|
213
209
|
} else {
|
|
214
210
|
filenames.push(arg);
|
|
@@ -217,9 +213,20 @@ function parseArgs(args) {
|
|
|
217
213
|
}
|
|
218
214
|
i++;
|
|
219
215
|
}
|
|
216
|
+
options.typescript = Boolean(options.typecheck || options.emitDeclaration);
|
|
217
|
+
if (!(filenames.length || options.typescript)) {
|
|
218
|
+
if (process.stdin.isTTY) {
|
|
219
|
+
options.repl = true;
|
|
220
|
+
} else {
|
|
221
|
+
options.compile = true;
|
|
222
|
+
options.run = false;
|
|
223
|
+
filenames = ["-"];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
220
226
|
if (errors) {
|
|
221
227
|
process.exit(Math.min(255, errors));
|
|
222
228
|
}
|
|
229
|
+
options.run = isRun();
|
|
223
230
|
return { filenames, scriptArgs, options };
|
|
224
231
|
}
|
|
225
232
|
async function* readFiles(filenames) {
|
|
@@ -457,15 +464,7 @@ async function cli() {
|
|
|
457
464
|
...options
|
|
458
465
|
};
|
|
459
466
|
}
|
|
460
|
-
if (
|
|
461
|
-
if (process.stdin.isTTY) {
|
|
462
|
-
options.repl = true;
|
|
463
|
-
} else {
|
|
464
|
-
options.compile = true;
|
|
465
|
-
filenames = ["-"];
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
if (options.typecheck || options.emitDeclaration) {
|
|
467
|
+
if (options.typescript) {
|
|
469
468
|
const unpluginOptions = {
|
|
470
469
|
...options,
|
|
471
470
|
ts: options.js ? "civet" : "preserve",
|
|
@@ -645,7 +644,7 @@ async function cli() {
|
|
|
645
644
|
emitFile({ source, fileName }) {
|
|
646
645
|
return import_promises.default.writeFile(fileName, source);
|
|
647
646
|
}
|
|
648
|
-
});
|
|
647
|
+
}, !filenames.length);
|
|
649
648
|
} catch (error) {
|
|
650
649
|
let ref1;
|
|
651
650
|
if (ref1 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
|
package/dist/config.js
CHANGED
|
@@ -38,40 +38,51 @@ module.exports = __toCommonJS(config_exports);
|
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_promises = __toESM(require("fs/promises"));
|
|
40
40
|
var import_main = require("./main.js");
|
|
41
|
-
var
|
|
42
|
-
"\u{1F408}
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
41
|
+
var configNames = [
|
|
42
|
+
"\u{1F408}",
|
|
43
|
+
"civetconfig",
|
|
44
|
+
"civet.config",
|
|
45
|
+
"package"
|
|
46
|
+
];
|
|
47
|
+
var configExtensions = [
|
|
48
|
+
".civet",
|
|
49
|
+
".js",
|
|
50
|
+
".yaml",
|
|
51
|
+
".yml",
|
|
52
|
+
".json"
|
|
53
|
+
];
|
|
54
|
+
var configDir = ".config";
|
|
51
55
|
async function findInDir(dirPath) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
})()) {
|
|
61
|
-
const found = await findInDir(entryPath);
|
|
62
|
-
if (found) {
|
|
63
|
-
return found;
|
|
64
|
-
}
|
|
56
|
+
const entries = new Set(await import_promises.default.readdir(dirPath));
|
|
57
|
+
const pathFor = (name) => import_path.default.join(dirPath, name);
|
|
58
|
+
if (entries.has(configDir) && await (async () => {
|
|
59
|
+
try {
|
|
60
|
+
return (await import_promises.default.stat(pathFor(configDir))).isDirectory();
|
|
61
|
+
} catch (e) {
|
|
62
|
+
return;
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
})()) {
|
|
65
|
+
const found = await findInDir(pathFor(configDir));
|
|
66
|
+
if (found) {
|
|
67
|
+
return found;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0, len = configNames.length; i < len; i++) {
|
|
71
|
+
const configName = configNames[i];
|
|
72
|
+
for (let i1 = 0, len1 = configExtensions.length; i1 < len1; i1++) {
|
|
73
|
+
const extension = configExtensions[i1];
|
|
74
|
+
for (let ref = ["." + configName + extension, configName + extension], i2 = 0, len2 = ref.length; i2 < len2; i2++) {
|
|
75
|
+
const entry = ref[i2];
|
|
76
|
+
if (entries.has(entry) && await (async () => {
|
|
77
|
+
try {
|
|
78
|
+
return (await import_promises.default.stat(pathFor(entry))).isFile();
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
})()) {
|
|
83
|
+
return pathFor(entry);
|
|
84
|
+
}
|
|
72
85
|
}
|
|
73
|
-
})()) {
|
|
74
|
-
return entryPath;
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
return;
|
|
@@ -89,39 +100,49 @@ async function findConfig(startDir) {
|
|
|
89
100
|
}
|
|
90
101
|
return;
|
|
91
102
|
}
|
|
92
|
-
async function loadConfig(
|
|
93
|
-
const config = await import_promises.default.readFile(
|
|
103
|
+
async function loadConfig(pathname) {
|
|
104
|
+
const config = await import_promises.default.readFile(pathname, "utf8");
|
|
94
105
|
let data = {};
|
|
95
|
-
if (
|
|
106
|
+
if (pathname.endsWith(".json")) {
|
|
107
|
+
let json;
|
|
96
108
|
try {
|
|
97
|
-
|
|
98
|
-
data = json.civetConfig ?? json;
|
|
109
|
+
json = JSON.parse(config);
|
|
99
110
|
} catch (e) {
|
|
100
|
-
throw new Error(`Error parsing JSON config file ${
|
|
111
|
+
throw new Error(`Error parsing JSON config file ${pathname}: ${e}`);
|
|
101
112
|
}
|
|
102
|
-
|
|
113
|
+
if ("civetConfig" in json) {
|
|
114
|
+
data = json.civetConfig;
|
|
115
|
+
} else if (import_path.default.basename(pathname).startsWith("package")) {
|
|
116
|
+
return {};
|
|
117
|
+
} else {
|
|
118
|
+
data = json;
|
|
119
|
+
}
|
|
120
|
+
} else if (/\.ya?ml$/.test(pathname)) {
|
|
103
121
|
try {
|
|
104
122
|
const { default: YAML } = await import("yaml");
|
|
105
123
|
const yaml = YAML.parse(config);
|
|
106
124
|
data = yaml.civetConfig ?? yaml;
|
|
107
125
|
} catch (e) {
|
|
108
|
-
throw new Error(`Error parsing YAML config file ${
|
|
126
|
+
throw new Error(`Error parsing YAML config file ${pathname}: ${e}`);
|
|
109
127
|
}
|
|
110
128
|
} else {
|
|
111
129
|
let js;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
js
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
if (pathname.endsWith(".civet")) {
|
|
131
|
+
try {
|
|
132
|
+
js = await (0, import_main.compile)(config, {
|
|
133
|
+
js: true
|
|
134
|
+
});
|
|
135
|
+
} catch (e) {
|
|
136
|
+
throw new Error(`Error compiling Civet config file ${pathname}: ${e}`);
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
js = config;
|
|
119
140
|
}
|
|
120
141
|
try {
|
|
121
142
|
const exports2 = await import(`data:text/javascript,${encodeURIComponent(js)}`);
|
|
122
143
|
data = exports2?.default;
|
|
123
144
|
} catch (e) {
|
|
124
|
-
throw new Error(`Error running Civet config file ${
|
|
145
|
+
throw new Error(`Error running Civet config file ${pathname}: ${e}`);
|
|
125
146
|
}
|
|
126
147
|
}
|
|
127
148
|
if (!(data != null && typeof data === "object" && !Array.isArray(data))) {
|
package/dist/esbuild.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|
package/dist/rollup.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -68,6 +68,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
68
68
|
let rootDir = process.cwd();
|
|
69
69
|
let esbuildOptions;
|
|
70
70
|
let configErrors;
|
|
71
|
+
let configFileNames;
|
|
71
72
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
72
73
|
const getFormatHost = (sys) => {
|
|
73
74
|
return {
|
|
@@ -82,6 +83,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
82
83
|
enforce: "pre",
|
|
83
84
|
async buildStart() {
|
|
84
85
|
if (transformTS || options.ts === "tsc") {
|
|
86
|
+
let mogrify2 = function(key) {
|
|
87
|
+
if (key in config && Array.isArray(config[key])) {
|
|
88
|
+
config[key] = config[key].map((item) => {
|
|
89
|
+
if (typeof item !== "string")
|
|
90
|
+
return item;
|
|
91
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var mogrify = mogrify2;
|
|
85
96
|
const ts = await tsPromise;
|
|
86
97
|
const civetConfigPath = "config" in options ? options.config : await findInDir(process.cwd());
|
|
87
98
|
if (civetConfigPath) {
|
|
@@ -103,12 +114,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
103
114
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
104
115
|
throw error;
|
|
105
116
|
}
|
|
117
|
+
mogrify2("files");
|
|
118
|
+
const system = { ...ts.sys };
|
|
119
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
120
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
121
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
122
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
123
|
+
};
|
|
106
124
|
const configContents = ts.parseJsonConfigFileContent(
|
|
107
125
|
config,
|
|
108
|
-
|
|
126
|
+
system,
|
|
109
127
|
process.cwd()
|
|
110
128
|
);
|
|
111
129
|
configErrors = configContents.errors;
|
|
130
|
+
configFileNames = configContents.fileNames;
|
|
112
131
|
compilerOptions = {
|
|
113
132
|
...configContents.options,
|
|
114
133
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -122,11 +141,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
122
141
|
fsMap = /* @__PURE__ */ new Map();
|
|
123
142
|
}
|
|
124
143
|
},
|
|
125
|
-
async buildEnd() {
|
|
144
|
+
async buildEnd(useConfigFileNames = false) {
|
|
126
145
|
if (transformTS) {
|
|
127
146
|
const ts = await tsPromise;
|
|
128
147
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
129
|
-
const {
|
|
148
|
+
const {
|
|
149
|
+
fileExists: systemFileExists,
|
|
150
|
+
readFile: systemReadFile,
|
|
151
|
+
readDirectory: systemReadDirectory
|
|
152
|
+
} = system;
|
|
130
153
|
system.fileExists = (filename) => {
|
|
131
154
|
if (!filename.endsWith(".civet.tsx"))
|
|
132
155
|
return systemFileExists(filename);
|
|
@@ -134,6 +157,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
134
157
|
return true;
|
|
135
158
|
return systemFileExists(filename.slice(0, -4));
|
|
136
159
|
};
|
|
160
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
137
161
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
138
162
|
if (path.basename(filename) === "package.json") {
|
|
139
163
|
let recurse2 = function(node) {
|
|
@@ -152,7 +176,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
152
176
|
}
|
|
153
177
|
};
|
|
154
178
|
var recurse = recurse2;
|
|
155
|
-
const json = systemReadFile(filename);
|
|
179
|
+
const json = systemReadFile(filename, encoding);
|
|
156
180
|
if (!json)
|
|
157
181
|
return json;
|
|
158
182
|
const parsed = JSON.parse(json);
|
|
@@ -161,7 +185,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
161
185
|
return modified ? JSON.stringify(parsed) : json;
|
|
162
186
|
}
|
|
163
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
164
|
-
return systemReadFile(filename);
|
|
188
|
+
return systemReadFile(filename, encoding);
|
|
165
189
|
if (fsMap.has(filename))
|
|
166
190
|
return fsMap.get(filename);
|
|
167
191
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -183,8 +207,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
183
207
|
compilerOptions,
|
|
184
208
|
ts
|
|
185
209
|
);
|
|
210
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
186
211
|
const program = ts.createProgram({
|
|
187
|
-
rootNames: [...fsMap.keys()],
|
|
212
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
188
213
|
options: compilerOptions,
|
|
189
214
|
host: host.compilerHost
|
|
190
215
|
});
|
package/dist/unplugin.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|
package/dist/vite.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|
package/dist/webpack.js
CHANGED
|
@@ -101,6 +101,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
101
101
|
let rootDir = process.cwd();
|
|
102
102
|
let esbuildOptions;
|
|
103
103
|
let configErrors;
|
|
104
|
+
let configFileNames;
|
|
104
105
|
const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
|
|
105
106
|
const getFormatHost = (sys) => {
|
|
106
107
|
return {
|
|
@@ -115,6 +116,16 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
115
116
|
enforce: "pre",
|
|
116
117
|
async buildStart() {
|
|
117
118
|
if (transformTS || options.ts === "tsc") {
|
|
119
|
+
let mogrify2 = function(key) {
|
|
120
|
+
if (key in config && Array.isArray(config[key])) {
|
|
121
|
+
config[key] = config[key].map((item) => {
|
|
122
|
+
if (typeof item !== "string")
|
|
123
|
+
return item;
|
|
124
|
+
return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var mogrify = mogrify2;
|
|
118
129
|
const ts = await tsPromise;
|
|
119
130
|
const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
|
|
120
131
|
if (civetConfigPath) {
|
|
@@ -136,12 +147,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
136
147
|
console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
|
|
137
148
|
throw error;
|
|
138
149
|
}
|
|
150
|
+
mogrify2("files");
|
|
151
|
+
const system = { ...ts.sys };
|
|
152
|
+
const { readDirectory: systemReadDirectory } = system;
|
|
153
|
+
system.readDirectory = (path2, extensions, excludes, includes, depth) => {
|
|
154
|
+
extensions = [...extensions ?? [], ".civet"];
|
|
155
|
+
return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
156
|
+
};
|
|
139
157
|
const configContents = ts.parseJsonConfigFileContent(
|
|
140
158
|
config,
|
|
141
|
-
|
|
159
|
+
system,
|
|
142
160
|
process.cwd()
|
|
143
161
|
);
|
|
144
162
|
configErrors = configContents.errors;
|
|
163
|
+
configFileNames = configContents.fileNames;
|
|
145
164
|
compilerOptions = {
|
|
146
165
|
...configContents.options,
|
|
147
166
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -155,11 +174,15 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
155
174
|
fsMap = /* @__PURE__ */ new Map();
|
|
156
175
|
}
|
|
157
176
|
},
|
|
158
|
-
async buildEnd() {
|
|
177
|
+
async buildEnd(useConfigFileNames = false) {
|
|
159
178
|
if (transformTS) {
|
|
160
179
|
const ts = await tsPromise;
|
|
161
180
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
162
|
-
const {
|
|
181
|
+
const {
|
|
182
|
+
fileExists: systemFileExists,
|
|
183
|
+
readFile: systemReadFile,
|
|
184
|
+
readDirectory: systemReadDirectory
|
|
185
|
+
} = system;
|
|
163
186
|
system.fileExists = (filename) => {
|
|
164
187
|
if (!filename.endsWith(".civet.tsx"))
|
|
165
188
|
return systemFileExists(filename);
|
|
@@ -167,6 +190,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
167
190
|
return true;
|
|
168
191
|
return systemFileExists(filename.slice(0, -4));
|
|
169
192
|
};
|
|
193
|
+
system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
|
|
170
194
|
system.readFile = (filename, encoding = "utf-8") => {
|
|
171
195
|
if (import_path.default.basename(filename) === "package.json") {
|
|
172
196
|
let recurse2 = function(node) {
|
|
@@ -185,7 +209,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
185
209
|
}
|
|
186
210
|
};
|
|
187
211
|
var recurse = recurse2;
|
|
188
|
-
const json = systemReadFile(filename);
|
|
212
|
+
const json = systemReadFile(filename, encoding);
|
|
189
213
|
if (!json)
|
|
190
214
|
return json;
|
|
191
215
|
const parsed = JSON.parse(json);
|
|
@@ -194,7 +218,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
194
218
|
return modified ? JSON.stringify(parsed) : json;
|
|
195
219
|
}
|
|
196
220
|
if (!filename.endsWith(".civet.tsx"))
|
|
197
|
-
return systemReadFile(filename);
|
|
221
|
+
return systemReadFile(filename, encoding);
|
|
198
222
|
if (fsMap.has(filename))
|
|
199
223
|
return fsMap.get(filename);
|
|
200
224
|
const civetFilename = filename.slice(0, -4);
|
|
@@ -216,8 +240,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
216
240
|
compilerOptions,
|
|
217
241
|
ts
|
|
218
242
|
);
|
|
243
|
+
host.compilerHost.getDirectories = system.getDirectories;
|
|
219
244
|
const program = ts.createProgram({
|
|
220
|
-
rootNames: [...fsMap.keys()],
|
|
245
|
+
rootNames: useConfigFileNames ? configFileNames : [...fsMap.keys()],
|
|
221
246
|
options: compilerOptions,
|
|
222
247
|
host: host.compilerHost
|
|
223
248
|
});
|