@danielx/civet 0.6.78 → 0.6.80
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/browser.js +15 -2
- package/dist/esbuild.js +59 -19
- package/dist/main.js +15 -2
- package/dist/main.mjs +15 -2
- package/dist/rollup.js +59 -19
- package/dist/unplugin-shared.mjs +59 -19
- package/dist/unplugin.d.mts +3 -3
- package/dist/unplugin.d.ts +3 -3
- package/dist/unplugin.js +59 -19
- package/dist/vite.js +59 -19
- package/dist/webpack.js +59 -19
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -2411,9 +2411,16 @@ var Civet = (() => {
|
|
|
2411
2411
|
const { decl, bindings } = condition.declaration;
|
|
2412
2412
|
const binding = bindings[0];
|
|
2413
2413
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2414
|
+
const grandparent = condition.parent?.parent;
|
|
2415
|
+
const children = (
|
|
2416
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2417
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2418
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2419
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2420
|
+
);
|
|
2414
2421
|
Object.assign(condition, {
|
|
2415
2422
|
type: "AssignmentExpression",
|
|
2416
|
-
children
|
|
2423
|
+
children,
|
|
2417
2424
|
hoistDec: {
|
|
2418
2425
|
type: "Declaration",
|
|
2419
2426
|
children: ["let ", ref, suffix],
|
|
@@ -2887,7 +2894,13 @@ var Civet = (() => {
|
|
|
2887
2894
|
};
|
|
2888
2895
|
}
|
|
2889
2896
|
function modifyString(str) {
|
|
2890
|
-
return str.replace(/(
|
|
2897
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2898
|
+
if (nl) {
|
|
2899
|
+
return chars + "\\n";
|
|
2900
|
+
} else {
|
|
2901
|
+
return chars;
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2891
2904
|
}
|
|
2892
2905
|
function quoteString(str) {
|
|
2893
2906
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/esbuild.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -239,28 +264,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
239
264
|
if (/\0/.test(id))
|
|
240
265
|
return null;
|
|
241
266
|
id = cleanCivetId(id);
|
|
242
|
-
|
|
243
|
-
if (!
|
|
267
|
+
let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
268
|
+
if (!resolvedId)
|
|
244
269
|
return null;
|
|
245
|
-
|
|
246
|
-
if (!relativeId.endsWith(".civet")) {
|
|
270
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
247
271
|
if (!implicitExtension)
|
|
248
272
|
return null;
|
|
249
|
-
const implicitId = implicitCivet(
|
|
273
|
+
const implicitId = implicitCivet(resolvedId);
|
|
250
274
|
if (!implicitId)
|
|
251
275
|
return null;
|
|
252
|
-
|
|
276
|
+
resolvedId = implicitId;
|
|
253
277
|
}
|
|
254
|
-
|
|
255
|
-
return relativePath;
|
|
278
|
+
return resolvedId + outExt;
|
|
256
279
|
},
|
|
257
280
|
loadInclude(id) {
|
|
258
|
-
return isCivetTranspiled(id);
|
|
281
|
+
return isCivetTranspiled.test(id);
|
|
259
282
|
},
|
|
260
283
|
async load(id) {
|
|
261
|
-
|
|
284
|
+
const match = isCivetTranspiled.exec(id);
|
|
285
|
+
if (!match)
|
|
262
286
|
return null;
|
|
263
|
-
const
|
|
287
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
288
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
264
289
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
265
290
|
this.addWatchFile(filename);
|
|
266
291
|
let compiled;
|
|
@@ -351,11 +376,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
351
376
|
},
|
|
352
377
|
vite: {
|
|
353
378
|
config(config) {
|
|
354
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
355
380
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
381
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
382
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
383
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
384
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
385
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
386
|
+
unplugin.esbuild({
|
|
387
|
+
...options,
|
|
388
|
+
js: void 0,
|
|
389
|
+
ts: "preserve",
|
|
390
|
+
dts: void 0,
|
|
391
|
+
emitDeclaration: false,
|
|
392
|
+
typecheck: false
|
|
393
|
+
})
|
|
394
|
+
);
|
|
356
395
|
if (implicitExtension) {
|
|
357
396
|
config.resolve ?? (config.resolve = {});
|
|
358
|
-
(
|
|
397
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
359
398
|
config.resolve.extensions.push(".civet");
|
|
360
399
|
}
|
|
361
400
|
},
|
|
@@ -380,10 +419,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
380
419
|
handleHotUpdate({ file, server, modules }) {
|
|
381
420
|
if (!file.endsWith(".civet"))
|
|
382
421
|
return;
|
|
383
|
-
const
|
|
384
|
-
const module2 = server.moduleGraph.getModuleById(
|
|
422
|
+
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
423
|
+
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
385
424
|
if (module2) {
|
|
386
|
-
server.moduleGraph.onFileChange(
|
|
425
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
387
426
|
return [...modules, module2];
|
|
388
427
|
}
|
|
389
428
|
return modules;
|
|
@@ -391,7 +430,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
};
|
|
394
|
-
var
|
|
433
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
434
|
+
var src_default = unplugin;
|
|
395
435
|
|
|
396
436
|
// src/esbuild.ts
|
|
397
437
|
var esbuild_default = src_default.esbuild;
|
package/dist/main.js
CHANGED
|
@@ -2403,9 +2403,16 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
2403
2403
|
const { decl, bindings } = condition.declaration;
|
|
2404
2404
|
const binding = bindings[0];
|
|
2405
2405
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2406
|
+
const grandparent = condition.parent?.parent;
|
|
2407
|
+
const children = (
|
|
2408
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2409
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2410
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2411
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2412
|
+
);
|
|
2406
2413
|
Object.assign(condition, {
|
|
2407
2414
|
type: "AssignmentExpression",
|
|
2408
|
-
children
|
|
2415
|
+
children,
|
|
2409
2416
|
hoistDec: {
|
|
2410
2417
|
type: "Declaration",
|
|
2411
2418
|
children: ["let ", ref, suffix],
|
|
@@ -2879,7 +2886,13 @@ function processCoffeeInterpolation(s, parts, e, $loc) {
|
|
|
2879
2886
|
};
|
|
2880
2887
|
}
|
|
2881
2888
|
function modifyString(str) {
|
|
2882
|
-
return str.replace(/(
|
|
2889
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2890
|
+
if (nl) {
|
|
2891
|
+
return chars + "\\n";
|
|
2892
|
+
} else {
|
|
2893
|
+
return chars;
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2883
2896
|
}
|
|
2884
2897
|
function quoteString(str) {
|
|
2885
2898
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/main.mjs
CHANGED
|
@@ -2401,9 +2401,16 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
2401
2401
|
const { decl, bindings } = condition.declaration;
|
|
2402
2402
|
const binding = bindings[0];
|
|
2403
2403
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2404
|
+
const grandparent = condition.parent?.parent;
|
|
2405
|
+
const children = (
|
|
2406
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2407
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2408
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2409
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2410
|
+
);
|
|
2404
2411
|
Object.assign(condition, {
|
|
2405
2412
|
type: "AssignmentExpression",
|
|
2406
|
-
children
|
|
2413
|
+
children,
|
|
2407
2414
|
hoistDec: {
|
|
2408
2415
|
type: "Declaration",
|
|
2409
2416
|
children: ["let ", ref, suffix],
|
|
@@ -2877,7 +2884,13 @@ function processCoffeeInterpolation(s, parts, e, $loc) {
|
|
|
2877
2884
|
};
|
|
2878
2885
|
}
|
|
2879
2886
|
function modifyString(str) {
|
|
2880
|
-
return str.replace(/(
|
|
2887
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2888
|
+
if (nl) {
|
|
2889
|
+
return chars + "\\n";
|
|
2890
|
+
} else {
|
|
2891
|
+
return chars;
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2881
2894
|
}
|
|
2882
2895
|
function quoteString(str) {
|
|
2883
2896
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/rollup.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -239,28 +264,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
239
264
|
if (/\0/.test(id))
|
|
240
265
|
return null;
|
|
241
266
|
id = cleanCivetId(id);
|
|
242
|
-
|
|
243
|
-
if (!
|
|
267
|
+
let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
268
|
+
if (!resolvedId)
|
|
244
269
|
return null;
|
|
245
|
-
|
|
246
|
-
if (!relativeId.endsWith(".civet")) {
|
|
270
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
247
271
|
if (!implicitExtension)
|
|
248
272
|
return null;
|
|
249
|
-
const implicitId = implicitCivet(
|
|
273
|
+
const implicitId = implicitCivet(resolvedId);
|
|
250
274
|
if (!implicitId)
|
|
251
275
|
return null;
|
|
252
|
-
|
|
276
|
+
resolvedId = implicitId;
|
|
253
277
|
}
|
|
254
|
-
|
|
255
|
-
return relativePath;
|
|
278
|
+
return resolvedId + outExt;
|
|
256
279
|
},
|
|
257
280
|
loadInclude(id) {
|
|
258
|
-
return isCivetTranspiled(id);
|
|
281
|
+
return isCivetTranspiled.test(id);
|
|
259
282
|
},
|
|
260
283
|
async load(id) {
|
|
261
|
-
|
|
284
|
+
const match = isCivetTranspiled.exec(id);
|
|
285
|
+
if (!match)
|
|
262
286
|
return null;
|
|
263
|
-
const
|
|
287
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
288
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
264
289
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
265
290
|
this.addWatchFile(filename);
|
|
266
291
|
let compiled;
|
|
@@ -351,11 +376,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
351
376
|
},
|
|
352
377
|
vite: {
|
|
353
378
|
config(config) {
|
|
354
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
355
380
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
381
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
382
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
383
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
384
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
385
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
386
|
+
unplugin.esbuild({
|
|
387
|
+
...options,
|
|
388
|
+
js: void 0,
|
|
389
|
+
ts: "preserve",
|
|
390
|
+
dts: void 0,
|
|
391
|
+
emitDeclaration: false,
|
|
392
|
+
typecheck: false
|
|
393
|
+
})
|
|
394
|
+
);
|
|
356
395
|
if (implicitExtension) {
|
|
357
396
|
config.resolve ?? (config.resolve = {});
|
|
358
|
-
(
|
|
397
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
359
398
|
config.resolve.extensions.push(".civet");
|
|
360
399
|
}
|
|
361
400
|
},
|
|
@@ -380,10 +419,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
380
419
|
handleHotUpdate({ file, server, modules }) {
|
|
381
420
|
if (!file.endsWith(".civet"))
|
|
382
421
|
return;
|
|
383
|
-
const
|
|
384
|
-
const module2 = server.moduleGraph.getModuleById(
|
|
422
|
+
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
423
|
+
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
385
424
|
if (module2) {
|
|
386
|
-
server.moduleGraph.onFileChange(
|
|
425
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
387
426
|
return [...modules, module2];
|
|
388
427
|
}
|
|
389
428
|
return modules;
|
|
@@ -391,7 +430,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
};
|
|
394
|
-
var
|
|
433
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
434
|
+
var src_default = unplugin;
|
|
395
435
|
|
|
396
436
|
// src/rollup.ts
|
|
397
437
|
var rollup_default = src_default.rollup;
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import * as fs from "fs";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import * as tsvfs from "@typescript/vfs";
|
|
11
11
|
import os from "os";
|
|
12
|
-
var isCivetTranspiled = (
|
|
12
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
13
13
|
var postfixRE = /[?#].*$/s;
|
|
14
14
|
var isWindows = os.platform() === "win32";
|
|
15
15
|
var windowsSlashRE = /\\/g;
|
|
@@ -93,7 +93,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
93
93
|
);
|
|
94
94
|
compilerOptions = {
|
|
95
95
|
...configContents.options,
|
|
96
|
-
target: ts.ScriptTarget.ESNext
|
|
96
|
+
target: ts.ScriptTarget.ESNext,
|
|
97
|
+
composite: false
|
|
97
98
|
};
|
|
98
99
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
99
100
|
compilerOptionsWithSourceMap = {
|
|
@@ -107,6 +108,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
107
108
|
if (transformTS) {
|
|
108
109
|
const ts = await tsPromise;
|
|
109
110
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
111
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
112
|
+
system.fileExists = (filename) => {
|
|
113
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
114
|
+
return systemFileExists(filename);
|
|
115
|
+
if (fsMap.has(filename))
|
|
116
|
+
return true;
|
|
117
|
+
return systemFileExists(filename.slice(0, -4));
|
|
118
|
+
};
|
|
119
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
120
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
121
|
+
return systemReadFile(filename);
|
|
122
|
+
if (fsMap.has(filename))
|
|
123
|
+
return fsMap.get(filename);
|
|
124
|
+
const civetFilename = filename.slice(0, -4);
|
|
125
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
126
|
+
encoding
|
|
127
|
+
});
|
|
128
|
+
const compiledTS = civet.compile(rawCivetSource, {
|
|
129
|
+
filename,
|
|
130
|
+
js: false
|
|
131
|
+
});
|
|
132
|
+
fsMap.set(filename, compiledTS);
|
|
133
|
+
return compiledTS;
|
|
134
|
+
};
|
|
110
135
|
const host = tsvfs.createVirtualCompilerHost(
|
|
111
136
|
system,
|
|
112
137
|
compilerOptions,
|
|
@@ -206,28 +231,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
206
231
|
if (/\0/.test(id))
|
|
207
232
|
return null;
|
|
208
233
|
id = cleanCivetId(id);
|
|
209
|
-
|
|
210
|
-
if (!
|
|
234
|
+
let resolvedId = path.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : path.resolve(path.dirname(importer ?? ""), id);
|
|
235
|
+
if (!resolvedId)
|
|
211
236
|
return null;
|
|
212
|
-
|
|
213
|
-
if (!relativeId.endsWith(".civet")) {
|
|
237
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
214
238
|
if (!implicitExtension)
|
|
215
239
|
return null;
|
|
216
|
-
const implicitId = implicitCivet(
|
|
240
|
+
const implicitId = implicitCivet(resolvedId);
|
|
217
241
|
if (!implicitId)
|
|
218
242
|
return null;
|
|
219
|
-
|
|
243
|
+
resolvedId = implicitId;
|
|
220
244
|
}
|
|
221
|
-
|
|
222
|
-
return relativePath;
|
|
245
|
+
return resolvedId + outExt;
|
|
223
246
|
},
|
|
224
247
|
loadInclude(id) {
|
|
225
|
-
return isCivetTranspiled(id);
|
|
248
|
+
return isCivetTranspiled.test(id);
|
|
226
249
|
},
|
|
227
250
|
async load(id) {
|
|
228
|
-
|
|
251
|
+
const match = isCivetTranspiled.exec(id);
|
|
252
|
+
if (!match)
|
|
229
253
|
return null;
|
|
230
|
-
const
|
|
254
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
255
|
+
const filename = path.resolve(rootDir, basename);
|
|
231
256
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
232
257
|
this.addWatchFile(filename);
|
|
233
258
|
let compiled;
|
|
@@ -318,11 +343,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
318
343
|
},
|
|
319
344
|
vite: {
|
|
320
345
|
config(config) {
|
|
321
|
-
var _a;
|
|
346
|
+
var _a, _b, _c;
|
|
322
347
|
rootDir = path.resolve(process.cwd(), config.root ?? "");
|
|
348
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
349
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
350
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
351
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
352
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
353
|
+
unplugin.esbuild({
|
|
354
|
+
...options,
|
|
355
|
+
js: void 0,
|
|
356
|
+
ts: "preserve",
|
|
357
|
+
dts: void 0,
|
|
358
|
+
emitDeclaration: false,
|
|
359
|
+
typecheck: false
|
|
360
|
+
})
|
|
361
|
+
);
|
|
323
362
|
if (implicitExtension) {
|
|
324
363
|
config.resolve ?? (config.resolve = {});
|
|
325
|
-
(
|
|
364
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
326
365
|
config.resolve.extensions.push(".civet");
|
|
327
366
|
}
|
|
328
367
|
},
|
|
@@ -347,10 +386,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
347
386
|
handleHotUpdate({ file, server, modules }) {
|
|
348
387
|
if (!file.endsWith(".civet"))
|
|
349
388
|
return;
|
|
350
|
-
const
|
|
351
|
-
const module = server.moduleGraph.getModuleById(
|
|
389
|
+
const resolvedId = slash(path.resolve(file) + outExt);
|
|
390
|
+
const module = server.moduleGraph.getModuleById(resolvedId);
|
|
352
391
|
if (module) {
|
|
353
|
-
server.moduleGraph.onFileChange(
|
|
392
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
354
393
|
return [...modules, module];
|
|
355
394
|
}
|
|
356
395
|
return modules;
|
|
@@ -358,7 +397,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
358
397
|
}
|
|
359
398
|
};
|
|
360
399
|
};
|
|
361
|
-
var
|
|
400
|
+
var unplugin = createUnplugin(rawPlugin);
|
|
401
|
+
var src_default = unplugin;
|
|
362
402
|
|
|
363
403
|
export {
|
|
364
404
|
slash,
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { TransformResult, createUnplugin } from 'unplugin';
|
|
3
3
|
|
|
4
4
|
type PluginOptions = {
|
|
@@ -15,6 +15,6 @@ type PluginOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function slash(p: string): string;
|
|
17
17
|
declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
|
|
18
|
-
declare
|
|
18
|
+
declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
19
19
|
|
|
20
|
-
export { PluginOptions,
|
|
20
|
+
export { PluginOptions, unplugin as default, rawPlugin, slash };
|
package/dist/unplugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { TransformResult, createUnplugin } from 'unplugin';
|
|
3
3
|
|
|
4
4
|
type PluginOptions = {
|
|
@@ -15,6 +15,6 @@ type PluginOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function slash(p: string): string;
|
|
17
17
|
declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
|
|
18
|
-
declare
|
|
18
|
+
declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
19
19
|
|
|
20
|
-
export { PluginOptions,
|
|
20
|
+
export { PluginOptions, unplugin as default, rawPlugin, slash };
|
package/dist/unplugin.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -239,28 +264,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
239
264
|
if (/\0/.test(id))
|
|
240
265
|
return null;
|
|
241
266
|
id = cleanCivetId(id);
|
|
242
|
-
|
|
243
|
-
if (!
|
|
267
|
+
let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
268
|
+
if (!resolvedId)
|
|
244
269
|
return null;
|
|
245
|
-
|
|
246
|
-
if (!relativeId.endsWith(".civet")) {
|
|
270
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
247
271
|
if (!implicitExtension)
|
|
248
272
|
return null;
|
|
249
|
-
const implicitId = implicitCivet(
|
|
273
|
+
const implicitId = implicitCivet(resolvedId);
|
|
250
274
|
if (!implicitId)
|
|
251
275
|
return null;
|
|
252
|
-
|
|
276
|
+
resolvedId = implicitId;
|
|
253
277
|
}
|
|
254
|
-
|
|
255
|
-
return relativePath;
|
|
278
|
+
return resolvedId + outExt;
|
|
256
279
|
},
|
|
257
280
|
loadInclude(id) {
|
|
258
|
-
return isCivetTranspiled(id);
|
|
281
|
+
return isCivetTranspiled.test(id);
|
|
259
282
|
},
|
|
260
283
|
async load(id) {
|
|
261
|
-
|
|
284
|
+
const match = isCivetTranspiled.exec(id);
|
|
285
|
+
if (!match)
|
|
262
286
|
return null;
|
|
263
|
-
const
|
|
287
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
288
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
264
289
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
265
290
|
this.addWatchFile(filename);
|
|
266
291
|
let compiled;
|
|
@@ -351,11 +376,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
351
376
|
},
|
|
352
377
|
vite: {
|
|
353
378
|
config(config) {
|
|
354
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
355
380
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
381
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
382
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
383
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
384
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
385
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
386
|
+
unplugin.esbuild({
|
|
387
|
+
...options,
|
|
388
|
+
js: void 0,
|
|
389
|
+
ts: "preserve",
|
|
390
|
+
dts: void 0,
|
|
391
|
+
emitDeclaration: false,
|
|
392
|
+
typecheck: false
|
|
393
|
+
})
|
|
394
|
+
);
|
|
356
395
|
if (implicitExtension) {
|
|
357
396
|
config.resolve ?? (config.resolve = {});
|
|
358
|
-
(
|
|
397
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
359
398
|
config.resolve.extensions.push(".civet");
|
|
360
399
|
}
|
|
361
400
|
},
|
|
@@ -380,10 +419,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
380
419
|
handleHotUpdate({ file, server, modules }) {
|
|
381
420
|
if (!file.endsWith(".civet"))
|
|
382
421
|
return;
|
|
383
|
-
const
|
|
384
|
-
const module2 = server.moduleGraph.getModuleById(
|
|
422
|
+
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
423
|
+
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
385
424
|
if (module2) {
|
|
386
|
-
server.moduleGraph.onFileChange(
|
|
425
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
387
426
|
return [...modules, module2];
|
|
388
427
|
}
|
|
389
428
|
return modules;
|
|
@@ -391,7 +430,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
};
|
|
394
|
-
var
|
|
433
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
434
|
+
var src_default = unplugin;
|
|
395
435
|
// Annotate the CommonJS export names for ESM import in node:
|
|
396
436
|
0 && (module.exports = {
|
|
397
437
|
rawPlugin,
|
package/dist/vite.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -239,28 +264,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
239
264
|
if (/\0/.test(id))
|
|
240
265
|
return null;
|
|
241
266
|
id = cleanCivetId(id);
|
|
242
|
-
|
|
243
|
-
if (!
|
|
267
|
+
let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
268
|
+
if (!resolvedId)
|
|
244
269
|
return null;
|
|
245
|
-
|
|
246
|
-
if (!relativeId.endsWith(".civet")) {
|
|
270
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
247
271
|
if (!implicitExtension)
|
|
248
272
|
return null;
|
|
249
|
-
const implicitId = implicitCivet(
|
|
273
|
+
const implicitId = implicitCivet(resolvedId);
|
|
250
274
|
if (!implicitId)
|
|
251
275
|
return null;
|
|
252
|
-
|
|
276
|
+
resolvedId = implicitId;
|
|
253
277
|
}
|
|
254
|
-
|
|
255
|
-
return relativePath;
|
|
278
|
+
return resolvedId + outExt;
|
|
256
279
|
},
|
|
257
280
|
loadInclude(id) {
|
|
258
|
-
return isCivetTranspiled(id);
|
|
281
|
+
return isCivetTranspiled.test(id);
|
|
259
282
|
},
|
|
260
283
|
async load(id) {
|
|
261
|
-
|
|
284
|
+
const match = isCivetTranspiled.exec(id);
|
|
285
|
+
if (!match)
|
|
262
286
|
return null;
|
|
263
|
-
const
|
|
287
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
288
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
264
289
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
265
290
|
this.addWatchFile(filename);
|
|
266
291
|
let compiled;
|
|
@@ -351,11 +376,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
351
376
|
},
|
|
352
377
|
vite: {
|
|
353
378
|
config(config) {
|
|
354
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
355
380
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
381
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
382
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
383
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
384
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
385
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
386
|
+
unplugin.esbuild({
|
|
387
|
+
...options,
|
|
388
|
+
js: void 0,
|
|
389
|
+
ts: "preserve",
|
|
390
|
+
dts: void 0,
|
|
391
|
+
emitDeclaration: false,
|
|
392
|
+
typecheck: false
|
|
393
|
+
})
|
|
394
|
+
);
|
|
356
395
|
if (implicitExtension) {
|
|
357
396
|
config.resolve ?? (config.resolve = {});
|
|
358
|
-
(
|
|
397
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
359
398
|
config.resolve.extensions.push(".civet");
|
|
360
399
|
}
|
|
361
400
|
},
|
|
@@ -380,10 +419,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
380
419
|
handleHotUpdate({ file, server, modules }) {
|
|
381
420
|
if (!file.endsWith(".civet"))
|
|
382
421
|
return;
|
|
383
|
-
const
|
|
384
|
-
const module2 = server.moduleGraph.getModuleById(
|
|
422
|
+
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
423
|
+
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
385
424
|
if (module2) {
|
|
386
|
-
server.moduleGraph.onFileChange(
|
|
425
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
387
426
|
return [...modules, module2];
|
|
388
427
|
}
|
|
389
428
|
return modules;
|
|
@@ -391,7 +430,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
};
|
|
394
|
-
var
|
|
433
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
434
|
+
var src_default = unplugin;
|
|
395
435
|
|
|
396
436
|
// src/vite.ts
|
|
397
437
|
var vite_default = src_default.vite;
|
package/dist/webpack.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -239,28 +264,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
239
264
|
if (/\0/.test(id))
|
|
240
265
|
return null;
|
|
241
266
|
id = cleanCivetId(id);
|
|
242
|
-
|
|
243
|
-
if (!
|
|
267
|
+
let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
268
|
+
if (!resolvedId)
|
|
244
269
|
return null;
|
|
245
|
-
|
|
246
|
-
if (!relativeId.endsWith(".civet")) {
|
|
270
|
+
if (!resolvedId.endsWith(".civet")) {
|
|
247
271
|
if (!implicitExtension)
|
|
248
272
|
return null;
|
|
249
|
-
const implicitId = implicitCivet(
|
|
273
|
+
const implicitId = implicitCivet(resolvedId);
|
|
250
274
|
if (!implicitId)
|
|
251
275
|
return null;
|
|
252
|
-
|
|
276
|
+
resolvedId = implicitId;
|
|
253
277
|
}
|
|
254
|
-
|
|
255
|
-
return relativePath;
|
|
278
|
+
return resolvedId + outExt;
|
|
256
279
|
},
|
|
257
280
|
loadInclude(id) {
|
|
258
|
-
return isCivetTranspiled(id);
|
|
281
|
+
return isCivetTranspiled.test(id);
|
|
259
282
|
},
|
|
260
283
|
async load(id) {
|
|
261
|
-
|
|
284
|
+
const match = isCivetTranspiled.exec(id);
|
|
285
|
+
if (!match)
|
|
262
286
|
return null;
|
|
263
|
-
const
|
|
287
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
288
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
264
289
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
265
290
|
this.addWatchFile(filename);
|
|
266
291
|
let compiled;
|
|
@@ -351,11 +376,25 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
351
376
|
},
|
|
352
377
|
vite: {
|
|
353
378
|
config(config) {
|
|
354
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
355
380
|
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
381
|
+
config.optimizeDeps ?? (config.optimizeDeps = {});
|
|
382
|
+
(_a = config.optimizeDeps).esbuildOptions ?? (_a.esbuildOptions = {});
|
|
383
|
+
(_b = config.optimizeDeps.esbuildOptions).plugins ?? (_b.plugins = []);
|
|
384
|
+
config.optimizeDeps.esbuildOptions.plugins.push(
|
|
385
|
+
// @ts-ignore esbuild types from Vite might not match our esbuild
|
|
386
|
+
unplugin.esbuild({
|
|
387
|
+
...options,
|
|
388
|
+
js: void 0,
|
|
389
|
+
ts: "preserve",
|
|
390
|
+
dts: void 0,
|
|
391
|
+
emitDeclaration: false,
|
|
392
|
+
typecheck: false
|
|
393
|
+
})
|
|
394
|
+
);
|
|
356
395
|
if (implicitExtension) {
|
|
357
396
|
config.resolve ?? (config.resolve = {});
|
|
358
|
-
(
|
|
397
|
+
(_c = config.resolve).extensions ?? (_c.extensions = []);
|
|
359
398
|
config.resolve.extensions.push(".civet");
|
|
360
399
|
}
|
|
361
400
|
},
|
|
@@ -380,10 +419,10 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
380
419
|
handleHotUpdate({ file, server, modules }) {
|
|
381
420
|
if (!file.endsWith(".civet"))
|
|
382
421
|
return;
|
|
383
|
-
const
|
|
384
|
-
const module2 = server.moduleGraph.getModuleById(
|
|
422
|
+
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
423
|
+
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
385
424
|
if (module2) {
|
|
386
|
-
server.moduleGraph.onFileChange(
|
|
425
|
+
server.moduleGraph.onFileChange(resolvedId);
|
|
387
426
|
return [...modules, module2];
|
|
388
427
|
}
|
|
389
428
|
return modules;
|
|
@@ -391,7 +430,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
391
430
|
}
|
|
392
431
|
};
|
|
393
432
|
};
|
|
394
|
-
var
|
|
433
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
434
|
+
var src_default = unplugin;
|
|
395
435
|
|
|
396
436
|
// src/webpack.ts
|
|
397
437
|
var webpack_default = src_default.webpack;
|