wxt 0.2.3 → 0.2.4
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 +159 -59
- package/dist/index.cjs +90 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +91 -59
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -470,7 +470,27 @@ async function getInternalConfig(config, command) {
|
|
|
470
470
|
wxtDir,
|
|
471
471
|
typesDir,
|
|
472
472
|
fsCache: createFsCache(wxtDir),
|
|
473
|
-
manifest
|
|
473
|
+
manifest,
|
|
474
|
+
zip: {
|
|
475
|
+
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
476
|
+
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
477
|
+
sourcesRoot: root,
|
|
478
|
+
...userConfig.zip,
|
|
479
|
+
...config.zip,
|
|
480
|
+
ignoredSources: [
|
|
481
|
+
"**/node_modules",
|
|
482
|
+
// WXT files
|
|
483
|
+
"**/web-ext.config.ts",
|
|
484
|
+
// Hidden files
|
|
485
|
+
"**/.*",
|
|
486
|
+
// Tests
|
|
487
|
+
"**/__tests__/**",
|
|
488
|
+
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
489
|
+
// User config
|
|
490
|
+
...userConfig.zip?.ignoredSources ?? [],
|
|
491
|
+
...config.zip?.ignoredSources ?? []
|
|
492
|
+
]
|
|
493
|
+
}
|
|
474
494
|
};
|
|
475
495
|
finalConfig.vite.root = root;
|
|
476
496
|
finalConfig.vite.configFile = false;
|
|
@@ -598,7 +618,7 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
598
618
|
// src/index.ts
|
|
599
619
|
var import_async_mutex = require("async-mutex");
|
|
600
620
|
var import_consola2 = require("consola");
|
|
601
|
-
var
|
|
621
|
+
var import_node_path6 = require("path");
|
|
602
622
|
|
|
603
623
|
// src/core/build/buildEntrypoints.ts
|
|
604
624
|
var vite2 = __toESM(require("vite"), 1);
|
|
@@ -1089,7 +1109,7 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
1089
1109
|
}
|
|
1090
1110
|
|
|
1091
1111
|
// src/core/utils/manifest.ts
|
|
1092
|
-
var
|
|
1112
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
1093
1113
|
var import_path10 = require("path");
|
|
1094
1114
|
|
|
1095
1115
|
// src/core/utils/ContentSecurityPolicy.ts
|
|
@@ -1173,11 +1193,26 @@ function mapWxtOptionsToContentScript(options) {
|
|
|
1173
1193
|
};
|
|
1174
1194
|
}
|
|
1175
1195
|
|
|
1196
|
+
// src/core/utils/package.ts
|
|
1197
|
+
var import_node_path4 = require("path");
|
|
1198
|
+
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
1199
|
+
async function getPackageJson(config) {
|
|
1200
|
+
const file = (0, import_node_path4.resolve)(config.root, "package.json");
|
|
1201
|
+
try {
|
|
1202
|
+
return await import_fs_extra9.default.readJson(file);
|
|
1203
|
+
} catch (err) {
|
|
1204
|
+
config.logger.debug(
|
|
1205
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
1206
|
+
);
|
|
1207
|
+
return {};
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1176
1211
|
// src/core/utils/manifest.ts
|
|
1177
1212
|
async function writeManifest(manifest, output, config) {
|
|
1178
1213
|
const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
1179
|
-
await
|
|
1180
|
-
await
|
|
1214
|
+
await import_fs_extra10.default.ensureDir(config.outDir);
|
|
1215
|
+
await import_fs_extra10.default.writeFile((0, import_path10.resolve)(config.outDir, "manifest.json"), str, "utf-8");
|
|
1181
1216
|
output.publicAssets.unshift({
|
|
1182
1217
|
type: "asset",
|
|
1183
1218
|
fileName: "manifest.json",
|
|
@@ -1216,17 +1251,6 @@ async function generateMainfest(entrypoints, buildOutput, config) {
|
|
|
1216
1251
|
}
|
|
1217
1252
|
return manifest;
|
|
1218
1253
|
}
|
|
1219
|
-
async function getPackageJson(config) {
|
|
1220
|
-
const file = (0, import_path10.resolve)(config.root, "package.json");
|
|
1221
|
-
try {
|
|
1222
|
-
return await import_fs_extra9.default.readJson(file);
|
|
1223
|
-
} catch (err) {
|
|
1224
|
-
config.logger.debug(
|
|
1225
|
-
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
1226
|
-
);
|
|
1227
|
-
return {};
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
1254
|
function simplifyVersion(versionName) {
|
|
1231
1255
|
const version3 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
|
|
1232
1256
|
versionName
|
|
@@ -1470,7 +1494,7 @@ function addHostPermission(manifest, hostPermission) {
|
|
|
1470
1494
|
// src/core/build.ts
|
|
1471
1495
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
1472
1496
|
var vite3 = __toESM(require("vite"), 1);
|
|
1473
|
-
var
|
|
1497
|
+
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
1474
1498
|
|
|
1475
1499
|
// src/core/utils/groupEntrypoints.ts
|
|
1476
1500
|
function groupEntrypoints(entrypoints) {
|
|
@@ -1518,7 +1542,13 @@ function formatDuration(duration) {
|
|
|
1518
1542
|
}
|
|
1519
1543
|
|
|
1520
1544
|
// src/core/log/printBuildSummary.ts
|
|
1521
|
-
var import_path11 =
|
|
1545
|
+
var import_path11 = require("path");
|
|
1546
|
+
|
|
1547
|
+
// src/core/log/printFileList.ts
|
|
1548
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
1549
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
1550
|
+
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
1551
|
+
var import_filesize = require("filesize");
|
|
1522
1552
|
|
|
1523
1553
|
// src/core/log/printTable.ts
|
|
1524
1554
|
function printTable(log, rows, gap = 2) {
|
|
@@ -1546,10 +1576,42 @@ function printTable(log, rows, gap = 2) {
|
|
|
1546
1576
|
log(str);
|
|
1547
1577
|
}
|
|
1548
1578
|
|
|
1579
|
+
// src/core/log/printFileList.ts
|
|
1580
|
+
async function printFileList(log, baseDir, files) {
|
|
1581
|
+
let totalSize = 0;
|
|
1582
|
+
const fileRows = await Promise.all(
|
|
1583
|
+
files.map(async (file, i) => {
|
|
1584
|
+
const parts = [
|
|
1585
|
+
import_node_path5.default.relative(process.cwd(), baseDir) + import_node_path5.default.sep,
|
|
1586
|
+
import_node_path5.default.relative(baseDir, file)
|
|
1587
|
+
];
|
|
1588
|
+
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
1589
|
+
const color = getChunkColor(file);
|
|
1590
|
+
const stats = await import_fs_extra11.default.lstat(file);
|
|
1591
|
+
totalSize += stats.size;
|
|
1592
|
+
const size = String((0, import_filesize.filesize)(stats.size));
|
|
1593
|
+
return [
|
|
1594
|
+
`${import_picocolors.default.gray(prefix)} ${import_picocolors.default.dim(parts[0])}${color(parts[1])}`,
|
|
1595
|
+
import_picocolors.default.dim(size)
|
|
1596
|
+
];
|
|
1597
|
+
})
|
|
1598
|
+
);
|
|
1599
|
+
printTable(log, fileRows);
|
|
1600
|
+
log(`${import_picocolors.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`);
|
|
1601
|
+
}
|
|
1602
|
+
var DEFAULT_COLOR = import_picocolors.default.blue;
|
|
1603
|
+
var CHUNK_COLORS = {
|
|
1604
|
+
".js.map": import_picocolors.default.gray,
|
|
1605
|
+
".html": import_picocolors.default.green,
|
|
1606
|
+
".css": import_picocolors.default.magenta,
|
|
1607
|
+
".js": import_picocolors.default.cyan,
|
|
1608
|
+
".zip": import_picocolors.default.yellow
|
|
1609
|
+
};
|
|
1610
|
+
function getChunkColor(filename) {
|
|
1611
|
+
return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1549
1614
|
// src/core/log/printBuildSummary.ts
|
|
1550
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
1551
|
-
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
1552
|
-
var import_filesize = require("filesize");
|
|
1553
1615
|
async function printBuildSummary(output, config) {
|
|
1554
1616
|
const chunks = [
|
|
1555
1617
|
...output.steps.flatMap((step) => step.chunks),
|
|
@@ -1562,28 +1624,8 @@ async function printBuildSummary(output, config) {
|
|
|
1562
1624
|
return diff;
|
|
1563
1625
|
return l.fileName.localeCompare(r.fileName);
|
|
1564
1626
|
});
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
chunks.map(async (chunk, i) => {
|
|
1568
|
-
const file = [
|
|
1569
|
-
(0, import_path11.relative)(process.cwd(), config.outDir) + import_path11.default.sep,
|
|
1570
|
-
chunk.fileName
|
|
1571
|
-
];
|
|
1572
|
-
const prefix = i === chunks.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
1573
|
-
const color = getChunkColor(chunk.fileName);
|
|
1574
|
-
const stats = await import_fs_extra10.default.lstat((0, import_path11.resolve)(config.outDir, chunk.fileName));
|
|
1575
|
-
totalSize += stats.size;
|
|
1576
|
-
const size = String((0, import_filesize.filesize)(stats.size));
|
|
1577
|
-
return [
|
|
1578
|
-
`${import_picocolors.default.gray(prefix)} ${import_picocolors.default.dim(file[0])}${color(file[1])}`,
|
|
1579
|
-
import_picocolors.default.dim(size)
|
|
1580
|
-
];
|
|
1581
|
-
})
|
|
1582
|
-
);
|
|
1583
|
-
printTable(config.logger.log, chunkRows);
|
|
1584
|
-
config.logger.log(
|
|
1585
|
-
`${import_picocolors.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`
|
|
1586
|
-
);
|
|
1627
|
+
const files = chunks.map((chunk) => (0, import_path11.resolve)(config.outDir, chunk.fileName));
|
|
1628
|
+
await printFileList(config.logger.log, config.outDir, files);
|
|
1587
1629
|
}
|
|
1588
1630
|
var DEFAULT_SORT_WEIGHT = 100;
|
|
1589
1631
|
var CHUNK_SORT_WEIGHTS = {
|
|
@@ -1598,16 +1640,6 @@ function getChunkSortWeight(filename) {
|
|
|
1598
1640
|
([key]) => filename.endsWith(key)
|
|
1599
1641
|
)?.[1] ?? DEFAULT_SORT_WEIGHT;
|
|
1600
1642
|
}
|
|
1601
|
-
var DEFAULT_COLOR = import_picocolors.default.blue;
|
|
1602
|
-
var CHUNK_COLORS = {
|
|
1603
|
-
".js.map": import_picocolors.default.gray,
|
|
1604
|
-
".html": import_picocolors.default.green,
|
|
1605
|
-
".css": import_picocolors.default.magenta,
|
|
1606
|
-
".js": import_picocolors.default.cyan
|
|
1607
|
-
};
|
|
1608
|
-
function getChunkColor(filename) {
|
|
1609
|
-
return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
|
|
1610
|
-
}
|
|
1611
1643
|
|
|
1612
1644
|
// src/core/build.ts
|
|
1613
1645
|
async function buildInternal(config) {
|
|
@@ -1619,8 +1651,8 @@ async function buildInternal(config) {
|
|
|
1619
1651
|
)}`
|
|
1620
1652
|
);
|
|
1621
1653
|
const startTime = Date.now();
|
|
1622
|
-
await
|
|
1623
|
-
await
|
|
1654
|
+
await import_fs_extra12.default.rm(config.outDir, { recursive: true, force: true });
|
|
1655
|
+
await import_fs_extra12.default.ensureDir(config.outDir);
|
|
1624
1656
|
const entrypoints = await findEntrypoints(config);
|
|
1625
1657
|
const groups = groupEntrypoints(entrypoints);
|
|
1626
1658
|
const { output } = await rebuild(config, groups);
|
|
@@ -1811,7 +1843,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1811
1843
|
}
|
|
1812
1844
|
|
|
1813
1845
|
// package.json
|
|
1814
|
-
var version2 = "0.2.
|
|
1846
|
+
var version2 = "0.2.4";
|
|
1815
1847
|
|
|
1816
1848
|
// src/core/utils/defineConfig.ts
|
|
1817
1849
|
function defineConfig(config) {
|
|
@@ -1855,11 +1887,11 @@ async function createServer2(config) {
|
|
|
1855
1887
|
if (changes.type === "no-change")
|
|
1856
1888
|
return;
|
|
1857
1889
|
internalConfig.logger.info(
|
|
1858
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors3.default.dim((0,
|
|
1890
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors3.default.dim((0, import_node_path6.relative)(internalConfig.root, file))).join(", ")}`
|
|
1859
1891
|
);
|
|
1860
1892
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
1861
1893
|
return import_picocolors3.default.cyan(
|
|
1862
|
-
(0,
|
|
1894
|
+
(0, import_node_path6.relative)(internalConfig.outDir, getEntrypointOutputFile(entry, ""))
|
|
1863
1895
|
);
|
|
1864
1896
|
}).join(import_picocolors3.default.dim(", "));
|
|
1865
1897
|
internalConfig = await getLatestInternalConfig();
|