wxt 0.18.9 → 0.18.11
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-6XSIWUWF.js +57 -0
- package/dist/{chunk-UA35R5HN.js → chunk-XNTIBS6O.js} +295 -202
- package/dist/cli.js +350 -238
- package/dist/{execa-D7CMCKO2.js → execa-4UBDUBJZ.js} +566 -478
- package/dist/{execa-ATHZH2Y4.js → execa-QLUM2B3W.js} +566 -478
- package/dist/{index-B0efqfEK.d.ts → index-CER9SLWP.d.cts} +69 -13
- package/dist/{index-B0efqfEK.d.cts → index-CER9SLWP.d.ts} +69 -13
- package/dist/index.cjs +1134 -913
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +18 -12
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/modules.js +8 -49
- package/dist/testing.cjs +253 -122
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +18 -9
- package/dist/virtual/background-entrypoint.js +9 -1
- package/package.json +9 -9
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");
|
|
@@ -2159,6 +2127,127 @@ var import_server = require("vite-node/server");
|
|
|
2159
2127
|
var import_client = require("vite-node/client");
|
|
2160
2128
|
var import_source_map = require("vite-node/source-map");
|
|
2161
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 === false) return;
|
|
2176
|
+
entries.push(
|
|
2177
|
+
await getEslintConfigEntry(unimport, options.eslintrc.enabled, options)
|
|
2178
|
+
);
|
|
2179
|
+
});
|
|
2180
|
+
addViteConfig(wxt2, () => ({
|
|
2181
|
+
plugins: [vitePlugin(unimport)]
|
|
2182
|
+
}));
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
function vitePlugin(unimport) {
|
|
2186
|
+
const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2187
|
+
".js",
|
|
2188
|
+
".jsx",
|
|
2189
|
+
".ts",
|
|
2190
|
+
".tsx",
|
|
2191
|
+
".vue",
|
|
2192
|
+
".svelte"
|
|
2193
|
+
]);
|
|
2194
|
+
return {
|
|
2195
|
+
name: "wxt:unimport",
|
|
2196
|
+
async transform(code, id) {
|
|
2197
|
+
if (id.includes("node_modules")) return;
|
|
2198
|
+
if (!ENABLED_EXTENSIONS.has((0, import_node_path10.extname)(id))) return;
|
|
2199
|
+
const injected = await unimport.injectImports(code, id);
|
|
2200
|
+
return {
|
|
2201
|
+
code: injected.code,
|
|
2202
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
async function getImportsDeclarationEntry(unimport) {
|
|
2208
|
+
await unimport.init();
|
|
2209
|
+
return {
|
|
2210
|
+
path: "types/imports.d.ts",
|
|
2211
|
+
text: [
|
|
2212
|
+
"// Generated by wxt",
|
|
2213
|
+
await unimport.generateTypeDeclarations(),
|
|
2214
|
+
""
|
|
2215
|
+
].join("\n"),
|
|
2216
|
+
tsReference: true
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
async function getEslintConfigEntry(unimport, version2, options) {
|
|
2220
|
+
const globals2 = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals3, name) => {
|
|
2221
|
+
globals3[name] = options.eslintrc.globalsPropValue;
|
|
2222
|
+
return globals3;
|
|
2223
|
+
}, {});
|
|
2224
|
+
if (version2 <= 8) return getEslint8ConfigEntry(options, globals2);
|
|
2225
|
+
else return getEslint9ConfigEntry(options, globals2);
|
|
2226
|
+
}
|
|
2227
|
+
function getEslint8ConfigEntry(options, globals2) {
|
|
2228
|
+
return {
|
|
2229
|
+
path: options.eslintrc.filePath,
|
|
2230
|
+
text: JSON.stringify({ globals: globals2 }, null, 2) + "\n"
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
function getEslint9ConfigEntry(options, globals2) {
|
|
2234
|
+
return {
|
|
2235
|
+
path: options.eslintrc.filePath,
|
|
2236
|
+
text: `const globals = ${JSON.stringify(globals2, null, 2)}
|
|
2237
|
+
|
|
2238
|
+
export default {
|
|
2239
|
+
languageOptions: {
|
|
2240
|
+
globals,
|
|
2241
|
+
sourceType: "module",
|
|
2242
|
+
},
|
|
2243
|
+
};
|
|
2244
|
+
`
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
// src/builtin-modules/index.ts
|
|
2249
|
+
var builtinModules = [unimport_default];
|
|
2250
|
+
|
|
2162
2251
|
// src/core/utils/fs.ts
|
|
2163
2252
|
async function writeFileIfDifferent(file, newContents) {
|
|
2164
2253
|
const existingContents = await import_fs_extra4.default.readFile(file, "utf-8").catch(() => void 0);
|
|
@@ -2176,7 +2265,7 @@ var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
|
2176
2265
|
var import_minimatch = require("minimatch");
|
|
2177
2266
|
var import_linkedom3 = require("linkedom");
|
|
2178
2267
|
var import_json5 = __toESM(require("json5"), 1);
|
|
2179
|
-
var
|
|
2268
|
+
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
2180
2269
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
2181
2270
|
var PATH_GLOB_TO_TYPE_MAP = {
|
|
2182
2271
|
"sandbox.html": "sandbox",
|
|
@@ -2219,23 +2308,23 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
2219
2308
|
};
|
|
2220
2309
|
|
|
2221
2310
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
2222
|
-
var import_unimport2 = require("unimport");
|
|
2223
2311
|
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
2224
|
-
var
|
|
2312
|
+
var import_node_path11 = require("path");
|
|
2313
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
2225
2314
|
|
|
2226
2315
|
// src/core/utils/building/resolve-config.ts
|
|
2227
2316
|
var import_c12 = require("c12");
|
|
2228
|
-
var
|
|
2317
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
2229
2318
|
|
|
2230
2319
|
// src/core/utils/cache.ts
|
|
2231
2320
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
2232
|
-
var
|
|
2321
|
+
var import_path = require("path");
|
|
2233
2322
|
function createFsCache(wxtDir) {
|
|
2234
|
-
const getPath = (key) => (0,
|
|
2323
|
+
const getPath = (key) => (0, import_path.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
2235
2324
|
return {
|
|
2236
2325
|
async set(key, value) {
|
|
2237
2326
|
const path8 = getPath(key);
|
|
2238
|
-
await (0, import_fs_extra8.ensureDir)((0,
|
|
2327
|
+
await (0, import_fs_extra8.ensureDir)((0, import_path.dirname)(path8));
|
|
2239
2328
|
await writeFileIfDifferent(path8, value);
|
|
2240
2329
|
},
|
|
2241
2330
|
async get(key) {
|
|
@@ -2257,25 +2346,29 @@ var import_node_process3 = require("process");
|
|
|
2257
2346
|
init_utils();
|
|
2258
2347
|
var import_node_tty2 = require("tty");
|
|
2259
2348
|
var import_node_util3 = require("util");
|
|
2260
|
-
var
|
|
2349
|
+
var import_node_path15 = require("path");
|
|
2261
2350
|
|
|
2262
2351
|
// src/core/utils/building/resolve-config.ts
|
|
2263
2352
|
var import_defu = __toESM(require("defu"), 1);
|
|
2264
|
-
|
|
2265
|
-
// src/core/utils/package.ts
|
|
2266
|
-
var import_node_path13 = require("path");
|
|
2267
2353
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2354
|
+
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
2355
|
+
|
|
2356
|
+
// src/core/utils/eslint.ts
|
|
2357
|
+
var import_meta = {};
|
|
2358
|
+
async function getEslintVersion() {
|
|
2359
|
+
try {
|
|
2360
|
+
const require2 = (await import("module")).default.createRequire(
|
|
2361
|
+
import_meta.url
|
|
2362
|
+
);
|
|
2363
|
+
const { ESLint } = require2("eslint");
|
|
2364
|
+
return ESLint.version?.split(".") ?? [];
|
|
2365
|
+
} catch (error) {
|
|
2366
|
+
return [];
|
|
2367
|
+
}
|
|
2273
2368
|
}
|
|
2274
2369
|
|
|
2275
2370
|
// src/core/utils/building/resolve-config.ts
|
|
2276
|
-
var
|
|
2277
|
-
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
2278
|
-
var import_meta = {};
|
|
2371
|
+
var import_meta2 = {};
|
|
2279
2372
|
async function resolveConfig(inlineConfig, command) {
|
|
2280
2373
|
let userConfig = {};
|
|
2281
2374
|
let userConfigMetadata;
|
|
@@ -2300,28 +2393,28 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2300
2393
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
2301
2394
|
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
2302
2395
|
const env2 = { browser, command, manifestVersion, mode };
|
|
2303
|
-
const root =
|
|
2396
|
+
const root = import_node_path16.default.resolve(
|
|
2304
2397
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
2305
2398
|
);
|
|
2306
|
-
const wxtDir =
|
|
2399
|
+
const wxtDir = import_node_path16.default.resolve(root, ".wxt");
|
|
2307
2400
|
const wxtModuleDir = await resolveWxtModuleDir();
|
|
2308
|
-
const srcDir =
|
|
2309
|
-
const entrypointsDir =
|
|
2401
|
+
const srcDir = import_node_path16.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
2402
|
+
const entrypointsDir = import_node_path16.default.resolve(
|
|
2310
2403
|
srcDir,
|
|
2311
2404
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
2312
2405
|
);
|
|
2313
|
-
const modulesDir =
|
|
2406
|
+
const modulesDir = import_node_path16.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
|
|
2314
2407
|
if (await isDirMissing(entrypointsDir)) {
|
|
2315
2408
|
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
2316
2409
|
}
|
|
2317
2410
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
2318
|
-
const publicDir =
|
|
2411
|
+
const publicDir = import_node_path16.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
2319
2412
|
if (await isDirMissing(publicDir)) {
|
|
2320
2413
|
logMissingDir(logger, "Public", publicDir);
|
|
2321
2414
|
}
|
|
2322
|
-
const typesDir =
|
|
2323
|
-
const outBaseDir =
|
|
2324
|
-
const outDir =
|
|
2415
|
+
const typesDir = import_node_path16.default.resolve(wxtDir, "types");
|
|
2416
|
+
const outBaseDir = import_node_path16.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
2417
|
+
const outDir = import_node_path16.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
2325
2418
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
2326
2419
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
2327
2420
|
name: "web-ext",
|
|
@@ -2338,7 +2431,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2338
2431
|
"~": srcDir,
|
|
2339
2432
|
"@@": root,
|
|
2340
2433
|
"~~": root
|
|
2341
|
-
}).map(([key, value]) => [key,
|
|
2434
|
+
}).map(([key, value]) => [key, import_node_path16.default.resolve(root, value)])
|
|
2342
2435
|
);
|
|
2343
2436
|
let devServerConfig;
|
|
2344
2437
|
if (command === "serve") {
|
|
@@ -2352,14 +2445,20 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2352
2445
|
hostname: "localhost"
|
|
2353
2446
|
};
|
|
2354
2447
|
}
|
|
2355
|
-
const
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2448
|
+
const userModules = await resolveWxtUserModules(
|
|
2449
|
+
modulesDir,
|
|
2450
|
+
mergedConfig.modules
|
|
2451
|
+
);
|
|
2452
|
+
const moduleOptions = userModules.reduce(
|
|
2453
|
+
(map, module2) => {
|
|
2454
|
+
if (module2.configKey) {
|
|
2455
|
+
map[module2.configKey] = // @ts-expect-error
|
|
2456
|
+
mergedConfig[module2.configKey];
|
|
2457
|
+
}
|
|
2458
|
+
return map;
|
|
2459
|
+
},
|
|
2460
|
+
{}
|
|
2461
|
+
);
|
|
2363
2462
|
return {
|
|
2364
2463
|
browser,
|
|
2365
2464
|
command,
|
|
@@ -2369,7 +2468,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2369
2468
|
filterEntrypoints,
|
|
2370
2469
|
env: env2,
|
|
2371
2470
|
fsCache: createFsCache(wxtDir),
|
|
2372
|
-
imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
|
|
2471
|
+
imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
|
|
2373
2472
|
logger,
|
|
2374
2473
|
manifest: await resolveManifestConfig(env2, mergedConfig.manifest),
|
|
2375
2474
|
manifestVersion,
|
|
@@ -2383,7 +2482,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2383
2482
|
srcDir,
|
|
2384
2483
|
typesDir,
|
|
2385
2484
|
wxtDir,
|
|
2386
|
-
zip: resolveZipConfig(root, mergedConfig),
|
|
2485
|
+
zip: resolveZipConfig(root, outBaseDir, mergedConfig),
|
|
2387
2486
|
transformManifest: mergedConfig.transformManifest,
|
|
2388
2487
|
analysis: resolveAnalysisConfig(root, mergedConfig),
|
|
2389
2488
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
@@ -2398,7 +2497,8 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2398
2497
|
},
|
|
2399
2498
|
hooks: mergedConfig.hooks ?? {},
|
|
2400
2499
|
vite: mergedConfig.vite ?? (() => ({})),
|
|
2401
|
-
|
|
2500
|
+
builtinModules,
|
|
2501
|
+
userModules,
|
|
2402
2502
|
plugins: [],
|
|
2403
2503
|
...moduleOptions
|
|
2404
2504
|
};
|
|
@@ -2427,8 +2527,8 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
2427
2527
|
...builderConfig
|
|
2428
2528
|
};
|
|
2429
2529
|
}
|
|
2430
|
-
function resolveZipConfig(root, mergedConfig) {
|
|
2431
|
-
const downloadedPackagesDir =
|
|
2530
|
+
function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
2531
|
+
const downloadedPackagesDir = import_node_path16.default.resolve(root, ".wxt/local_modules");
|
|
2432
2532
|
return {
|
|
2433
2533
|
name: void 0,
|
|
2434
2534
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -2446,6 +2546,8 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
2446
2546
|
// Tests
|
|
2447
2547
|
"**/__tests__/**",
|
|
2448
2548
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
2549
|
+
// Output directory
|
|
2550
|
+
`${import_node_path16.default.relative(root, outBaseDir)}/**`,
|
|
2449
2551
|
// From user
|
|
2450
2552
|
...mergedConfig.zip?.excludeSources ?? []
|
|
2451
2553
|
],
|
|
@@ -2454,12 +2556,12 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
2454
2556
|
};
|
|
2455
2557
|
}
|
|
2456
2558
|
function resolveAnalysisConfig(root, mergedConfig) {
|
|
2457
|
-
const analysisOutputFile =
|
|
2559
|
+
const analysisOutputFile = import_node_path16.default.resolve(
|
|
2458
2560
|
root,
|
|
2459
2561
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
2460
2562
|
);
|
|
2461
|
-
const analysisOutputDir =
|
|
2462
|
-
const analysisOutputName =
|
|
2563
|
+
const analysisOutputDir = import_node_path16.default.dirname(analysisOutputFile);
|
|
2564
|
+
const analysisOutputName = import_node_path16.default.parse(analysisOutputFile).name;
|
|
2463
2565
|
return {
|
|
2464
2566
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
2465
2567
|
open: mergedConfig.analysis?.open ?? false,
|
|
@@ -2470,18 +2572,8 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
2470
2572
|
keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
|
|
2471
2573
|
};
|
|
2472
2574
|
}
|
|
2473
|
-
async function getUnimportOptions(wxtDir, logger, config) {
|
|
2575
|
+
async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
2474
2576
|
if (config.imports === false) return false;
|
|
2475
|
-
const enabledConfig = config.imports?.eslintrc?.enabled;
|
|
2476
|
-
let enabled;
|
|
2477
|
-
switch (enabledConfig) {
|
|
2478
|
-
case void 0:
|
|
2479
|
-
case "auto":
|
|
2480
|
-
enabled = await isModuleInstalled("eslint");
|
|
2481
|
-
break;
|
|
2482
|
-
default:
|
|
2483
|
-
enabled = enabledConfig;
|
|
2484
|
-
}
|
|
2485
2577
|
const defaultOptions = {
|
|
2486
2578
|
debugLog: logger.debug,
|
|
2487
2579
|
imports: [
|
|
@@ -2496,28 +2588,53 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
2496
2588
|
],
|
|
2497
2589
|
warn: logger.warn,
|
|
2498
2590
|
dirs: ["components", "composables", "hooks", "utils"],
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
}
|
|
2591
|
+
dirsScanOptions: {
|
|
2592
|
+
cwd: srcDir
|
|
2593
|
+
},
|
|
2594
|
+
eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
|
|
2504
2595
|
};
|
|
2505
2596
|
return (0, import_defu.default)(
|
|
2506
2597
|
config.imports ?? {},
|
|
2507
2598
|
defaultOptions
|
|
2508
2599
|
);
|
|
2509
2600
|
}
|
|
2601
|
+
async function getUnimportEslintOptions(wxtDir, options) {
|
|
2602
|
+
const rawEslintEnabled = options?.enabled ?? "auto";
|
|
2603
|
+
let eslintEnabled;
|
|
2604
|
+
switch (rawEslintEnabled) {
|
|
2605
|
+
case "auto":
|
|
2606
|
+
const version2 = await getEslintVersion();
|
|
2607
|
+
let major = parseInt(version2[0]);
|
|
2608
|
+
if (major <= 8) eslintEnabled = 8;
|
|
2609
|
+
else if (major >= 9) eslintEnabled = 9;
|
|
2610
|
+
else eslintEnabled = 8;
|
|
2611
|
+
break;
|
|
2612
|
+
case true:
|
|
2613
|
+
eslintEnabled = 8;
|
|
2614
|
+
break;
|
|
2615
|
+
default:
|
|
2616
|
+
eslintEnabled = rawEslintEnabled;
|
|
2617
|
+
}
|
|
2618
|
+
return {
|
|
2619
|
+
enabled: eslintEnabled,
|
|
2620
|
+
filePath: import_node_path16.default.resolve(
|
|
2621
|
+
wxtDir,
|
|
2622
|
+
eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
|
|
2623
|
+
),
|
|
2624
|
+
globalsPropValue: true
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2510
2627
|
async function resolveWxtModuleDir() {
|
|
2511
|
-
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(
|
|
2512
|
-
return
|
|
2628
|
+
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta2.url).resolve;
|
|
2629
|
+
return import_node_path16.default.resolve(requireResolve("wxt"), "../..");
|
|
2513
2630
|
}
|
|
2514
2631
|
async function isDirMissing(dir) {
|
|
2515
|
-
return !await
|
|
2632
|
+
return !await import_fs_extra9.default.exists(dir);
|
|
2516
2633
|
}
|
|
2517
2634
|
function logMissingDir(logger, name, expected) {
|
|
2518
2635
|
logger.warn(
|
|
2519
2636
|
`${name} directory not found: ./${normalizePath(
|
|
2520
|
-
|
|
2637
|
+
import_node_path16.default.relative(process.cwd(), expected)
|
|
2521
2638
|
)}`
|
|
2522
2639
|
);
|
|
2523
2640
|
}
|
|
@@ -2526,19 +2643,19 @@ var COMMAND_MODES = {
|
|
|
2526
2643
|
serve: "development"
|
|
2527
2644
|
};
|
|
2528
2645
|
async function mergeBuilderConfig(inlineConfig, userConfig) {
|
|
2529
|
-
const
|
|
2530
|
-
if (
|
|
2646
|
+
const vite2 = await import("vite").catch(() => void 0);
|
|
2647
|
+
if (vite2) {
|
|
2531
2648
|
return {
|
|
2532
2649
|
vite: async (env2) => {
|
|
2533
2650
|
const resolvedInlineConfig = await inlineConfig.vite?.(env2) ?? {};
|
|
2534
2651
|
const resolvedUserConfig = await userConfig.vite?.(env2) ?? {};
|
|
2535
|
-
return
|
|
2652
|
+
return vite2.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
|
|
2536
2653
|
}
|
|
2537
2654
|
};
|
|
2538
2655
|
}
|
|
2539
2656
|
throw Error("Builder not found. Make sure vite is installed.");
|
|
2540
2657
|
}
|
|
2541
|
-
async function
|
|
2658
|
+
async function resolveWxtUserModules(modulesDir, modules = []) {
|
|
2542
2659
|
const npmModules = await Promise.all(
|
|
2543
2660
|
modules.map(async (moduleId) => {
|
|
2544
2661
|
const mod = await import(
|
|
@@ -2555,13 +2672,13 @@ async function resolveWxtModules(modulesDir, modules = []) {
|
|
|
2555
2672
|
};
|
|
2556
2673
|
})
|
|
2557
2674
|
);
|
|
2558
|
-
const localModulePaths = await (0,
|
|
2675
|
+
const localModulePaths = await (0, import_fast_glob4.default)(["*.[tj]s", "*/index.[tj]s"], {
|
|
2559
2676
|
cwd: modulesDir,
|
|
2560
2677
|
onlyFiles: true
|
|
2561
2678
|
}).catch(() => []);
|
|
2562
2679
|
const localModules = await Promise.all(
|
|
2563
2680
|
localModulePaths.map(async (file) => {
|
|
2564
|
-
const absolutePath = normalizePath(
|
|
2681
|
+
const absolutePath = normalizePath(import_node_path16.default.resolve(modulesDir, file));
|
|
2565
2682
|
const { config } = await (0, import_c12.loadConfig)({
|
|
2566
2683
|
configFile: absolutePath,
|
|
2567
2684
|
globalRc: false,
|
|
@@ -2588,8 +2705,8 @@ async function resolveWxtModules(modulesDir, modules = []) {
|
|
|
2588
2705
|
// src/core/utils/building/import-entrypoint.ts
|
|
2589
2706
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
2590
2707
|
var import_unimport3 = require("unimport");
|
|
2591
|
-
var
|
|
2592
|
-
var
|
|
2708
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
2709
|
+
var import_node_path17 = require("path");
|
|
2593
2710
|
var import_esbuild = require("esbuild");
|
|
2594
2711
|
var import_node_url = require("url");
|
|
2595
2712
|
|
|
@@ -2598,9 +2715,9 @@ var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
|
2598
2715
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
2599
2716
|
|
|
2600
2717
|
// src/core/utils/log/printFileList.ts
|
|
2601
|
-
var
|
|
2718
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
2602
2719
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
2603
|
-
var
|
|
2720
|
+
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
2604
2721
|
var import_filesize = require("filesize");
|
|
2605
2722
|
var DEFAULT_COLOR = import_picocolors3.default.blue;
|
|
2606
2723
|
var CHUNK_COLORS = {
|
|
@@ -2619,26 +2736,40 @@ var CHUNK_COLORS = {
|
|
|
2619
2736
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
2620
2737
|
|
|
2621
2738
|
// src/core/utils/building/internal-build.ts
|
|
2622
|
-
var
|
|
2739
|
+
var import_fast_glob5 = __toESM(require("fast-glob"), 1);
|
|
2623
2740
|
|
|
2624
2741
|
// src/core/utils/manifest.ts
|
|
2625
2742
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
2743
|
+
|
|
2744
|
+
// src/core/utils/package.ts
|
|
2745
|
+
var import_node_path19 = require("path");
|
|
2746
|
+
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
2747
|
+
|
|
2748
|
+
// src/core/utils/manifest.ts
|
|
2626
2749
|
var import_defu2 = __toESM(require("defu"), 1);
|
|
2627
2750
|
|
|
2628
2751
|
// src/core/utils/building/internal-build.ts
|
|
2629
|
-
var
|
|
2752
|
+
var import_node_path20 = require("path");
|
|
2630
2753
|
var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
|
|
2631
2754
|
var import_ci_info = require("ci-info");
|
|
2632
2755
|
|
|
2633
2756
|
// src/testing/wxt-vitest-plugin.ts
|
|
2757
|
+
var import_unimport5 = require("unimport");
|
|
2634
2758
|
function WxtVitest(inlineConfig) {
|
|
2635
|
-
return resolveConfig(inlineConfig ?? {}, "serve").then((config) =>
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2759
|
+
return resolveConfig(inlineConfig ?? {}, "serve").then(async (config) => {
|
|
2760
|
+
const plugins = [
|
|
2761
|
+
webextensionPolyfillMock(config),
|
|
2762
|
+
globals(config),
|
|
2763
|
+
download(config),
|
|
2764
|
+
tsconfigPaths(config)
|
|
2765
|
+
];
|
|
2766
|
+
if (config.imports !== false) {
|
|
2767
|
+
const unimport = (0, import_unimport5.createUnimport)(config.imports);
|
|
2768
|
+
await unimport.init();
|
|
2769
|
+
plugins.push(vitePlugin(unimport));
|
|
2770
|
+
}
|
|
2771
|
+
return plugins;
|
|
2772
|
+
});
|
|
2642
2773
|
}
|
|
2643
2774
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2644
2775
|
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-CER9SLWP.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-CER9SLWP.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|