wxt 0.1.5 → 0.1.6
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/cli.cjs +85 -57
- package/dist/index.cjs +82 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -288,6 +288,32 @@ function virtualEntrypoin(type, config) {
|
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
// src/core/vite-plugins/tsconfigPaths.ts
|
|
292
|
+
import paths from "vite-tsconfig-paths";
|
|
293
|
+
function tsconfigPaths(config) {
|
|
294
|
+
const fn = typeof paths === "function" ? paths : paths.default;
|
|
295
|
+
return fn({
|
|
296
|
+
root: config.root
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/core/vite-plugins/hmrLogger.ts
|
|
301
|
+
import { relative as relative3 } from "path";
|
|
302
|
+
import pc from "picocolors";
|
|
303
|
+
function hmrLogger(config) {
|
|
304
|
+
return {
|
|
305
|
+
name: "wxt:hmr-logger",
|
|
306
|
+
apply: "serve",
|
|
307
|
+
handleHotUpdate(ctx) {
|
|
308
|
+
if (ctx.file.startsWith(config.srcDir) && !ctx.file.startsWith(config.wxtDir) && !ctx.file.endsWith(".html")) {
|
|
309
|
+
config.logger.info(
|
|
310
|
+
"Hot reload: " + pc.dim(relative3(process.cwd(), ctx.file))
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
291
317
|
// src/core/utils/createFsCache.ts
|
|
292
318
|
import fs3, { ensureDir as ensureDir2 } from "fs-extra";
|
|
293
319
|
import { dirname as dirname3, resolve as resolve5 } from "path";
|
|
@@ -440,6 +466,8 @@ async function getInternalConfig(config, command) {
|
|
|
440
466
|
virtualEntrypoin("content-script", finalConfig)
|
|
441
467
|
);
|
|
442
468
|
finalConfig.vite.plugins.push(devServerGlobals(finalConfig));
|
|
469
|
+
finalConfig.vite.plugins.push(tsconfigPaths(finalConfig));
|
|
470
|
+
finalConfig.vite.plugins.push(hmrLogger(finalConfig));
|
|
443
471
|
finalConfig.vite.define ??= {};
|
|
444
472
|
getGlobals(finalConfig).forEach((global) => {
|
|
445
473
|
finalConfig.vite.define[global.name] = JSON.stringify(global.value);
|
|
@@ -451,7 +479,7 @@ async function resolveManifestConfig(env, manifest) {
|
|
|
451
479
|
}
|
|
452
480
|
|
|
453
481
|
// src/index.ts
|
|
454
|
-
import
|
|
482
|
+
import pc4 from "picocolors";
|
|
455
483
|
import * as vite5 from "vite";
|
|
456
484
|
|
|
457
485
|
// src/core/utils/arrays.ts
|
|
@@ -548,7 +576,7 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
548
576
|
// src/index.ts
|
|
549
577
|
import { Mutex } from "async-mutex";
|
|
550
578
|
import { consola as consola2 } from "consola";
|
|
551
|
-
import { relative as
|
|
579
|
+
import { relative as relative7 } from "node:path";
|
|
552
580
|
|
|
553
581
|
// src/core/build/buildEntrypoints.ts
|
|
554
582
|
import * as vite2 from "vite";
|
|
@@ -682,7 +710,7 @@ async function copyPublicDirectory(config) {
|
|
|
682
710
|
}
|
|
683
711
|
|
|
684
712
|
// src/core/build/findEntrypoints.ts
|
|
685
|
-
import { relative as
|
|
713
|
+
import { relative as relative4, resolve as resolve9 } from "path";
|
|
686
714
|
import fs7 from "fs-extra";
|
|
687
715
|
import picomatch from "picomatch";
|
|
688
716
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
@@ -793,8 +821,8 @@ ${JSON.stringify(
|
|
|
793
821
|
if (withSameName) {
|
|
794
822
|
throw Error(
|
|
795
823
|
`Multiple entrypoints with the name "${entrypoint.name}" detected, but only one is allowed: ${[
|
|
796
|
-
|
|
797
|
-
|
|
824
|
+
relative4(config.root, withSameName.inputPath),
|
|
825
|
+
relative4(config.root, entrypoint.inputPath)
|
|
798
826
|
].join(", ")}`
|
|
799
827
|
);
|
|
800
828
|
}
|
|
@@ -921,7 +949,7 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
921
949
|
// src/core/build/generateTypesDir.ts
|
|
922
950
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
923
951
|
import fs8 from "fs-extra";
|
|
924
|
-
import { relative as
|
|
952
|
+
import { relative as relative5, resolve as resolve10 } from "path";
|
|
925
953
|
async function generateTypesDir(entrypoints, config) {
|
|
926
954
|
await fs8.ensureDir(config.typesDir);
|
|
927
955
|
const references = [];
|
|
@@ -988,7 +1016,7 @@ async function writeMainDeclarationFile(references, config) {
|
|
|
988
1016
|
"// Generated by wxt",
|
|
989
1017
|
`/// <reference types="vite/client" />`,
|
|
990
1018
|
...references.map(
|
|
991
|
-
(ref) => `/// <reference types="./${
|
|
1019
|
+
(ref) => `/// <reference types="./${relative5(dir, ref)}" />`
|
|
992
1020
|
)
|
|
993
1021
|
].join("\n") + "\n"
|
|
994
1022
|
);
|
|
@@ -1015,23 +1043,23 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
1015
1043
|
"skipLibCheck": true,
|
|
1016
1044
|
|
|
1017
1045
|
/* Aliases */
|
|
1018
|
-
"baseUrl": "${
|
|
1046
|
+
"baseUrl": "${relative5(dir, config.root)}",
|
|
1019
1047
|
"paths": {
|
|
1020
1048
|
"@@": ["."],
|
|
1021
1049
|
"@@/*": ["./*"],
|
|
1022
1050
|
"~~": ["."],
|
|
1023
1051
|
"~~/*": ["./*"],
|
|
1024
|
-
"@": ["${
|
|
1025
|
-
"@/*": ["${
|
|
1026
|
-
"~": ["${
|
|
1027
|
-
"~/*": ["${
|
|
1052
|
+
"@": ["${relative5(config.root, config.srcDir)}"],
|
|
1053
|
+
"@/*": ["${relative5(config.root, config.srcDir)}/*"],
|
|
1054
|
+
"~": ["${relative5(config.root, config.srcDir)}"],
|
|
1055
|
+
"~/*": ["${relative5(config.root, config.srcDir)}/*"]
|
|
1028
1056
|
}
|
|
1029
1057
|
},
|
|
1030
1058
|
"include": [
|
|
1031
|
-
"${
|
|
1032
|
-
"./${
|
|
1059
|
+
"${relative5(dir, config.root)}/**/*",
|
|
1060
|
+
"./${relative5(dir, mainReference)}"
|
|
1033
1061
|
],
|
|
1034
|
-
"exclude": ["${
|
|
1062
|
+
"exclude": ["${relative5(dir, config.outBaseDir)}"]
|
|
1035
1063
|
}`
|
|
1036
1064
|
);
|
|
1037
1065
|
}
|
|
@@ -1363,7 +1391,7 @@ function addHostPermission(manifest, hostPermission) {
|
|
|
1363
1391
|
}
|
|
1364
1392
|
|
|
1365
1393
|
// src/core/build.ts
|
|
1366
|
-
import
|
|
1394
|
+
import pc3 from "picocolors";
|
|
1367
1395
|
import * as vite3 from "vite";
|
|
1368
1396
|
import fs11 from "fs-extra";
|
|
1369
1397
|
|
|
@@ -1413,7 +1441,7 @@ function formatDuration(duration) {
|
|
|
1413
1441
|
}
|
|
1414
1442
|
|
|
1415
1443
|
// src/core/log/printBuildSummary.ts
|
|
1416
|
-
import path4, { relative as
|
|
1444
|
+
import path4, { relative as relative6, resolve as resolve12 } from "path";
|
|
1417
1445
|
|
|
1418
1446
|
// src/core/log/printTable.ts
|
|
1419
1447
|
function printTable(log, rows, gap = 2) {
|
|
@@ -1442,7 +1470,7 @@ function printTable(log, rows, gap = 2) {
|
|
|
1442
1470
|
}
|
|
1443
1471
|
|
|
1444
1472
|
// src/core/log/printBuildSummary.ts
|
|
1445
|
-
import
|
|
1473
|
+
import pc2 from "picocolors";
|
|
1446
1474
|
import fs10 from "fs-extra";
|
|
1447
1475
|
import { filesize } from "filesize";
|
|
1448
1476
|
async function printBuildSummary(output, config) {
|
|
@@ -1461,7 +1489,7 @@ async function printBuildSummary(output, config) {
|
|
|
1461
1489
|
const chunkRows = await Promise.all(
|
|
1462
1490
|
chunks.map(async (chunk, i) => {
|
|
1463
1491
|
const file = [
|
|
1464
|
-
|
|
1492
|
+
relative6(process.cwd(), config.outDir) + path4.sep,
|
|
1465
1493
|
chunk.fileName
|
|
1466
1494
|
];
|
|
1467
1495
|
const prefix = i === chunks.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
@@ -1470,14 +1498,14 @@ async function printBuildSummary(output, config) {
|
|
|
1470
1498
|
totalSize += stats.size;
|
|
1471
1499
|
const size = String(filesize(stats.size));
|
|
1472
1500
|
return [
|
|
1473
|
-
`${
|
|
1474
|
-
|
|
1501
|
+
`${pc2.gray(prefix)} ${pc2.dim(file[0])}${color(file[1])}`,
|
|
1502
|
+
pc2.dim(size)
|
|
1475
1503
|
];
|
|
1476
1504
|
})
|
|
1477
1505
|
);
|
|
1478
1506
|
printTable(config.logger.log, chunkRows);
|
|
1479
1507
|
config.logger.log(
|
|
1480
|
-
`${
|
|
1508
|
+
`${pc2.cyan("\u03A3 Total size:")} ${String(filesize(totalSize))}`
|
|
1481
1509
|
);
|
|
1482
1510
|
}
|
|
1483
1511
|
var DEFAULT_SORT_WEIGHT = 100;
|
|
@@ -1493,12 +1521,12 @@ function getChunkSortWeight(filename) {
|
|
|
1493
1521
|
([key]) => filename.endsWith(key)
|
|
1494
1522
|
)?.[1] ?? DEFAULT_SORT_WEIGHT;
|
|
1495
1523
|
}
|
|
1496
|
-
var DEFAULT_COLOR =
|
|
1524
|
+
var DEFAULT_COLOR = pc2.blue;
|
|
1497
1525
|
var CHUNK_COLORS = {
|
|
1498
|
-
".js.map":
|
|
1499
|
-
".html":
|
|
1500
|
-
".css":
|
|
1501
|
-
".js":
|
|
1526
|
+
".js.map": pc2.gray,
|
|
1527
|
+
".html": pc2.green,
|
|
1528
|
+
".css": pc2.magenta,
|
|
1529
|
+
".js": pc2.cyan
|
|
1502
1530
|
};
|
|
1503
1531
|
function getChunkColor(filename) {
|
|
1504
1532
|
return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
|
|
@@ -1509,7 +1537,7 @@ async function buildInternal(config) {
|
|
|
1509
1537
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
1510
1538
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
1511
1539
|
config.logger.info(
|
|
1512
|
-
`${verb} ${
|
|
1540
|
+
`${verb} ${pc3.cyan(target)} for ${pc3.cyan(config.mode)} with ${pc3.green(
|
|
1513
1541
|
`Vite ${vite3.version}`
|
|
1514
1542
|
)}`
|
|
1515
1543
|
);
|
|
@@ -1728,7 +1756,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1728
1756
|
}
|
|
1729
1757
|
|
|
1730
1758
|
// package.json
|
|
1731
|
-
var version2 = "0.1.
|
|
1759
|
+
var version2 = "0.1.6";
|
|
1732
1760
|
|
|
1733
1761
|
// src/core/utils/defineConfig.ts
|
|
1734
1762
|
function defineConfig(config) {
|
|
@@ -1771,14 +1799,14 @@ async function createServer2(config) {
|
|
|
1771
1799
|
const changes = detectDevChanges(fileChanges, server.currentOutput);
|
|
1772
1800
|
if (changes.type === "no-change")
|
|
1773
1801
|
return;
|
|
1774
|
-
|
|
1775
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) =>
|
|
1802
|
+
internalConfig.logger.info(
|
|
1803
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc4.dim(relative7(internalConfig.root, file))).join(", ")}`
|
|
1776
1804
|
);
|
|
1777
1805
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
1778
|
-
return
|
|
1779
|
-
|
|
1806
|
+
return pc4.cyan(
|
|
1807
|
+
relative7(internalConfig.outDir, getEntrypointOutputFile(entry, ""))
|
|
1780
1808
|
);
|
|
1781
|
-
}).join(
|
|
1809
|
+
}).join(pc4.dim(", "));
|
|
1782
1810
|
internalConfig = await getLatestInternalConfig();
|
|
1783
1811
|
internalConfig.server = server;
|
|
1784
1812
|
const { output: newOutput } = await rebuild(
|