wxt 0.14.1 → 0.14.2
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-B7XRXAP5.js → chunk-TX6NW7VP.js} +60 -25
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +131 -76
- package/dist/{external-tVP-84Pg.d.cts → external-QOQPHF1G.d.cts} +7 -0
- package/dist/{external-tVP-84Pg.d.ts → external-QOQPHF1G.d.ts} +7 -0
- package/dist/index.cjs +97 -60
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/testing.cjs +19 -15
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.14.
|
|
2
|
+
var version = "0.14.2";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -127,7 +127,7 @@ function resolvePerBrowserOption(option, browser) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// src/core/utils/building/find-entrypoints.ts
|
|
130
|
-
import { relative as
|
|
130
|
+
import { relative as relative5, resolve as resolve12 } from "path";
|
|
131
131
|
import fs12 from "fs-extra";
|
|
132
132
|
import { minimatch } from "minimatch";
|
|
133
133
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
@@ -349,8 +349,10 @@ import "wxt/browser";
|
|
|
349
349
|
declare module "wxt/browser" {
|
|
350
350
|
export type PublicPath =
|
|
351
351
|
{{ union }}
|
|
352
|
+
type HtmlPublicPath = Extract<PublicPath, \`\${string}.html\`>
|
|
352
353
|
export interface WxtRuntime extends Runtime.Static {
|
|
353
354
|
getURL(path: PublicPath): string;
|
|
355
|
+
getURL(path: \`\${HtmlPublicPath}\${string}\`): string;
|
|
354
356
|
}
|
|
355
357
|
}
|
|
356
358
|
`;
|
|
@@ -993,7 +995,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
993
995
|
}
|
|
994
996
|
|
|
995
997
|
// src/core/builders/vite/index.ts
|
|
996
|
-
async function
|
|
998
|
+
async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
997
999
|
const vite = await import("vite");
|
|
998
1000
|
const getBaseConfig = async () => {
|
|
999
1001
|
const resolvedInlineConfig = await inlineConfig.vite?.(wxtConfig.env) ?? {};
|
|
@@ -1230,6 +1232,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
1230
1232
|
srcDir,
|
|
1231
1233
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
1232
1234
|
);
|
|
1235
|
+
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
1233
1236
|
const publicDir = path4.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
1234
1237
|
const typesDir = path4.resolve(wxtDir, "types");
|
|
1235
1238
|
const outBaseDir = path4.resolve(root, mergedConfig.outDir ?? ".output");
|
|
@@ -1256,6 +1259,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
1256
1259
|
command,
|
|
1257
1260
|
debug,
|
|
1258
1261
|
entrypointsDir,
|
|
1262
|
+
filterEntrypoints,
|
|
1259
1263
|
env,
|
|
1260
1264
|
fsCache: createFsCache(wxtDir),
|
|
1261
1265
|
imports: mergedConfig.imports ?? {},
|
|
@@ -1287,7 +1291,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
1287
1291
|
},
|
|
1288
1292
|
server
|
|
1289
1293
|
};
|
|
1290
|
-
const builder = await
|
|
1294
|
+
const builder = await createViteBuilder(
|
|
1291
1295
|
inlineConfig,
|
|
1292
1296
|
userConfig,
|
|
1293
1297
|
finalConfig
|
|
@@ -1329,6 +1333,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1329
1333
|
configFile: inlineConfig.configFile,
|
|
1330
1334
|
debug: inlineConfig.debug ?? userConfig.debug,
|
|
1331
1335
|
entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
|
|
1336
|
+
filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
|
|
1332
1337
|
imports,
|
|
1333
1338
|
logger: inlineConfig.logger ?? userConfig.logger,
|
|
1334
1339
|
manifest,
|
|
@@ -1416,7 +1421,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
1416
1421
|
import createJITI from "jiti";
|
|
1417
1422
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
1418
1423
|
import fs7 from "fs-extra";
|
|
1419
|
-
import { resolve as resolve8 } from "node:path";
|
|
1424
|
+
import { relative as relative4, resolve as resolve8 } from "node:path";
|
|
1420
1425
|
|
|
1421
1426
|
// src/core/utils/strings.ts
|
|
1422
1427
|
function kebabCaseAlphanumeric(str) {
|
|
@@ -1493,8 +1498,16 @@ async function importEntrypointFile(path6, config) {
|
|
|
1493
1498
|
const res = await jiti(path6);
|
|
1494
1499
|
return res.default;
|
|
1495
1500
|
} catch (err) {
|
|
1496
|
-
|
|
1497
|
-
|
|
1501
|
+
if (err instanceof ReferenceError) {
|
|
1502
|
+
const variableName = err.message.replace(" is not defined", "");
|
|
1503
|
+
const filePath = relative4(config.root, path6);
|
|
1504
|
+
throw Error(
|
|
1505
|
+
`${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
|
|
1506
|
+
{ cause: err }
|
|
1507
|
+
);
|
|
1508
|
+
} else {
|
|
1509
|
+
throw err;
|
|
1510
|
+
}
|
|
1498
1511
|
}
|
|
1499
1512
|
}
|
|
1500
1513
|
function getEsbuildOptions(opts) {
|
|
@@ -2150,13 +2163,12 @@ function stripPathFromMatchPattern(pattern) {
|
|
|
2150
2163
|
}
|
|
2151
2164
|
|
|
2152
2165
|
// src/core/utils/building/rebuild.ts
|
|
2153
|
-
async function rebuild(config, entrypointGroups, existingOutput = {
|
|
2166
|
+
async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput = {
|
|
2154
2167
|
steps: [],
|
|
2155
2168
|
publicAssets: []
|
|
2156
2169
|
}) {
|
|
2157
2170
|
const { default: ora } = await import("ora");
|
|
2158
2171
|
const spinner = ora(`Preparing...`).start();
|
|
2159
|
-
const allEntrypoints = await findEntrypoints(config);
|
|
2160
2172
|
await generateTypesDir(allEntrypoints, config).catch((err) => {
|
|
2161
2173
|
config.logger.warn("Failed to update .wxt directory:", err);
|
|
2162
2174
|
if (config.command === "build")
|
|
@@ -2206,7 +2218,7 @@ async function internalBuild(config) {
|
|
|
2206
2218
|
const entrypoints = await findEntrypoints(config);
|
|
2207
2219
|
config.logger.debug("Detected entrypoints:", entrypoints);
|
|
2208
2220
|
const groups = groupEntrypoints(entrypoints);
|
|
2209
|
-
const { output } = await rebuild(config, groups, void 0);
|
|
2221
|
+
const { output } = await rebuild(config, entrypoints, groups, void 0);
|
|
2210
2222
|
await printBuildSummary(
|
|
2211
2223
|
config.logger.success,
|
|
2212
2224
|
`Built extension in ${formatDuration(Date.now() - startTime)}`,
|
|
@@ -2237,6 +2249,7 @@ async function combineAnalysisStats(config) {
|
|
|
2237
2249
|
|
|
2238
2250
|
// src/core/utils/building/find-entrypoints.ts
|
|
2239
2251
|
import glob3 from "fast-glob";
|
|
2252
|
+
import pc5 from "picocolors";
|
|
2240
2253
|
async function findEntrypoints(config) {
|
|
2241
2254
|
const relativePaths = await glob3(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
2242
2255
|
cwd: config.entrypointsDir
|
|
@@ -2251,7 +2264,12 @@ async function findEntrypoints(config) {
|
|
|
2251
2264
|
);
|
|
2252
2265
|
if (matchingGlob) {
|
|
2253
2266
|
const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
|
|
2254
|
-
results.push({
|
|
2267
|
+
results.push({
|
|
2268
|
+
name,
|
|
2269
|
+
inputPath,
|
|
2270
|
+
type,
|
|
2271
|
+
skipped: config.filterEntrypoints != null && !config.filterEntrypoints.has(name)
|
|
2272
|
+
});
|
|
2255
2273
|
}
|
|
2256
2274
|
return results;
|
|
2257
2275
|
}, []);
|
|
@@ -2303,11 +2321,19 @@ async function findEntrypoints(config) {
|
|
|
2303
2321
|
await getBackgroundEntrypoint(config, {
|
|
2304
2322
|
inputPath: VIRTUAL_NOOP_BACKGROUND_MODULE_ID,
|
|
2305
2323
|
name: "background",
|
|
2306
|
-
type: "background"
|
|
2324
|
+
type: "background",
|
|
2325
|
+
skipped: false
|
|
2307
2326
|
})
|
|
2308
2327
|
);
|
|
2309
2328
|
}
|
|
2310
2329
|
config.logger.debug("All entrypoints:", entrypoints);
|
|
2330
|
+
const skippedEntrypointNames = entrypointInfos.filter((item) => item.skipped).map((item) => item.name);
|
|
2331
|
+
if (skippedEntrypointNames.length) {
|
|
2332
|
+
config.logger.warn(
|
|
2333
|
+
`Filter excluded the following entrypoints:
|
|
2334
|
+
${skippedEntrypointNames.map((item) => `${pc5.dim("-")} ${pc5.cyan(item)}`).join("\n")}`
|
|
2335
|
+
);
|
|
2336
|
+
}
|
|
2311
2337
|
const targetEntrypoints = entrypoints.filter((entry) => {
|
|
2312
2338
|
const { include, exclude } = entry.options;
|
|
2313
2339
|
if (include?.length && exclude?.length) {
|
|
@@ -2322,6 +2348,9 @@ async function findEntrypoints(config) {
|
|
|
2322
2348
|
if (include?.length && !exclude?.length) {
|
|
2323
2349
|
return include.includes(config.browser);
|
|
2324
2350
|
}
|
|
2351
|
+
if (skippedEntrypointNames.includes(entry.name)) {
|
|
2352
|
+
return false;
|
|
2353
|
+
}
|
|
2325
2354
|
return true;
|
|
2326
2355
|
});
|
|
2327
2356
|
config.logger.debug(`${config.browser} entrypoints:`, targetEntrypoints);
|
|
@@ -2341,7 +2370,7 @@ function preventDuplicateEntrypointNames(config, files) {
|
|
|
2341
2370
|
if (absolutePaths.length > 1) {
|
|
2342
2371
|
lines.push(`- ${name}`);
|
|
2343
2372
|
absolutePaths.forEach((absolutePath) => {
|
|
2344
|
-
lines.push(` - ${
|
|
2373
|
+
lines.push(` - ${relative5(config.root, absolutePath)}`);
|
|
2345
2374
|
});
|
|
2346
2375
|
}
|
|
2347
2376
|
return lines;
|
|
@@ -2374,7 +2403,7 @@ function getHtmlBaseOptions(document) {
|
|
|
2374
2403
|
}
|
|
2375
2404
|
return options;
|
|
2376
2405
|
}
|
|
2377
|
-
async function getPopupEntrypoint(config, { inputPath, name }) {
|
|
2406
|
+
async function getPopupEntrypoint(config, { inputPath, name, skipped }) {
|
|
2378
2407
|
const content = await fs12.readFile(inputPath, "utf-8");
|
|
2379
2408
|
const { document } = parseHTML2(content);
|
|
2380
2409
|
const options = getHtmlBaseOptions(document);
|
|
@@ -2405,10 +2434,11 @@ async function getPopupEntrypoint(config, { inputPath, name }) {
|
|
|
2405
2434
|
name: "popup",
|
|
2406
2435
|
options,
|
|
2407
2436
|
inputPath,
|
|
2408
|
-
outputDir: config.outDir
|
|
2437
|
+
outputDir: config.outDir,
|
|
2438
|
+
skipped
|
|
2409
2439
|
};
|
|
2410
2440
|
}
|
|
2411
|
-
async function getOptionsEntrypoint(config, { inputPath, name }) {
|
|
2441
|
+
async function getOptionsEntrypoint(config, { inputPath, name, skipped }) {
|
|
2412
2442
|
const content = await fs12.readFile(inputPath, "utf-8");
|
|
2413
2443
|
const { document } = parseHTML2(content);
|
|
2414
2444
|
const options = getHtmlBaseOptions(document);
|
|
@@ -2429,10 +2459,11 @@ async function getOptionsEntrypoint(config, { inputPath, name }) {
|
|
|
2429
2459
|
name: "options",
|
|
2430
2460
|
options,
|
|
2431
2461
|
inputPath,
|
|
2432
|
-
outputDir: config.outDir
|
|
2462
|
+
outputDir: config.outDir,
|
|
2463
|
+
skipped
|
|
2433
2464
|
};
|
|
2434
2465
|
}
|
|
2435
|
-
async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
|
|
2466
|
+
async function getUnlistedPageEntrypoint(config, { inputPath, name, skipped }) {
|
|
2436
2467
|
const content = await fs12.readFile(inputPath, "utf-8");
|
|
2437
2468
|
const { document } = parseHTML2(content);
|
|
2438
2469
|
return {
|
|
@@ -2440,10 +2471,11 @@ async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
|
|
|
2440
2471
|
name: getEntrypointName(config.entrypointsDir, inputPath),
|
|
2441
2472
|
inputPath,
|
|
2442
2473
|
outputDir: config.outDir,
|
|
2443
|
-
options: getHtmlBaseOptions(document)
|
|
2474
|
+
options: getHtmlBaseOptions(document),
|
|
2475
|
+
skipped
|
|
2444
2476
|
};
|
|
2445
2477
|
}
|
|
2446
|
-
async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
|
|
2478
|
+
async function getUnlistedScriptEntrypoint(config, { inputPath, name, skipped }) {
|
|
2447
2479
|
const defaultExport = await importEntrypointFile(
|
|
2448
2480
|
inputPath,
|
|
2449
2481
|
config
|
|
@@ -2460,10 +2492,11 @@ async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
|
|
|
2460
2492
|
name,
|
|
2461
2493
|
inputPath,
|
|
2462
2494
|
outputDir: config.outDir,
|
|
2463
|
-
options
|
|
2495
|
+
options,
|
|
2496
|
+
skipped
|
|
2464
2497
|
};
|
|
2465
2498
|
}
|
|
2466
|
-
async function getBackgroundEntrypoint(config, { inputPath, name }) {
|
|
2499
|
+
async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
|
|
2467
2500
|
let options = {};
|
|
2468
2501
|
if (inputPath !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
|
|
2469
2502
|
const defaultExport = await importEntrypointFile(
|
|
@@ -2487,10 +2520,11 @@ async function getBackgroundEntrypoint(config, { inputPath, name }) {
|
|
|
2487
2520
|
...options,
|
|
2488
2521
|
type: resolvePerBrowserOption(options.type, config.browser),
|
|
2489
2522
|
persistent: resolvePerBrowserOption(options.persistent, config.browser)
|
|
2490
|
-
}
|
|
2523
|
+
},
|
|
2524
|
+
skipped
|
|
2491
2525
|
};
|
|
2492
2526
|
}
|
|
2493
|
-
async function getContentScriptEntrypoint(config, { inputPath, name }) {
|
|
2527
|
+
async function getContentScriptEntrypoint(config, { inputPath, name, skipped }) {
|
|
2494
2528
|
const { main: _, ...options } = await importEntrypointFile(inputPath, config);
|
|
2495
2529
|
if (options == null) {
|
|
2496
2530
|
throw Error(
|
|
@@ -2502,7 +2536,8 @@ async function getContentScriptEntrypoint(config, { inputPath, name }) {
|
|
|
2502
2536
|
name,
|
|
2503
2537
|
inputPath,
|
|
2504
2538
|
outputDir: resolve12(config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
2505
|
-
options
|
|
2539
|
+
options,
|
|
2540
|
+
skipped
|
|
2506
2541
|
};
|
|
2507
2542
|
}
|
|
2508
2543
|
var PATH_GLOB_TO_TYPE_MAP = {
|
package/dist/cli.d.ts
ADDED