wxt 0.18.8 → 0.18.10
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-Z3C7S5VV.js → chunk-2V7XZSZQ.js} +385 -286
- package/dist/chunk-6XSIWUWF.js +57 -0
- package/dist/cli.js +416 -305
- package/dist/{index-D6lH9OkP.d.cts → index-mz3v4Nde.d.cts} +67 -13
- package/dist/{index-D6lH9OkP.d.ts → index-mz3v4Nde.d.ts} +67 -13
- package/dist/index.cjs +502 -390
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/modules.js +8 -49
- package/dist/testing.cjs +207 -116
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +18 -9
- package/package.json +2 -1
package/dist/testing.cjs
CHANGED
|
@@ -445,7 +445,7 @@ var init_core = __esm({
|
|
|
445
445
|
|
|
446
446
|
// ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
|
|
447
447
|
function parseStack(stack) {
|
|
448
|
-
const cwd = process.cwd() +
|
|
448
|
+
const cwd = process.cwd() + import_node_path13.sep;
|
|
449
449
|
const lines = stack.split("\n").splice(1).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
450
450
|
return lines;
|
|
451
451
|
}
|
|
@@ -453,12 +453,12 @@ function writeStream(data, stream) {
|
|
|
453
453
|
const write = stream.__write || stream.write;
|
|
454
454
|
return write.call(stream, data);
|
|
455
455
|
}
|
|
456
|
-
var import_node_util,
|
|
456
|
+
var import_node_util, import_node_path13, bracket, BasicReporter;
|
|
457
457
|
var init_consola_06ad8a64 = __esm({
|
|
458
458
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs"() {
|
|
459
459
|
"use strict";
|
|
460
460
|
import_node_util = require("util");
|
|
461
|
-
|
|
461
|
+
import_node_path13 = require("path");
|
|
462
462
|
bracket = (x) => x ? `[${x}]` : "";
|
|
463
463
|
BasicReporter = class {
|
|
464
464
|
formatStack(stack, opts) {
|
|
@@ -861,7 +861,7 @@ async function prompt(message, opts = {}) {
|
|
|
861
861
|
}
|
|
862
862
|
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
863
863
|
}
|
|
864
|
-
var import_node_process, import_node_readline, import_node_tty, import_tty, import_node_util2,
|
|
864
|
+
var import_node_process, import_node_readline, import_node_tty, import_tty, import_node_util2, import_node_path14, ESC, CSI, beep, cursor, scroll, erase, src, picocolors, tty2, isColorSupported2, formatter, replaceClose2, createColors2, picocolorsExports, l, m, G, K, Y, v, L, M, T, r, Z, H, q, p, J, b, W, Q, I, w, N, j, X, _, DD, uD, R, V, tD, h, sD, iD, ED, oD, unicode, s, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR, S_BAR_END, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, symbol, text, confirm, select, multiselect;
|
|
865
865
|
var init_prompt = __esm({
|
|
866
866
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs"() {
|
|
867
867
|
"use strict";
|
|
@@ -874,7 +874,7 @@ var init_prompt = __esm({
|
|
|
874
874
|
init_core();
|
|
875
875
|
init_consola_06ad8a64();
|
|
876
876
|
import_node_util2 = require("util");
|
|
877
|
-
|
|
877
|
+
import_node_path14 = require("path");
|
|
878
878
|
ESC = "\x1B";
|
|
879
879
|
CSI = `${ESC}[`;
|
|
880
880
|
beep = "\x07";
|
|
@@ -1972,38 +1972,6 @@ function download(config) {
|
|
|
1972
1972
|
var import_node_path4 = require("path");
|
|
1973
1973
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
1974
1974
|
|
|
1975
|
-
// src/core/builders/vite/plugins/unimport.ts
|
|
1976
|
-
var import_unimport = require("unimport");
|
|
1977
|
-
var import_path = require("path");
|
|
1978
|
-
var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1979
|
-
".js",
|
|
1980
|
-
".jsx",
|
|
1981
|
-
".ts",
|
|
1982
|
-
".tsx",
|
|
1983
|
-
".vue",
|
|
1984
|
-
".svelte"
|
|
1985
|
-
]);
|
|
1986
|
-
function unimport(config) {
|
|
1987
|
-
const options = config.imports;
|
|
1988
|
-
if (options === false) return [];
|
|
1989
|
-
const unimport2 = (0, import_unimport.createUnimport)(options);
|
|
1990
|
-
return {
|
|
1991
|
-
name: "wxt:unimport",
|
|
1992
|
-
async config() {
|
|
1993
|
-
await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
|
|
1994
|
-
},
|
|
1995
|
-
async transform(code, id) {
|
|
1996
|
-
if (id.includes("node_modules")) return;
|
|
1997
|
-
if (!ENABLED_EXTENSIONS.has((0, import_path.extname)(id))) return;
|
|
1998
|
-
const injected = await unimport2.injectImports(code, id);
|
|
1999
|
-
return {
|
|
2000
|
-
code: injected.code,
|
|
2001
|
-
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
2002
|
-
};
|
|
2003
|
-
}
|
|
2004
|
-
};
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
1975
|
// src/core/utils/virtual-modules.ts
|
|
2008
1976
|
var virtualEntrypointTypes = [
|
|
2009
1977
|
"content-script-main-world",
|
|
@@ -2142,7 +2110,7 @@ var import_linkedom2 = require("linkedom");
|
|
|
2142
2110
|
|
|
2143
2111
|
// src/core/utils/fs.ts
|
|
2144
2112
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
2145
|
-
var
|
|
2113
|
+
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
2146
2114
|
|
|
2147
2115
|
// src/core/wxt.ts
|
|
2148
2116
|
var import_hookable = require("hookable");
|
|
@@ -2154,6 +2122,113 @@ var import_nypm = require("nypm");
|
|
|
2154
2122
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
2155
2123
|
var import_fs_extra3 = require("fs-extra");
|
|
2156
2124
|
|
|
2125
|
+
// src/core/builders/vite/index.ts
|
|
2126
|
+
var import_server = require("vite-node/server");
|
|
2127
|
+
var import_client = require("vite-node/client");
|
|
2128
|
+
var import_source_map = require("vite-node/source-map");
|
|
2129
|
+
|
|
2130
|
+
// src/modules.ts
|
|
2131
|
+
var vite = __toESM(require("vite"), 1);
|
|
2132
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
2133
|
+
var import_node_path9 = require("path");
|
|
2134
|
+
function defineWxtModule(module2) {
|
|
2135
|
+
if (typeof module2 === "function") return { setup: module2 };
|
|
2136
|
+
return module2;
|
|
2137
|
+
}
|
|
2138
|
+
function addViteConfig(wxt2, viteConfig) {
|
|
2139
|
+
wxt2.hooks.hook("ready", (wxt3) => {
|
|
2140
|
+
const userVite = wxt3.config.vite;
|
|
2141
|
+
wxt3.config.vite = async (env2) => {
|
|
2142
|
+
const fromUser = await userVite(env2);
|
|
2143
|
+
const fromModule = viteConfig(env2) ?? {};
|
|
2144
|
+
return vite.mergeConfig(fromModule, fromUser);
|
|
2145
|
+
};
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// src/builtin-modules/unimport.ts
|
|
2150
|
+
var import_unimport = require("unimport");
|
|
2151
|
+
var import_node_path10 = require("path");
|
|
2152
|
+
var unimport_default = defineWxtModule({
|
|
2153
|
+
name: "wxt:built-in:unimport",
|
|
2154
|
+
setup(wxt2) {
|
|
2155
|
+
const options = wxt2.config.imports;
|
|
2156
|
+
if (options === false) return;
|
|
2157
|
+
let unimport;
|
|
2158
|
+
wxt2.hooks.hook("ready", () => {
|
|
2159
|
+
const addModuleImports = (module2) => {
|
|
2160
|
+
if (!module2.imports) return;
|
|
2161
|
+
options.imports ??= [];
|
|
2162
|
+
options.imports.push(...module2.imports);
|
|
2163
|
+
};
|
|
2164
|
+
wxt2.config.builtinModules.forEach(addModuleImports);
|
|
2165
|
+
wxt2.config.userModules.forEach(addModuleImports);
|
|
2166
|
+
});
|
|
2167
|
+
wxt2.hooks.afterEach((event) => {
|
|
2168
|
+
if (event.name === "ready") {
|
|
2169
|
+
unimport = (0, import_unimport.createUnimport)(options);
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
wxt2.hooks.hook("prepare:types", async (_2, entries) => {
|
|
2173
|
+
await unimport.init();
|
|
2174
|
+
entries.push(await getImportsDeclarationEntry(unimport));
|
|
2175
|
+
if (!options.eslintrc.enabled) return;
|
|
2176
|
+
entries.push(await getImportsEslintEntry(unimport, options));
|
|
2177
|
+
});
|
|
2178
|
+
addViteConfig(wxt2, () => ({
|
|
2179
|
+
plugins: [vitePlugin(unimport)]
|
|
2180
|
+
}));
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
function vitePlugin(unimport) {
|
|
2184
|
+
const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2185
|
+
".js",
|
|
2186
|
+
".jsx",
|
|
2187
|
+
".ts",
|
|
2188
|
+
".tsx",
|
|
2189
|
+
".vue",
|
|
2190
|
+
".svelte"
|
|
2191
|
+
]);
|
|
2192
|
+
return {
|
|
2193
|
+
name: "wxt:unimport",
|
|
2194
|
+
async transform(code, id) {
|
|
2195
|
+
if (id.includes("node_modules")) return;
|
|
2196
|
+
if (!ENABLED_EXTENSIONS.has((0, import_node_path10.extname)(id))) return;
|
|
2197
|
+
const injected = await unimport.injectImports(code, id);
|
|
2198
|
+
return {
|
|
2199
|
+
code: injected.code,
|
|
2200
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
async function getImportsDeclarationEntry(unimport) {
|
|
2206
|
+
await unimport.init();
|
|
2207
|
+
return {
|
|
2208
|
+
path: "types/imports.d.ts",
|
|
2209
|
+
text: [
|
|
2210
|
+
"// Generated by wxt",
|
|
2211
|
+
await unimport.generateTypeDeclarations(),
|
|
2212
|
+
""
|
|
2213
|
+
].join("\n"),
|
|
2214
|
+
tsReference: true
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
async function getImportsEslintEntry(unimport, options) {
|
|
2218
|
+
const globals2 = {};
|
|
2219
|
+
const eslintrc = { globals: globals2 };
|
|
2220
|
+
(await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => {
|
|
2221
|
+
eslintrc.globals[name] = options.eslintrc.globalsPropValue;
|
|
2222
|
+
});
|
|
2223
|
+
return {
|
|
2224
|
+
path: options.eslintrc.filePath,
|
|
2225
|
+
text: JSON.stringify(eslintrc, null, 2) + "\n"
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
// src/builtin-modules/index.ts
|
|
2230
|
+
var builtinModules = [unimport_default];
|
|
2231
|
+
|
|
2157
2232
|
// src/core/utils/fs.ts
|
|
2158
2233
|
async function writeFileIfDifferent(file, newContents) {
|
|
2159
2234
|
const existingContents = await import_fs_extra4.default.readFile(file, "utf-8").catch(() => void 0);
|
|
@@ -2167,22 +2242,12 @@ var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
|
2167
2242
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
2168
2243
|
|
|
2169
2244
|
// src/core/utils/building/find-entrypoints.ts
|
|
2170
|
-
var
|
|
2245
|
+
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
2171
2246
|
var import_minimatch = require("minimatch");
|
|
2172
2247
|
var import_linkedom3 = require("linkedom");
|
|
2173
2248
|
var import_json5 = __toESM(require("json5"), 1);
|
|
2174
|
-
var
|
|
2249
|
+
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
2175
2250
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
2176
|
-
|
|
2177
|
-
// src/core/utils/building/import-entrypoint.ts
|
|
2178
|
-
var import_jiti = __toESM(require("jiti"), 1);
|
|
2179
|
-
var import_unimport2 = require("unimport");
|
|
2180
|
-
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
2181
|
-
var import_node_path9 = require("path");
|
|
2182
|
-
var import_esbuild = require("esbuild");
|
|
2183
|
-
var import_node_url = require("url");
|
|
2184
|
-
|
|
2185
|
-
// src/core/utils/building/find-entrypoints.ts
|
|
2186
2251
|
var PATH_GLOB_TO_TYPE_MAP = {
|
|
2187
2252
|
"sandbox.html": "sandbox",
|
|
2188
2253
|
"sandbox/index.html": "sandbox",
|
|
@@ -2224,29 +2289,29 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
2224
2289
|
};
|
|
2225
2290
|
|
|
2226
2291
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
2227
|
-
var
|
|
2228
|
-
var
|
|
2229
|
-
var
|
|
2292
|
+
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
2293
|
+
var import_node_path11 = require("path");
|
|
2294
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
2230
2295
|
|
|
2231
2296
|
// src/core/utils/building/resolve-config.ts
|
|
2232
2297
|
var import_c12 = require("c12");
|
|
2233
|
-
var
|
|
2298
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
2234
2299
|
|
|
2235
2300
|
// src/core/utils/cache.ts
|
|
2236
|
-
var
|
|
2237
|
-
var
|
|
2301
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
2302
|
+
var import_path = require("path");
|
|
2238
2303
|
function createFsCache(wxtDir) {
|
|
2239
|
-
const getPath = (key) => (0,
|
|
2304
|
+
const getPath = (key) => (0, import_path.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
2240
2305
|
return {
|
|
2241
2306
|
async set(key, value) {
|
|
2242
2307
|
const path8 = getPath(key);
|
|
2243
|
-
await (0,
|
|
2308
|
+
await (0, import_fs_extra8.ensureDir)((0, import_path.dirname)(path8));
|
|
2244
2309
|
await writeFileIfDifferent(path8, value);
|
|
2245
2310
|
},
|
|
2246
2311
|
async get(key) {
|
|
2247
2312
|
const path8 = getPath(key);
|
|
2248
2313
|
try {
|
|
2249
|
-
return await
|
|
2314
|
+
return await import_fs_extra8.default.readFile(path8, "utf-8");
|
|
2250
2315
|
} catch {
|
|
2251
2316
|
return void 0;
|
|
2252
2317
|
}
|
|
@@ -2262,14 +2327,14 @@ var import_node_process3 = require("process");
|
|
|
2262
2327
|
init_utils();
|
|
2263
2328
|
var import_node_tty2 = require("tty");
|
|
2264
2329
|
var import_node_util3 = require("util");
|
|
2265
|
-
var
|
|
2330
|
+
var import_node_path15 = require("path");
|
|
2266
2331
|
|
|
2267
2332
|
// src/core/utils/building/resolve-config.ts
|
|
2268
2333
|
var import_defu = __toESM(require("defu"), 1);
|
|
2269
2334
|
|
|
2270
2335
|
// src/core/utils/package.ts
|
|
2271
|
-
var
|
|
2272
|
-
var
|
|
2336
|
+
var import_node_path16 = require("path");
|
|
2337
|
+
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
2273
2338
|
function isModuleInstalled(name) {
|
|
2274
2339
|
return import(
|
|
2275
2340
|
/* @vite-ignore */
|
|
@@ -2278,8 +2343,8 @@ function isModuleInstalled(name) {
|
|
|
2278
2343
|
}
|
|
2279
2344
|
|
|
2280
2345
|
// src/core/utils/building/resolve-config.ts
|
|
2281
|
-
var
|
|
2282
|
-
var
|
|
2346
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
2347
|
+
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
2283
2348
|
var import_meta = {};
|
|
2284
2349
|
async function resolveConfig(inlineConfig, command) {
|
|
2285
2350
|
let userConfig = {};
|
|
@@ -2305,28 +2370,28 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2305
2370
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
2306
2371
|
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
2307
2372
|
const env2 = { browser, command, manifestVersion, mode };
|
|
2308
|
-
const root =
|
|
2373
|
+
const root = import_node_path17.default.resolve(
|
|
2309
2374
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
2310
2375
|
);
|
|
2311
|
-
const wxtDir =
|
|
2376
|
+
const wxtDir = import_node_path17.default.resolve(root, ".wxt");
|
|
2312
2377
|
const wxtModuleDir = await resolveWxtModuleDir();
|
|
2313
|
-
const srcDir =
|
|
2314
|
-
const entrypointsDir =
|
|
2378
|
+
const srcDir = import_node_path17.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
2379
|
+
const entrypointsDir = import_node_path17.default.resolve(
|
|
2315
2380
|
srcDir,
|
|
2316
2381
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
2317
2382
|
);
|
|
2318
|
-
const modulesDir =
|
|
2383
|
+
const modulesDir = import_node_path17.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
|
|
2319
2384
|
if (await isDirMissing(entrypointsDir)) {
|
|
2320
2385
|
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
2321
2386
|
}
|
|
2322
2387
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
2323
|
-
const publicDir =
|
|
2388
|
+
const publicDir = import_node_path17.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
2324
2389
|
if (await isDirMissing(publicDir)) {
|
|
2325
2390
|
logMissingDir(logger, "Public", publicDir);
|
|
2326
2391
|
}
|
|
2327
|
-
const typesDir =
|
|
2328
|
-
const outBaseDir =
|
|
2329
|
-
const outDir =
|
|
2392
|
+
const typesDir = import_node_path17.default.resolve(wxtDir, "types");
|
|
2393
|
+
const outBaseDir = import_node_path17.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
2394
|
+
const outDir = import_node_path17.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
2330
2395
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
2331
2396
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
2332
2397
|
name: "web-ext",
|
|
@@ -2343,7 +2408,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2343
2408
|
"~": srcDir,
|
|
2344
2409
|
"@@": root,
|
|
2345
2410
|
"~~": root
|
|
2346
|
-
}).map(([key, value]) => [key,
|
|
2411
|
+
}).map(([key, value]) => [key, import_node_path17.default.resolve(root, value)])
|
|
2347
2412
|
);
|
|
2348
2413
|
let devServerConfig;
|
|
2349
2414
|
if (command === "serve") {
|
|
@@ -2357,14 +2422,20 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2357
2422
|
hostname: "localhost"
|
|
2358
2423
|
};
|
|
2359
2424
|
}
|
|
2360
|
-
const
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2425
|
+
const userModules = await resolveWxtUserModules(
|
|
2426
|
+
modulesDir,
|
|
2427
|
+
mergedConfig.modules
|
|
2428
|
+
);
|
|
2429
|
+
const moduleOptions = userModules.reduce(
|
|
2430
|
+
(map, module2) => {
|
|
2431
|
+
if (module2.configKey) {
|
|
2432
|
+
map[module2.configKey] = // @ts-expect-error
|
|
2433
|
+
mergedConfig[module2.configKey];
|
|
2434
|
+
}
|
|
2435
|
+
return map;
|
|
2436
|
+
},
|
|
2437
|
+
{}
|
|
2438
|
+
);
|
|
2368
2439
|
return {
|
|
2369
2440
|
browser,
|
|
2370
2441
|
command,
|
|
@@ -2374,7 +2445,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2374
2445
|
filterEntrypoints,
|
|
2375
2446
|
env: env2,
|
|
2376
2447
|
fsCache: createFsCache(wxtDir),
|
|
2377
|
-
imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
|
|
2448
|
+
imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
|
|
2378
2449
|
logger,
|
|
2379
2450
|
manifest: await resolveManifestConfig(env2, mergedConfig.manifest),
|
|
2380
2451
|
manifestVersion,
|
|
@@ -2395,7 +2466,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2395
2466
|
alias,
|
|
2396
2467
|
experimental: (0, import_defu.default)(mergedConfig.experimental, {
|
|
2397
2468
|
includeBrowserPolyfill: true,
|
|
2398
|
-
|
|
2469
|
+
entrypointImporter: "jiti"
|
|
2399
2470
|
}),
|
|
2400
2471
|
dev: {
|
|
2401
2472
|
server: devServerConfig,
|
|
@@ -2403,7 +2474,8 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2403
2474
|
},
|
|
2404
2475
|
hooks: mergedConfig.hooks ?? {},
|
|
2405
2476
|
vite: mergedConfig.vite ?? (() => ({})),
|
|
2406
|
-
|
|
2477
|
+
builtinModules,
|
|
2478
|
+
userModules,
|
|
2407
2479
|
plugins: [],
|
|
2408
2480
|
...moduleOptions
|
|
2409
2481
|
};
|
|
@@ -2433,7 +2505,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
2433
2505
|
};
|
|
2434
2506
|
}
|
|
2435
2507
|
function resolveZipConfig(root, mergedConfig) {
|
|
2436
|
-
const downloadedPackagesDir =
|
|
2508
|
+
const downloadedPackagesDir = import_node_path17.default.resolve(root, ".wxt/local_modules");
|
|
2437
2509
|
return {
|
|
2438
2510
|
name: void 0,
|
|
2439
2511
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -2459,12 +2531,12 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
2459
2531
|
};
|
|
2460
2532
|
}
|
|
2461
2533
|
function resolveAnalysisConfig(root, mergedConfig) {
|
|
2462
|
-
const analysisOutputFile =
|
|
2534
|
+
const analysisOutputFile = import_node_path17.default.resolve(
|
|
2463
2535
|
root,
|
|
2464
2536
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
2465
2537
|
);
|
|
2466
|
-
const analysisOutputDir =
|
|
2467
|
-
const analysisOutputName =
|
|
2538
|
+
const analysisOutputDir = import_node_path17.default.dirname(analysisOutputFile);
|
|
2539
|
+
const analysisOutputName = import_node_path17.default.parse(analysisOutputFile).name;
|
|
2468
2540
|
return {
|
|
2469
2541
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
2470
2542
|
open: mergedConfig.analysis?.open ?? false,
|
|
@@ -2475,17 +2547,17 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
2475
2547
|
keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
|
|
2476
2548
|
};
|
|
2477
2549
|
}
|
|
2478
|
-
async function getUnimportOptions(wxtDir, logger, config) {
|
|
2550
|
+
async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
2479
2551
|
if (config.imports === false) return false;
|
|
2480
|
-
const
|
|
2481
|
-
let
|
|
2482
|
-
switch (
|
|
2552
|
+
const rawEslintEnabled = config.imports?.eslintrc?.enabled;
|
|
2553
|
+
let eslintEnabled;
|
|
2554
|
+
switch (rawEslintEnabled) {
|
|
2483
2555
|
case void 0:
|
|
2484
2556
|
case "auto":
|
|
2485
|
-
|
|
2557
|
+
eslintEnabled = await isModuleInstalled("eslint");
|
|
2486
2558
|
break;
|
|
2487
2559
|
default:
|
|
2488
|
-
|
|
2560
|
+
eslintEnabled = rawEslintEnabled;
|
|
2489
2561
|
}
|
|
2490
2562
|
const defaultOptions = {
|
|
2491
2563
|
debugLog: logger.debug,
|
|
@@ -2501,9 +2573,12 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
2501
2573
|
],
|
|
2502
2574
|
warn: logger.warn,
|
|
2503
2575
|
dirs: ["components", "composables", "hooks", "utils"],
|
|
2576
|
+
dirsScanOptions: {
|
|
2577
|
+
cwd: srcDir
|
|
2578
|
+
},
|
|
2504
2579
|
eslintrc: {
|
|
2505
|
-
enabled,
|
|
2506
|
-
filePath:
|
|
2580
|
+
enabled: eslintEnabled,
|
|
2581
|
+
filePath: import_node_path17.default.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
2507
2582
|
globalsPropValue: true
|
|
2508
2583
|
}
|
|
2509
2584
|
};
|
|
@@ -2514,15 +2589,15 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
2514
2589
|
}
|
|
2515
2590
|
async function resolveWxtModuleDir() {
|
|
2516
2591
|
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta.url).resolve;
|
|
2517
|
-
return
|
|
2592
|
+
return import_node_path17.default.resolve(requireResolve("wxt"), "../..");
|
|
2518
2593
|
}
|
|
2519
2594
|
async function isDirMissing(dir) {
|
|
2520
|
-
return !await
|
|
2595
|
+
return !await import_fs_extra10.default.exists(dir);
|
|
2521
2596
|
}
|
|
2522
2597
|
function logMissingDir(logger, name, expected) {
|
|
2523
2598
|
logger.warn(
|
|
2524
2599
|
`${name} directory not found: ./${normalizePath(
|
|
2525
|
-
|
|
2600
|
+
import_node_path17.default.relative(process.cwd(), expected)
|
|
2526
2601
|
)}`
|
|
2527
2602
|
);
|
|
2528
2603
|
}
|
|
@@ -2531,19 +2606,19 @@ var COMMAND_MODES = {
|
|
|
2531
2606
|
serve: "development"
|
|
2532
2607
|
};
|
|
2533
2608
|
async function mergeBuilderConfig(inlineConfig, userConfig) {
|
|
2534
|
-
const
|
|
2535
|
-
if (
|
|
2609
|
+
const vite2 = await import("vite").catch(() => void 0);
|
|
2610
|
+
if (vite2) {
|
|
2536
2611
|
return {
|
|
2537
2612
|
vite: async (env2) => {
|
|
2538
2613
|
const resolvedInlineConfig = await inlineConfig.vite?.(env2) ?? {};
|
|
2539
2614
|
const resolvedUserConfig = await userConfig.vite?.(env2) ?? {};
|
|
2540
|
-
return
|
|
2615
|
+
return vite2.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
|
|
2541
2616
|
}
|
|
2542
2617
|
};
|
|
2543
2618
|
}
|
|
2544
2619
|
throw Error("Builder not found. Make sure vite is installed.");
|
|
2545
2620
|
}
|
|
2546
|
-
async function
|
|
2621
|
+
async function resolveWxtUserModules(modulesDir, modules = []) {
|
|
2547
2622
|
const npmModules = await Promise.all(
|
|
2548
2623
|
modules.map(async (moduleId) => {
|
|
2549
2624
|
const mod = await import(
|
|
@@ -2560,13 +2635,13 @@ async function resolveWxtModules(modulesDir, modules = []) {
|
|
|
2560
2635
|
};
|
|
2561
2636
|
})
|
|
2562
2637
|
);
|
|
2563
|
-
const localModulePaths = await (0,
|
|
2638
|
+
const localModulePaths = await (0, import_fast_glob4.default)(["*.[tj]s", "*/index.[tj]s"], {
|
|
2564
2639
|
cwd: modulesDir,
|
|
2565
2640
|
onlyFiles: true
|
|
2566
2641
|
}).catch(() => []);
|
|
2567
2642
|
const localModules = await Promise.all(
|
|
2568
2643
|
localModulePaths.map(async (file) => {
|
|
2569
|
-
const absolutePath = normalizePath(
|
|
2644
|
+
const absolutePath = normalizePath(import_node_path17.default.resolve(modulesDir, file));
|
|
2570
2645
|
const { config } = await (0, import_c12.loadConfig)({
|
|
2571
2646
|
configFile: absolutePath,
|
|
2572
2647
|
globalRc: false,
|
|
@@ -2590,12 +2665,20 @@ async function resolveWxtModules(modulesDir, modules = []) {
|
|
|
2590
2665
|
return [...npmModules, ...localModules];
|
|
2591
2666
|
}
|
|
2592
2667
|
|
|
2668
|
+
// src/core/utils/building/import-entrypoint.ts
|
|
2669
|
+
var import_jiti = __toESM(require("jiti"), 1);
|
|
2670
|
+
var import_unimport3 = require("unimport");
|
|
2671
|
+
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
2672
|
+
var import_node_path18 = require("path");
|
|
2673
|
+
var import_esbuild = require("esbuild");
|
|
2674
|
+
var import_node_url = require("url");
|
|
2675
|
+
|
|
2593
2676
|
// src/core/utils/building/internal-build.ts
|
|
2594
2677
|
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
2595
2678
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
2596
2679
|
|
|
2597
2680
|
// src/core/utils/log/printFileList.ts
|
|
2598
|
-
var
|
|
2681
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
2599
2682
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
2600
2683
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
2601
2684
|
var import_filesize = require("filesize");
|
|
@@ -2616,26 +2699,34 @@ var CHUNK_COLORS = {
|
|
|
2616
2699
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
2617
2700
|
|
|
2618
2701
|
// src/core/utils/building/internal-build.ts
|
|
2619
|
-
var
|
|
2702
|
+
var import_fast_glob5 = __toESM(require("fast-glob"), 1);
|
|
2620
2703
|
|
|
2621
2704
|
// src/core/utils/manifest.ts
|
|
2622
2705
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
2623
2706
|
var import_defu2 = __toESM(require("defu"), 1);
|
|
2624
2707
|
|
|
2625
2708
|
// src/core/utils/building/internal-build.ts
|
|
2626
|
-
var
|
|
2709
|
+
var import_node_path20 = require("path");
|
|
2627
2710
|
var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
|
|
2628
2711
|
var import_ci_info = require("ci-info");
|
|
2629
2712
|
|
|
2630
2713
|
// src/testing/wxt-vitest-plugin.ts
|
|
2714
|
+
var import_unimport5 = require("unimport");
|
|
2631
2715
|
function WxtVitest(inlineConfig) {
|
|
2632
|
-
return resolveConfig(inlineConfig ?? {}, "serve").then((config) =>
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2716
|
+
return resolveConfig(inlineConfig ?? {}, "serve").then(async (config) => {
|
|
2717
|
+
const plugins = [
|
|
2718
|
+
webextensionPolyfillMock(config),
|
|
2719
|
+
globals(config),
|
|
2720
|
+
download(config),
|
|
2721
|
+
tsconfigPaths(config)
|
|
2722
|
+
];
|
|
2723
|
+
if (config.imports !== false) {
|
|
2724
|
+
const unimport = (0, import_unimport5.createUnimport)(config.imports);
|
|
2725
|
+
await unimport.init();
|
|
2726
|
+
plugins.push(vitePlugin(unimport));
|
|
2727
|
+
}
|
|
2728
|
+
return plugins;
|
|
2729
|
+
});
|
|
2639
2730
|
}
|
|
2640
2731
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2641
2732
|
0 && (module.exports = {
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './index-
|
|
3
|
+
import { I as InlineConfig } from './index-mz3v4Nde.cjs';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './index-
|
|
3
|
+
import { I as InlineConfig } from './index-mz3v4Nde.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
globals,
|
|
4
4
|
resolveConfig,
|
|
5
5
|
tsconfigPaths,
|
|
6
|
-
|
|
6
|
+
vitePlugin,
|
|
7
7
|
webextensionPolyfillMock
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2V7XZSZQ.js";
|
|
9
9
|
import "./chunk-BERPNPEZ.js";
|
|
10
|
+
import "./chunk-6XSIWUWF.js";
|
|
10
11
|
import "./chunk-BM6QYGAW.js";
|
|
11
12
|
import "./chunk-QGM4M3NI.js";
|
|
12
13
|
|
|
@@ -14,14 +15,22 @@ import "./chunk-QGM4M3NI.js";
|
|
|
14
15
|
import { fakeBrowser } from "@webext-core/fake-browser";
|
|
15
16
|
|
|
16
17
|
// src/testing/wxt-vitest-plugin.ts
|
|
18
|
+
import { createUnimport } from "unimport";
|
|
17
19
|
function WxtVitest(inlineConfig) {
|
|
18
|
-
return resolveConfig(inlineConfig ?? {}, "serve").then((config) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
return resolveConfig(inlineConfig ?? {}, "serve").then(async (config) => {
|
|
21
|
+
const plugins = [
|
|
22
|
+
webextensionPolyfillMock(config),
|
|
23
|
+
globals(config),
|
|
24
|
+
download(config),
|
|
25
|
+
tsconfigPaths(config)
|
|
26
|
+
];
|
|
27
|
+
if (config.imports !== false) {
|
|
28
|
+
const unimport = createUnimport(config.imports);
|
|
29
|
+
await unimport.init();
|
|
30
|
+
plugins.push(vitePlugin(unimport));
|
|
31
|
+
}
|
|
32
|
+
return plugins;
|
|
33
|
+
});
|
|
25
34
|
}
|
|
26
35
|
export {
|
|
27
36
|
WxtVitest,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.10",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -128,6 +128,7 @@
|
|
|
128
128
|
"publish-browser-extension": "^2.1.3",
|
|
129
129
|
"unimport": "^3.7.2",
|
|
130
130
|
"vite": "^5.3.0",
|
|
131
|
+
"vite-node": "^1.6.0",
|
|
131
132
|
"web-ext-run": "^0.2.0",
|
|
132
133
|
"webextension-polyfill": "^0.10.0"
|
|
133
134
|
},
|