wxt 0.15.3 → 0.16.0
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/{chunk-6OOILYIE.js → chunk-NTBDEVHE.js} +42 -32
- package/dist/cli.js +61 -39
- package/dist/index.cjs +61 -39
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -10
- package/dist/testing.cjs +19 -14
- package/dist/testing.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.16.0";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -1092,17 +1092,7 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1092
1092
|
return config;
|
|
1093
1093
|
};
|
|
1094
1094
|
const getLibModeConfig = (entrypoint) => {
|
|
1095
|
-
|
|
1096
|
-
switch (entrypoint.type) {
|
|
1097
|
-
case "background":
|
|
1098
|
-
case "unlisted-script":
|
|
1099
|
-
virtualEntrypointType = entrypoint.type;
|
|
1100
|
-
break;
|
|
1101
|
-
case "content-script":
|
|
1102
|
-
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
1103
|
-
break;
|
|
1104
|
-
}
|
|
1105
|
-
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
1095
|
+
const entry = getRollupEntry(entrypoint);
|
|
1106
1096
|
const plugins = [
|
|
1107
1097
|
entrypointGroupGlobals(entrypoint)
|
|
1108
1098
|
];
|
|
@@ -1157,14 +1147,16 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1157
1147
|
build: {
|
|
1158
1148
|
rollupOptions: {
|
|
1159
1149
|
input: entrypoints.reduce((input, entry) => {
|
|
1160
|
-
input[entry.name] = entry
|
|
1150
|
+
input[entry.name] = getRollupEntry(entry);
|
|
1161
1151
|
return input;
|
|
1162
1152
|
}, {}),
|
|
1163
1153
|
output: {
|
|
1164
1154
|
// Include a hash to prevent conflicts
|
|
1165
1155
|
chunkFileNames: "chunks/[name]-[hash].js",
|
|
1166
|
-
//
|
|
1167
|
-
|
|
1156
|
+
// Place JS entrypoints in main directory without a hash. (popup.html & popup.js are
|
|
1157
|
+
// next to each other). The unique entrypoint name requirement prevents conflicts with
|
|
1158
|
+
// scripts of the same name
|
|
1159
|
+
entryFileNames: "[name].js",
|
|
1168
1160
|
// We can't control the "name", so we need a hash to prevent conflicts
|
|
1169
1161
|
assetFileNames: "assets/[name]-[hash].[ext]"
|
|
1170
1162
|
}
|
|
@@ -1256,6 +1248,19 @@ function getBuildOutputChunks(result) {
|
|
|
1256
1248
|
return result.flatMap(({ output }) => output);
|
|
1257
1249
|
return result.output;
|
|
1258
1250
|
}
|
|
1251
|
+
function getRollupEntry(entrypoint) {
|
|
1252
|
+
let virtualEntrypointType;
|
|
1253
|
+
switch (entrypoint.type) {
|
|
1254
|
+
case "background":
|
|
1255
|
+
case "unlisted-script":
|
|
1256
|
+
virtualEntrypointType = entrypoint.type;
|
|
1257
|
+
break;
|
|
1258
|
+
case "content-script":
|
|
1259
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
1263
|
+
}
|
|
1259
1264
|
|
|
1260
1265
|
// src/core/utils/building/get-internal-config.ts
|
|
1261
1266
|
import defu2 from "defu";
|
|
@@ -1455,8 +1460,11 @@ function groupEntrypoints(entrypoints) {
|
|
|
1455
1460
|
const groupIndexMap = {};
|
|
1456
1461
|
const groups = [];
|
|
1457
1462
|
for (const entry of entrypoints) {
|
|
1458
|
-
|
|
1459
|
-
if (
|
|
1463
|
+
let group = ENTRY_TYPE_TO_GROUP_MAP[entry.type];
|
|
1464
|
+
if (entry.type === "background" && entry.options.type === "module") {
|
|
1465
|
+
group = "esm";
|
|
1466
|
+
}
|
|
1467
|
+
if (group === "individual") {
|
|
1460
1468
|
groups.push(entry);
|
|
1461
1469
|
} else {
|
|
1462
1470
|
let groupIndex = groupIndexMap[group];
|
|
@@ -1470,20 +1478,20 @@ function groupEntrypoints(entrypoints) {
|
|
|
1470
1478
|
return groups;
|
|
1471
1479
|
}
|
|
1472
1480
|
var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
1473
|
-
sandbox: "
|
|
1474
|
-
popup: "
|
|
1475
|
-
newtab: "
|
|
1476
|
-
history: "
|
|
1477
|
-
options: "
|
|
1478
|
-
devtools: "
|
|
1479
|
-
bookmarks: "
|
|
1480
|
-
sidepanel: "
|
|
1481
|
-
"unlisted-page": "
|
|
1482
|
-
background: "
|
|
1483
|
-
"content-script": "
|
|
1484
|
-
"unlisted-script": "
|
|
1485
|
-
"unlisted-style": "
|
|
1486
|
-
"content-script-style": "
|
|
1481
|
+
sandbox: "sandboxed-esm",
|
|
1482
|
+
popup: "esm",
|
|
1483
|
+
newtab: "esm",
|
|
1484
|
+
history: "esm",
|
|
1485
|
+
options: "esm",
|
|
1486
|
+
devtools: "esm",
|
|
1487
|
+
bookmarks: "esm",
|
|
1488
|
+
sidepanel: "esm",
|
|
1489
|
+
"unlisted-page": "esm",
|
|
1490
|
+
background: "individual",
|
|
1491
|
+
"content-script": "individual",
|
|
1492
|
+
"unlisted-script": "individual",
|
|
1493
|
+
"unlisted-style": "individual",
|
|
1494
|
+
"content-script-style": "individual"
|
|
1487
1495
|
};
|
|
1488
1496
|
|
|
1489
1497
|
// src/core/utils/building/import-entrypoint.ts
|
|
@@ -2703,6 +2711,9 @@ async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
|
|
|
2703
2711
|
const { main: _, ...moduleOptions } = defaultExport;
|
|
2704
2712
|
options = moduleOptions;
|
|
2705
2713
|
}
|
|
2714
|
+
if (config.manifestVersion !== 3) {
|
|
2715
|
+
delete options.type;
|
|
2716
|
+
}
|
|
2706
2717
|
return {
|
|
2707
2718
|
type: "background",
|
|
2708
2719
|
name,
|
|
@@ -2775,7 +2786,6 @@ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
|
|
|
2775
2786
|
|
|
2776
2787
|
export {
|
|
2777
2788
|
detectDevChanges,
|
|
2778
|
-
getEntrypointOutputFile,
|
|
2779
2789
|
getEntrypointBundlePath,
|
|
2780
2790
|
resolvePerBrowserOption,
|
|
2781
2791
|
findEntrypoints,
|
package/dist/cli.js
CHANGED
|
@@ -475,6 +475,9 @@ async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
|
|
|
475
475
|
const { main: _, ...moduleOptions } = defaultExport;
|
|
476
476
|
options = moduleOptions;
|
|
477
477
|
}
|
|
478
|
+
if (config.manifestVersion !== 3) {
|
|
479
|
+
delete options.type;
|
|
480
|
+
}
|
|
478
481
|
return {
|
|
479
482
|
type: "background",
|
|
480
483
|
name,
|
|
@@ -1406,17 +1409,7 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1406
1409
|
return config;
|
|
1407
1410
|
};
|
|
1408
1411
|
const getLibModeConfig = (entrypoint) => {
|
|
1409
|
-
|
|
1410
|
-
switch (entrypoint.type) {
|
|
1411
|
-
case "background":
|
|
1412
|
-
case "unlisted-script":
|
|
1413
|
-
virtualEntrypointType = entrypoint.type;
|
|
1414
|
-
break;
|
|
1415
|
-
case "content-script":
|
|
1416
|
-
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
1417
|
-
break;
|
|
1418
|
-
}
|
|
1419
|
-
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
1412
|
+
const entry = getRollupEntry(entrypoint);
|
|
1420
1413
|
const plugins = [
|
|
1421
1414
|
entrypointGroupGlobals(entrypoint)
|
|
1422
1415
|
];
|
|
@@ -1471,14 +1464,16 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1471
1464
|
build: {
|
|
1472
1465
|
rollupOptions: {
|
|
1473
1466
|
input: entrypoints.reduce((input, entry) => {
|
|
1474
|
-
input[entry.name] = entry
|
|
1467
|
+
input[entry.name] = getRollupEntry(entry);
|
|
1475
1468
|
return input;
|
|
1476
1469
|
}, {}),
|
|
1477
1470
|
output: {
|
|
1478
1471
|
// Include a hash to prevent conflicts
|
|
1479
1472
|
chunkFileNames: "chunks/[name]-[hash].js",
|
|
1480
|
-
//
|
|
1481
|
-
|
|
1473
|
+
// Place JS entrypoints in main directory without a hash. (popup.html & popup.js are
|
|
1474
|
+
// next to each other). The unique entrypoint name requirement prevents conflicts with
|
|
1475
|
+
// scripts of the same name
|
|
1476
|
+
entryFileNames: "[name].js",
|
|
1482
1477
|
// We can't control the "name", so we need a hash to prevent conflicts
|
|
1483
1478
|
assetFileNames: "assets/[name]-[hash].[ext]"
|
|
1484
1479
|
}
|
|
@@ -1570,6 +1565,19 @@ function getBuildOutputChunks(result) {
|
|
|
1570
1565
|
return result.flatMap(({ output }) => output);
|
|
1571
1566
|
return result.output;
|
|
1572
1567
|
}
|
|
1568
|
+
function getRollupEntry(entrypoint) {
|
|
1569
|
+
let virtualEntrypointType;
|
|
1570
|
+
switch (entrypoint.type) {
|
|
1571
|
+
case "background":
|
|
1572
|
+
case "unlisted-script":
|
|
1573
|
+
virtualEntrypointType = entrypoint.type;
|
|
1574
|
+
break;
|
|
1575
|
+
case "content-script":
|
|
1576
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
1577
|
+
break;
|
|
1578
|
+
}
|
|
1579
|
+
return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
1580
|
+
}
|
|
1573
1581
|
|
|
1574
1582
|
// src/core/utils/building/get-internal-config.ts
|
|
1575
1583
|
import defu2 from "defu";
|
|
@@ -1769,8 +1777,11 @@ function groupEntrypoints(entrypoints) {
|
|
|
1769
1777
|
const groupIndexMap = {};
|
|
1770
1778
|
const groups = [];
|
|
1771
1779
|
for (const entry of entrypoints) {
|
|
1772
|
-
|
|
1773
|
-
if (
|
|
1780
|
+
let group = ENTRY_TYPE_TO_GROUP_MAP[entry.type];
|
|
1781
|
+
if (entry.type === "background" && entry.options.type === "module") {
|
|
1782
|
+
group = "esm";
|
|
1783
|
+
}
|
|
1784
|
+
if (group === "individual") {
|
|
1774
1785
|
groups.push(entry);
|
|
1775
1786
|
} else {
|
|
1776
1787
|
let groupIndex = groupIndexMap[group];
|
|
@@ -1784,20 +1795,20 @@ function groupEntrypoints(entrypoints) {
|
|
|
1784
1795
|
return groups;
|
|
1785
1796
|
}
|
|
1786
1797
|
var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
1787
|
-
sandbox: "
|
|
1788
|
-
popup: "
|
|
1789
|
-
newtab: "
|
|
1790
|
-
history: "
|
|
1791
|
-
options: "
|
|
1792
|
-
devtools: "
|
|
1793
|
-
bookmarks: "
|
|
1794
|
-
sidepanel: "
|
|
1795
|
-
"unlisted-page": "
|
|
1796
|
-
background: "
|
|
1797
|
-
"content-script": "
|
|
1798
|
-
"unlisted-script": "
|
|
1799
|
-
"unlisted-style": "
|
|
1800
|
-
"content-script-style": "
|
|
1798
|
+
sandbox: "sandboxed-esm",
|
|
1799
|
+
popup: "esm",
|
|
1800
|
+
newtab: "esm",
|
|
1801
|
+
history: "esm",
|
|
1802
|
+
options: "esm",
|
|
1803
|
+
devtools: "esm",
|
|
1804
|
+
bookmarks: "esm",
|
|
1805
|
+
sidepanel: "esm",
|
|
1806
|
+
"unlisted-page": "esm",
|
|
1807
|
+
background: "individual",
|
|
1808
|
+
"content-script": "individual",
|
|
1809
|
+
"unlisted-script": "individual",
|
|
1810
|
+
"unlisted-style": "individual",
|
|
1811
|
+
"content-script-style": "individual"
|
|
1801
1812
|
};
|
|
1802
1813
|
|
|
1803
1814
|
// src/core/utils/building/import-entrypoint.ts
|
|
@@ -2016,7 +2027,7 @@ function getChunkSortWeight(filename) {
|
|
|
2016
2027
|
import pc4 from "picocolors";
|
|
2017
2028
|
|
|
2018
2029
|
// package.json
|
|
2019
|
-
var version = "0.
|
|
2030
|
+
var version = "0.16.0";
|
|
2020
2031
|
|
|
2021
2032
|
// src/core/utils/log/printHeader.ts
|
|
2022
2033
|
import { consola as consola2 } from "consola";
|
|
@@ -3070,11 +3081,6 @@ function createFileReloader(options) {
|
|
|
3070
3081
|
config.logger.info(
|
|
3071
3082
|
`Changed: ${Array.from(new Set(fileChanges)).map((file) => pc7.dim(relative10(config.root, file))).join(", ")}`
|
|
3072
3083
|
);
|
|
3073
|
-
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
3074
|
-
return pc7.cyan(
|
|
3075
|
-
relative10(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
3076
|
-
);
|
|
3077
|
-
}).join(pc7.dim(", "));
|
|
3078
3084
|
const allEntrypoints = await findEntrypoints(config);
|
|
3079
3085
|
const { output: newOutput } = await rebuild(
|
|
3080
3086
|
config,
|
|
@@ -3087,15 +3093,22 @@ function createFileReloader(options) {
|
|
|
3087
3093
|
switch (changes.type) {
|
|
3088
3094
|
case "extension-reload":
|
|
3089
3095
|
server.reloadExtension();
|
|
3096
|
+
consola5.success(`Reloaded extension`);
|
|
3090
3097
|
break;
|
|
3091
3098
|
case "html-reload":
|
|
3092
|
-
reloadHtmlPages(
|
|
3099
|
+
const { reloadedNames } = reloadHtmlPages(
|
|
3100
|
+
changes.rebuildGroups,
|
|
3101
|
+
server,
|
|
3102
|
+
config
|
|
3103
|
+
);
|
|
3104
|
+
consola5.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
3093
3105
|
break;
|
|
3094
3106
|
case "content-script-reload":
|
|
3095
3107
|
reloadContentScripts(changes.changedSteps, config, server);
|
|
3108
|
+
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
3109
|
+
consola5.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
3096
3110
|
break;
|
|
3097
3111
|
}
|
|
3098
|
-
consola5.success(`Reloaded: ${rebuiltNames}`);
|
|
3099
3112
|
});
|
|
3100
3113
|
};
|
|
3101
3114
|
}
|
|
@@ -3132,10 +3145,19 @@ function reloadContentScripts(steps, config, server) {
|
|
|
3132
3145
|
}
|
|
3133
3146
|
}
|
|
3134
3147
|
function reloadHtmlPages(groups, server, config) {
|
|
3135
|
-
groups.flat().
|
|
3148
|
+
const htmlEntries = groups.flat().filter((entry) => entry.inputPath.endsWith(".html"));
|
|
3149
|
+
htmlEntries.forEach((entry) => {
|
|
3136
3150
|
const path7 = getEntrypointBundlePath(entry, config.outDir, ".html");
|
|
3137
3151
|
server.reloadPage(path7);
|
|
3138
3152
|
});
|
|
3153
|
+
return {
|
|
3154
|
+
reloadedNames: htmlEntries.map((entry) => entry.name)
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
function getFilenameList(names) {
|
|
3158
|
+
return names.map((name) => {
|
|
3159
|
+
return pc7.cyan(name);
|
|
3160
|
+
}).join(pc7.dim(", "));
|
|
3139
3161
|
}
|
|
3140
3162
|
|
|
3141
3163
|
// src/core/initialize.ts
|
package/dist/index.cjs
CHANGED
|
@@ -2898,6 +2898,9 @@ async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
|
|
|
2898
2898
|
const { main: _, ...moduleOptions } = defaultExport;
|
|
2899
2899
|
options = moduleOptions;
|
|
2900
2900
|
}
|
|
2901
|
+
if (config.manifestVersion !== 3) {
|
|
2902
|
+
delete options.type;
|
|
2903
|
+
}
|
|
2901
2904
|
return {
|
|
2902
2905
|
type: "background",
|
|
2903
2906
|
name,
|
|
@@ -3832,17 +3835,7 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3832
3835
|
return config;
|
|
3833
3836
|
};
|
|
3834
3837
|
const getLibModeConfig = (entrypoint) => {
|
|
3835
|
-
|
|
3836
|
-
switch (entrypoint.type) {
|
|
3837
|
-
case "background":
|
|
3838
|
-
case "unlisted-script":
|
|
3839
|
-
virtualEntrypointType = entrypoint.type;
|
|
3840
|
-
break;
|
|
3841
|
-
case "content-script":
|
|
3842
|
-
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
3843
|
-
break;
|
|
3844
|
-
}
|
|
3845
|
-
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
3838
|
+
const entry = getRollupEntry(entrypoint);
|
|
3846
3839
|
const plugins = [
|
|
3847
3840
|
entrypointGroupGlobals(entrypoint)
|
|
3848
3841
|
];
|
|
@@ -3897,14 +3890,16 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3897
3890
|
build: {
|
|
3898
3891
|
rollupOptions: {
|
|
3899
3892
|
input: entrypoints.reduce((input, entry) => {
|
|
3900
|
-
input[entry.name] = entry
|
|
3893
|
+
input[entry.name] = getRollupEntry(entry);
|
|
3901
3894
|
return input;
|
|
3902
3895
|
}, {}),
|
|
3903
3896
|
output: {
|
|
3904
3897
|
// Include a hash to prevent conflicts
|
|
3905
3898
|
chunkFileNames: "chunks/[name]-[hash].js",
|
|
3906
|
-
//
|
|
3907
|
-
|
|
3899
|
+
// Place JS entrypoints in main directory without a hash. (popup.html & popup.js are
|
|
3900
|
+
// next to each other). The unique entrypoint name requirement prevents conflicts with
|
|
3901
|
+
// scripts of the same name
|
|
3902
|
+
entryFileNames: "[name].js",
|
|
3908
3903
|
// We can't control the "name", so we need a hash to prevent conflicts
|
|
3909
3904
|
assetFileNames: "assets/[name]-[hash].[ext]"
|
|
3910
3905
|
}
|
|
@@ -3996,6 +3991,19 @@ function getBuildOutputChunks(result) {
|
|
|
3996
3991
|
return result.flatMap(({ output }) => output);
|
|
3997
3992
|
return result.output;
|
|
3998
3993
|
}
|
|
3994
|
+
function getRollupEntry(entrypoint) {
|
|
3995
|
+
let virtualEntrypointType;
|
|
3996
|
+
switch (entrypoint.type) {
|
|
3997
|
+
case "background":
|
|
3998
|
+
case "unlisted-script":
|
|
3999
|
+
virtualEntrypointType = entrypoint.type;
|
|
4000
|
+
break;
|
|
4001
|
+
case "content-script":
|
|
4002
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
4003
|
+
break;
|
|
4004
|
+
}
|
|
4005
|
+
return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
4006
|
+
}
|
|
3999
4007
|
|
|
4000
4008
|
// src/core/utils/building/get-internal-config.ts
|
|
4001
4009
|
var import_defu2 = __toESM(require("defu"), 1);
|
|
@@ -4195,8 +4203,11 @@ function groupEntrypoints(entrypoints) {
|
|
|
4195
4203
|
const groupIndexMap = {};
|
|
4196
4204
|
const groups = [];
|
|
4197
4205
|
for (const entry of entrypoints) {
|
|
4198
|
-
|
|
4199
|
-
if (
|
|
4206
|
+
let group = ENTRY_TYPE_TO_GROUP_MAP[entry.type];
|
|
4207
|
+
if (entry.type === "background" && entry.options.type === "module") {
|
|
4208
|
+
group = "esm";
|
|
4209
|
+
}
|
|
4210
|
+
if (group === "individual") {
|
|
4200
4211
|
groups.push(entry);
|
|
4201
4212
|
} else {
|
|
4202
4213
|
let groupIndex = groupIndexMap[group];
|
|
@@ -4210,20 +4221,20 @@ function groupEntrypoints(entrypoints) {
|
|
|
4210
4221
|
return groups;
|
|
4211
4222
|
}
|
|
4212
4223
|
var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
4213
|
-
sandbox: "
|
|
4214
|
-
popup: "
|
|
4215
|
-
newtab: "
|
|
4216
|
-
history: "
|
|
4217
|
-
options: "
|
|
4218
|
-
devtools: "
|
|
4219
|
-
bookmarks: "
|
|
4220
|
-
sidepanel: "
|
|
4221
|
-
"unlisted-page": "
|
|
4222
|
-
background: "
|
|
4223
|
-
"content-script": "
|
|
4224
|
-
"unlisted-script": "
|
|
4225
|
-
"unlisted-style": "
|
|
4226
|
-
"content-script-style": "
|
|
4224
|
+
sandbox: "sandboxed-esm",
|
|
4225
|
+
popup: "esm",
|
|
4226
|
+
newtab: "esm",
|
|
4227
|
+
history: "esm",
|
|
4228
|
+
options: "esm",
|
|
4229
|
+
devtools: "esm",
|
|
4230
|
+
bookmarks: "esm",
|
|
4231
|
+
sidepanel: "esm",
|
|
4232
|
+
"unlisted-page": "esm",
|
|
4233
|
+
background: "individual",
|
|
4234
|
+
"content-script": "individual",
|
|
4235
|
+
"unlisted-script": "individual",
|
|
4236
|
+
"unlisted-style": "individual",
|
|
4237
|
+
"content-script-style": "individual"
|
|
4227
4238
|
};
|
|
4228
4239
|
|
|
4229
4240
|
// src/core/utils/building/import-entrypoint.ts
|
|
@@ -4443,7 +4454,7 @@ function getChunkSortWeight(filename) {
|
|
|
4443
4454
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4444
4455
|
|
|
4445
4456
|
// package.json
|
|
4446
|
-
var version = "0.
|
|
4457
|
+
var version = "0.16.0";
|
|
4447
4458
|
|
|
4448
4459
|
// src/core/utils/log/printHeader.ts
|
|
4449
4460
|
var import_consola2 = require("consola");
|
|
@@ -5503,11 +5514,6 @@ function createFileReloader(options) {
|
|
|
5503
5514
|
config.logger.info(
|
|
5504
5515
|
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path19.relative)(config.root, file))).join(", ")}`
|
|
5505
5516
|
);
|
|
5506
|
-
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
5507
|
-
return import_picocolors7.default.cyan(
|
|
5508
|
-
(0, import_node_path19.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
5509
|
-
);
|
|
5510
|
-
}).join(import_picocolors7.default.dim(", "));
|
|
5511
5517
|
const allEntrypoints = await findEntrypoints(config);
|
|
5512
5518
|
const { output: newOutput } = await rebuild(
|
|
5513
5519
|
config,
|
|
@@ -5520,15 +5526,22 @@ function createFileReloader(options) {
|
|
|
5520
5526
|
switch (changes.type) {
|
|
5521
5527
|
case "extension-reload":
|
|
5522
5528
|
server.reloadExtension();
|
|
5529
|
+
import_consola5.consola.success(`Reloaded extension`);
|
|
5523
5530
|
break;
|
|
5524
5531
|
case "html-reload":
|
|
5525
|
-
reloadHtmlPages(
|
|
5532
|
+
const { reloadedNames } = reloadHtmlPages(
|
|
5533
|
+
changes.rebuildGroups,
|
|
5534
|
+
server,
|
|
5535
|
+
config
|
|
5536
|
+
);
|
|
5537
|
+
import_consola5.consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
5526
5538
|
break;
|
|
5527
5539
|
case "content-script-reload":
|
|
5528
5540
|
reloadContentScripts(changes.changedSteps, config, server);
|
|
5541
|
+
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
5542
|
+
import_consola5.consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
5529
5543
|
break;
|
|
5530
5544
|
}
|
|
5531
|
-
import_consola5.consola.success(`Reloaded: ${rebuiltNames}`);
|
|
5532
5545
|
});
|
|
5533
5546
|
};
|
|
5534
5547
|
}
|
|
@@ -5565,10 +5578,19 @@ function reloadContentScripts(steps, config, server) {
|
|
|
5565
5578
|
}
|
|
5566
5579
|
}
|
|
5567
5580
|
function reloadHtmlPages(groups, server, config) {
|
|
5568
|
-
groups.flat().
|
|
5581
|
+
const htmlEntries = groups.flat().filter((entry) => entry.inputPath.endsWith(".html"));
|
|
5582
|
+
htmlEntries.forEach((entry) => {
|
|
5569
5583
|
const path10 = getEntrypointBundlePath(entry, config.outDir, ".html");
|
|
5570
5584
|
server.reloadPage(path10);
|
|
5571
5585
|
});
|
|
5586
|
+
return {
|
|
5587
|
+
reloadedNames: htmlEntries.map((entry) => entry.name)
|
|
5588
|
+
};
|
|
5589
|
+
}
|
|
5590
|
+
function getFilenameList(names) {
|
|
5591
|
+
return names.map((name) => {
|
|
5592
|
+
return import_picocolors7.default.cyan(name);
|
|
5593
|
+
}).join(import_picocolors7.default.dim(", "));
|
|
5572
5594
|
}
|
|
5573
5595
|
|
|
5574
5596
|
// src/core/initialize.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.
|
|
65
|
+
var version = "0.16.0";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.
|
|
65
|
+
var version = "0.16.0";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
getContentScriptCssFiles,
|
|
7
7
|
getContentScriptsCssMap,
|
|
8
8
|
getEntrypointBundlePath,
|
|
9
|
-
getEntrypointOutputFile,
|
|
10
9
|
getInternalConfig,
|
|
11
10
|
getPackageJson,
|
|
12
11
|
internalBuild,
|
|
@@ -15,7 +14,7 @@ import {
|
|
|
15
14
|
rebuild,
|
|
16
15
|
resolvePerBrowserOption,
|
|
17
16
|
version
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NTBDEVHE.js";
|
|
19
18
|
import "./chunk-VBXJIVYU.js";
|
|
20
19
|
|
|
21
20
|
// src/core/build.ts
|
|
@@ -336,11 +335,6 @@ function createFileReloader(options) {
|
|
|
336
335
|
config.logger.info(
|
|
337
336
|
`Changed: ${Array.from(new Set(fileChanges)).map((file) => pc2.dim(relative4(config.root, file))).join(", ")}`
|
|
338
337
|
);
|
|
339
|
-
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
340
|
-
return pc2.cyan(
|
|
341
|
-
relative4(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
342
|
-
);
|
|
343
|
-
}).join(pc2.dim(", "));
|
|
344
338
|
const allEntrypoints = await findEntrypoints(config);
|
|
345
339
|
const { output: newOutput } = await rebuild(
|
|
346
340
|
config,
|
|
@@ -353,15 +347,22 @@ function createFileReloader(options) {
|
|
|
353
347
|
switch (changes.type) {
|
|
354
348
|
case "extension-reload":
|
|
355
349
|
server.reloadExtension();
|
|
350
|
+
consola2.success(`Reloaded extension`);
|
|
356
351
|
break;
|
|
357
352
|
case "html-reload":
|
|
358
|
-
reloadHtmlPages(
|
|
353
|
+
const { reloadedNames } = reloadHtmlPages(
|
|
354
|
+
changes.rebuildGroups,
|
|
355
|
+
server,
|
|
356
|
+
config
|
|
357
|
+
);
|
|
358
|
+
consola2.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
359
359
|
break;
|
|
360
360
|
case "content-script-reload":
|
|
361
361
|
reloadContentScripts(changes.changedSteps, config, server);
|
|
362
|
+
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
363
|
+
consola2.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
362
364
|
break;
|
|
363
365
|
}
|
|
364
|
-
consola2.success(`Reloaded: ${rebuiltNames}`);
|
|
365
366
|
});
|
|
366
367
|
};
|
|
367
368
|
}
|
|
@@ -398,10 +399,19 @@ function reloadContentScripts(steps, config, server) {
|
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
401
|
function reloadHtmlPages(groups, server, config) {
|
|
401
|
-
groups.flat().
|
|
402
|
+
const htmlEntries = groups.flat().filter((entry) => entry.inputPath.endsWith(".html"));
|
|
403
|
+
htmlEntries.forEach((entry) => {
|
|
402
404
|
const path3 = getEntrypointBundlePath(entry, config.outDir, ".html");
|
|
403
405
|
server.reloadPage(path3);
|
|
404
406
|
});
|
|
407
|
+
return {
|
|
408
|
+
reloadedNames: htmlEntries.map((entry) => entry.name)
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
function getFilenameList(names) {
|
|
412
|
+
return names.map((name) => {
|
|
413
|
+
return pc2.cyan(name);
|
|
414
|
+
}).join(pc2.dim(", "));
|
|
405
415
|
}
|
|
406
416
|
|
|
407
417
|
// src/core/initialize.ts
|
package/dist/testing.cjs
CHANGED
|
@@ -792,17 +792,7 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
792
792
|
return config;
|
|
793
793
|
};
|
|
794
794
|
const getLibModeConfig = (entrypoint) => {
|
|
795
|
-
|
|
796
|
-
switch (entrypoint.type) {
|
|
797
|
-
case "background":
|
|
798
|
-
case "unlisted-script":
|
|
799
|
-
virtualEntrypointType = entrypoint.type;
|
|
800
|
-
break;
|
|
801
|
-
case "content-script":
|
|
802
|
-
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
795
|
+
const entry = getRollupEntry(entrypoint);
|
|
806
796
|
const plugins = [
|
|
807
797
|
entrypointGroupGlobals(entrypoint)
|
|
808
798
|
];
|
|
@@ -857,14 +847,16 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
857
847
|
build: {
|
|
858
848
|
rollupOptions: {
|
|
859
849
|
input: entrypoints.reduce((input, entry) => {
|
|
860
|
-
input[entry.name] = entry
|
|
850
|
+
input[entry.name] = getRollupEntry(entry);
|
|
861
851
|
return input;
|
|
862
852
|
}, {}),
|
|
863
853
|
output: {
|
|
864
854
|
// Include a hash to prevent conflicts
|
|
865
855
|
chunkFileNames: "chunks/[name]-[hash].js",
|
|
866
|
-
//
|
|
867
|
-
|
|
856
|
+
// Place JS entrypoints in main directory without a hash. (popup.html & popup.js are
|
|
857
|
+
// next to each other). The unique entrypoint name requirement prevents conflicts with
|
|
858
|
+
// scripts of the same name
|
|
859
|
+
entryFileNames: "[name].js",
|
|
868
860
|
// We can't control the "name", so we need a hash to prevent conflicts
|
|
869
861
|
assetFileNames: "assets/[name]-[hash].[ext]"
|
|
870
862
|
}
|
|
@@ -956,6 +948,19 @@ function getBuildOutputChunks(result) {
|
|
|
956
948
|
return result.flatMap(({ output }) => output);
|
|
957
949
|
return result.output;
|
|
958
950
|
}
|
|
951
|
+
function getRollupEntry(entrypoint) {
|
|
952
|
+
let virtualEntrypointType;
|
|
953
|
+
switch (entrypoint.type) {
|
|
954
|
+
case "background":
|
|
955
|
+
case "unlisted-script":
|
|
956
|
+
virtualEntrypointType = entrypoint.type;
|
|
957
|
+
break;
|
|
958
|
+
case "content-script":
|
|
959
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
963
|
+
}
|
|
959
964
|
|
|
960
965
|
// src/core/utils/building/get-internal-config.ts
|
|
961
966
|
var import_defu2 = __toESM(require("defu"), 1);
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"ora": "^7.0.1",
|
|
112
112
|
"picocolors": "^1.0.0",
|
|
113
113
|
"prompts": "^2.4.2",
|
|
114
|
-
"publish-browser-extension": "^2.
|
|
114
|
+
"publish-browser-extension": "^2.1.0",
|
|
115
115
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
116
116
|
"unimport": "^3.4.0",
|
|
117
117
|
"vite": "^5.0.12",
|