wxt 0.11.2 → 0.12.1
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/bin/wxt.mjs +2 -0
- package/dist/{chunk-XTGVY6KL.js → chunk-ENVSDI4C.js} +62 -35
- package/dist/cli.js +3119 -0
- package/dist/client.d.ts +3 -8
- package/dist/client.js +1 -15
- package/dist/{external-PmmO6xnl.d.ts → external-TYmXqKVq.d.ts} +24 -11
- package/dist/{external-irU6kFSB.d.cts → external-tVP-84Pg.d.cts} +24 -11
- package/dist/{external-irU6kFSB.d.ts → external-tVP-84Pg.d.ts} +24 -11
- package/dist/index.cjs +107 -79
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/sandbox.d.ts +7 -2
- package/dist/sandbox.js +14 -0
- package/dist/testing.cjs +21 -10
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/{content-script-entrypoint.js → content-script-isolated-world-entrypoint.js} +3 -3
- package/dist/virtual/content-script-main-world-entrypoint.js +33 -0
- package/package.json +38 -19
- package/bin/wxt.cjs +0 -2
- package/dist/cli.cjs +0 -5506
package/bin/wxt.mjs
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.12.1";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -1029,7 +1029,8 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1029
1029
|
devHtmlPrerender(wxtConfig),
|
|
1030
1030
|
unimport(wxtConfig),
|
|
1031
1031
|
virtualEntrypoint("background", wxtConfig),
|
|
1032
|
-
virtualEntrypoint("content-script", wxtConfig),
|
|
1032
|
+
virtualEntrypoint("content-script-isolated-world", wxtConfig),
|
|
1033
|
+
virtualEntrypoint("content-script-main-world", wxtConfig),
|
|
1033
1034
|
virtualEntrypoint("unlisted-script", wxtConfig),
|
|
1034
1035
|
devServerGlobals(wxtConfig),
|
|
1035
1036
|
tsconfigPaths(wxtConfig),
|
|
@@ -1043,12 +1044,17 @@ async function craeteViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1043
1044
|
return config;
|
|
1044
1045
|
};
|
|
1045
1046
|
const getLibModeConfig = (entrypoint) => {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
"
|
|
1049
|
-
"unlisted-script"
|
|
1050
|
-
|
|
1051
|
-
|
|
1047
|
+
let virtualEntrypointType;
|
|
1048
|
+
switch (entrypoint.type) {
|
|
1049
|
+
case "background":
|
|
1050
|
+
case "unlisted-script":
|
|
1051
|
+
virtualEntrypointType = entrypoint.type;
|
|
1052
|
+
break;
|
|
1053
|
+
case "content-script":
|
|
1054
|
+
virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
const entry = virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
|
|
1052
1058
|
const plugins = [
|
|
1053
1059
|
entrypointGroupGlobals(entrypoint)
|
|
1054
1060
|
];
|
|
@@ -1209,7 +1215,10 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
1209
1215
|
const { config: loadedConfig, ...metadata } = await loadConfig({
|
|
1210
1216
|
name: "wxt",
|
|
1211
1217
|
cwd: inlineConfig.root ?? process.cwd(),
|
|
1212
|
-
rcFile: false
|
|
1218
|
+
rcFile: false,
|
|
1219
|
+
jitiOptions: {
|
|
1220
|
+
esmResolve: true
|
|
1221
|
+
}
|
|
1213
1222
|
});
|
|
1214
1223
|
userConfig = loadedConfig ?? {};
|
|
1215
1224
|
userConfigMetadata = metadata;
|
|
@@ -1418,7 +1427,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
1418
1427
|
import createJITI from "jiti";
|
|
1419
1428
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
1420
1429
|
import fs7 from "fs-extra";
|
|
1421
|
-
import { resolve as resolve8 } from "path";
|
|
1430
|
+
import { resolve as resolve8 } from "node:path";
|
|
1422
1431
|
|
|
1423
1432
|
// src/core/utils/strings.ts
|
|
1424
1433
|
function kebabCaseAlphanumeric(str) {
|
|
@@ -1432,14 +1441,14 @@ function removeImportStatements(text) {
|
|
|
1432
1441
|
}
|
|
1433
1442
|
function removeProjectImportStatements(text) {
|
|
1434
1443
|
const noImports = removeImportStatements(text);
|
|
1435
|
-
return `import { defineContentScript, defineBackground } from 'wxt/
|
|
1436
|
-
import { defineUnlistedScript } from 'wxt/sandbox';
|
|
1444
|
+
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
1437
1445
|
|
|
1438
1446
|
${noImports}`;
|
|
1439
1447
|
}
|
|
1440
1448
|
|
|
1441
1449
|
// src/core/utils/building/import-entrypoint.ts
|
|
1442
1450
|
import { transformSync } from "esbuild";
|
|
1451
|
+
import { fileURLToPath } from "node:url";
|
|
1443
1452
|
async function importEntrypointFile(path6, config) {
|
|
1444
1453
|
config.logger.debug("Loading file metadata:", path6);
|
|
1445
1454
|
const normalPath = normalizePath(path6);
|
|
@@ -1455,30 +1464,42 @@ async function importEntrypointFile(path6, config) {
|
|
|
1455
1464
|
config.logger.debug(
|
|
1456
1465
|
["Text:", text, "No imports:", textNoImports, "Code:", code].join("\n")
|
|
1457
1466
|
);
|
|
1458
|
-
const jiti = createJITI(
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
"
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1467
|
+
const jiti = createJITI(
|
|
1468
|
+
typeof __filename !== "undefined" ? __filename : fileURLToPath(import.meta.url),
|
|
1469
|
+
{
|
|
1470
|
+
cache: false,
|
|
1471
|
+
debug: config.debug,
|
|
1472
|
+
esmResolve: true,
|
|
1473
|
+
alias: {
|
|
1474
|
+
"webextension-polyfill": resolve8(
|
|
1475
|
+
config.root,
|
|
1476
|
+
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
1477
|
+
)
|
|
1478
|
+
},
|
|
1479
|
+
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
1480
|
+
// respect the custom transform function when using it's native bun option.
|
|
1481
|
+
experimentalBun: false,
|
|
1482
|
+
// List of extensions to transform with esbuild
|
|
1483
|
+
extensions: [
|
|
1484
|
+
".ts",
|
|
1485
|
+
".cts",
|
|
1486
|
+
".mts",
|
|
1487
|
+
".tsx",
|
|
1488
|
+
".js",
|
|
1489
|
+
".cjs",
|
|
1490
|
+
".mjs",
|
|
1491
|
+
".jsx"
|
|
1492
|
+
],
|
|
1493
|
+
transform(opts) {
|
|
1494
|
+
const isEntrypoint = opts.filename === normalPath;
|
|
1495
|
+
return transformSync(
|
|
1496
|
+
// Use modified source code for entrypoints
|
|
1497
|
+
isEntrypoint ? code : opts.source,
|
|
1498
|
+
getEsbuildOptions(opts)
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1480
1501
|
}
|
|
1481
|
-
|
|
1502
|
+
);
|
|
1482
1503
|
try {
|
|
1483
1504
|
const res = await jiti(path6);
|
|
1484
1505
|
return res.default;
|
|
@@ -2220,6 +2241,7 @@ async function findEntrypoints(config) {
|
|
|
2220
2241
|
}
|
|
2221
2242
|
return results;
|
|
2222
2243
|
}, []);
|
|
2244
|
+
preventNoEntrypoints(config, entrypointInfos);
|
|
2223
2245
|
preventDuplicateEntrypointNames(config, entrypointInfos);
|
|
2224
2246
|
let hasBackground = false;
|
|
2225
2247
|
const entrypoints = await Promise.all(
|
|
@@ -2321,6 +2343,11 @@ ${errorContent}`
|
|
|
2321
2343
|
);
|
|
2322
2344
|
}
|
|
2323
2345
|
}
|
|
2346
|
+
function preventNoEntrypoints(config, files) {
|
|
2347
|
+
if (files.length === 0) {
|
|
2348
|
+
throw Error(`No entrypoints found in ${config.entrypointsDir}`);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2324
2351
|
function getHtmlBaseOptions(document) {
|
|
2325
2352
|
const options = {};
|
|
2326
2353
|
const includeContent = document.querySelector("meta[name='manifest.include']")?.getAttribute("content");
|