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/cli.js CHANGED
@@ -12,7 +12,7 @@ import cac from "cac";
12
12
 
13
13
  // src/core/utils/fs.ts
14
14
  import fs3 from "fs-extra";
15
- import glob from "fast-glob";
15
+ import glob2 from "fast-glob";
16
16
 
17
17
  // src/core/utils/paths.ts
18
18
  import systemPath from "node:path";
@@ -46,7 +46,7 @@ var npm = {
46
46
  overridesKey: "overrides",
47
47
  async downloadDependency(id, downloadDir) {
48
48
  await ensureDir(downloadDir);
49
- const { execa } = await import("./execa-ATHZH2Y4.js");
49
+ const { execa } = await import("./execa-QLUM2B3W.js");
50
50
  const res = await execa("npm", ["pack", id, "--json"], {
51
51
  cwd: downloadDir
52
52
  });
@@ -58,7 +58,7 @@ var npm = {
58
58
  if (options?.all) {
59
59
  args.push("--depth", "Infinity");
60
60
  }
61
- const { execa } = await import("./execa-ATHZH2Y4.js");
61
+ const { execa } = await import("./execa-QLUM2B3W.js");
62
62
  const res = await execa("npm", args, { cwd: options?.cwd });
63
63
  const project = JSON.parse(res.stdout);
64
64
  return flattenNpmListOutput([project]);
@@ -111,7 +111,7 @@ var bun = {
111
111
  if (options?.all) {
112
112
  args.push("--all");
113
113
  }
114
- const { execa } = await import("./execa-ATHZH2Y4.js");
114
+ const { execa } = await import("./execa-QLUM2B3W.js");
115
115
  const res = await execa("bun", args, { cwd: options?.cwd });
116
116
  return dedupeDependencies(
117
117
  res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
@@ -130,7 +130,7 @@ var yarn = {
130
130
  if (options?.all) {
131
131
  args.push("--depth", "Infinity");
132
132
  }
133
- const { execa } = await import("./execa-ATHZH2Y4.js");
133
+ const { execa } = await import("./execa-QLUM2B3W.js");
134
134
  const res = await execa("yarn", args, { cwd: options?.cwd });
135
135
  const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
136
136
  if (tree == null) throw Error("'yarn list --json' did not output a tree");
@@ -166,7 +166,7 @@ var pnpm = {
166
166
  if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
167
167
  args.push("--ignore-workspace");
168
168
  }
169
- const { execa } = await import("./execa-ATHZH2Y4.js");
169
+ const { execa } = await import("./execa-QLUM2B3W.js");
170
170
  const res = await execa("pnpm", args, { cwd: options?.cwd });
171
171
  const projects = JSON.parse(res.stdout);
172
172
  return flattenNpmListOutput(projects);
@@ -548,38 +548,6 @@ async function removeEmptyDirs(dir) {
548
548
  }
549
549
  }
550
550
 
551
- // src/core/builders/vite/plugins/unimport.ts
552
- import { createUnimport } from "unimport";
553
- import { extname as extname2 } from "path";
554
- var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
555
- ".js",
556
- ".jsx",
557
- ".ts",
558
- ".tsx",
559
- ".vue",
560
- ".svelte"
561
- ]);
562
- function unimport(config) {
563
- const options = config.imports;
564
- if (options === false) return [];
565
- const unimport2 = createUnimport(options);
566
- return {
567
- name: "wxt:unimport",
568
- async config() {
569
- await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
570
- },
571
- async transform(code, id) {
572
- if (id.includes("node_modules")) return;
573
- if (!ENABLED_EXTENSIONS.has(extname2(id))) return;
574
- const injected = await unimport2.injectImports(code, id);
575
- return {
576
- code: injected.code,
577
- map: injected.s.generateMap({ hires: "boundary", source: id })
578
- };
579
- }
580
- };
581
- }
582
-
583
551
  // src/core/utils/virtual-modules.ts
584
552
  var virtualEntrypointTypes = [
585
553
  "content-script-main-world",
@@ -978,7 +946,7 @@ import { ViteNodeServer } from "vite-node/server";
978
946
  import { ViteNodeRunner } from "vite-node/client";
979
947
  import { installSourcemapsSupport } from "vite-node/source-map";
980
948
  async function createViteBuilder(wxtConfig, hooks, server) {
981
- const vite = await import("vite");
949
+ const vite2 = await import("vite");
982
950
  const getBaseConfig = async () => {
983
951
  const config = await wxtConfig.vite(wxtConfig.env);
984
952
  config.root = wxtConfig.root;
@@ -1000,7 +968,6 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1000
968
  config.plugins.push(
1001
969
  download(wxtConfig),
1002
970
  devHtmlPrerender(wxtConfig, server),
1003
- unimport(wxtConfig),
1004
971
  resolveVirtualModules(wxtConfig),
1005
972
  devServerGlobals(wxtConfig, server),
1006
973
  tsconfigPaths(wxtConfig),
@@ -1123,7 +1090,7 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1123
1090
  };
1124
1091
  return {
1125
1092
  name: "Vite",
1126
- version: vite.version,
1093
+ version: vite2.version,
1127
1094
  async importEntrypoint(path11) {
1128
1095
  switch (wxtConfig.experimental.entrypointImporter) {
1129
1096
  default:
@@ -1138,10 +1105,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1138
1105
  removeEntrypointMainFunction(wxtConfig, path11)
1139
1106
  ]
1140
1107
  };
1141
- const config = vite.mergeConfig(baseConfig, envConfig);
1142
- const server2 = await vite.createServer(config);
1108
+ const config = vite2.mergeConfig(baseConfig, envConfig);
1109
+ const server2 = await vite2.createServer(config);
1143
1110
  await server2.listen();
1144
- const runtime = await vite.createViteRuntime(server2, { hmr: false });
1111
+ const runtime = await vite2.createViteRuntime(server2, { hmr: false });
1145
1112
  const module = await runtime.executeUrl(path11);
1146
1113
  await server2.close();
1147
1114
  return module.default;
@@ -1157,10 +1124,13 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1157
1124
  removeEntrypointMainFunction(wxtConfig, path11)
1158
1125
  ]
1159
1126
  };
1160
- const config = vite.mergeConfig(baseConfig, envConfig);
1161
- const server2 = await vite.createServer(config);
1127
+ const config = vite2.mergeConfig(baseConfig, envConfig);
1128
+ const server2 = await vite2.createServer(config);
1162
1129
  await server2.pluginContainer.buildStart({});
1163
- const node = new ViteNodeServer(server2);
1130
+ const node = new ViteNodeServer(
1131
+ // @ts-ignore: Some weird type error...
1132
+ server2
1133
+ );
1164
1134
  installSourcemapsSupport({
1165
1135
  getSourceMap: (source) => node.getSourceMap(source)
1166
1136
  });
@@ -1189,13 +1159,13 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1189
1159
  else if (group.inputPath.endsWith(".css"))
1190
1160
  entryConfig = getCssConfig(group);
1191
1161
  else entryConfig = getLibModeConfig(group);
1192
- const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
1162
+ const buildConfig = vite2.mergeConfig(await getBaseConfig(), entryConfig);
1193
1163
  await hooks.callHook(
1194
1164
  "vite:build:extendConfig",
1195
1165
  toArray(group),
1196
1166
  buildConfig
1197
1167
  );
1198
- const result = await vite.build(buildConfig);
1168
+ const result = await vite2.build(buildConfig);
1199
1169
  return {
1200
1170
  entrypoints: group,
1201
1171
  chunks: getBuildOutputChunks(result)
@@ -1211,9 +1181,9 @@ async function createViteBuilder(wxtConfig, hooks, server) {
1211
1181
  }
1212
1182
  };
1213
1183
  const baseConfig = await getBaseConfig();
1214
- const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
1184
+ const finalConfig = vite2.mergeConfig(baseConfig, serverConfig);
1215
1185
  await hooks.callHook("vite:devServer:extendConfig", finalConfig);
1216
- const viteServer = await vite.createServer(finalConfig);
1186
+ const viteServer = await vite2.createServer(finalConfig);
1217
1187
  const server2 = {
1218
1188
  async listen() {
1219
1189
  await viteServer.listen(info.port);
@@ -1261,6 +1231,126 @@ function getRollupEntry(entrypoint) {
1261
1231
  return entrypoint.inputPath;
1262
1232
  }
1263
1233
 
1234
+ // src/modules.ts
1235
+ import * as vite from "vite";
1236
+ import glob from "fast-glob";
1237
+ function defineWxtModule(module) {
1238
+ if (typeof module === "function") return { setup: module };
1239
+ return module;
1240
+ }
1241
+ function addViteConfig(wxt2, viteConfig) {
1242
+ wxt2.hooks.hook("ready", (wxt3) => {
1243
+ const userVite = wxt3.config.vite;
1244
+ wxt3.config.vite = async (env) => {
1245
+ const fromUser = await userVite(env);
1246
+ const fromModule = viteConfig(env) ?? {};
1247
+ return vite.mergeConfig(fromModule, fromUser);
1248
+ };
1249
+ });
1250
+ }
1251
+
1252
+ // src/builtin-modules/unimport.ts
1253
+ import { createUnimport } from "unimport";
1254
+ import { extname as extname2 } from "node:path";
1255
+ var unimport_default = defineWxtModule({
1256
+ name: "wxt:built-in:unimport",
1257
+ setup(wxt2) {
1258
+ const options = wxt2.config.imports;
1259
+ if (options === false) return;
1260
+ let unimport;
1261
+ wxt2.hooks.hook("ready", () => {
1262
+ const addModuleImports = (module) => {
1263
+ if (!module.imports) return;
1264
+ options.imports ??= [];
1265
+ options.imports.push(...module.imports);
1266
+ };
1267
+ wxt2.config.builtinModules.forEach(addModuleImports);
1268
+ wxt2.config.userModules.forEach(addModuleImports);
1269
+ });
1270
+ wxt2.hooks.afterEach((event) => {
1271
+ if (event.name === "ready") {
1272
+ unimport = createUnimport(options);
1273
+ }
1274
+ });
1275
+ wxt2.hooks.hook("prepare:types", async (_, entries) => {
1276
+ await unimport.init();
1277
+ entries.push(await getImportsDeclarationEntry(unimport));
1278
+ if (options.eslintrc.enabled === false) return;
1279
+ entries.push(
1280
+ await getEslintConfigEntry(unimport, options.eslintrc.enabled, options)
1281
+ );
1282
+ });
1283
+ addViteConfig(wxt2, () => ({
1284
+ plugins: [vitePlugin(unimport)]
1285
+ }));
1286
+ }
1287
+ });
1288
+ function vitePlugin(unimport) {
1289
+ const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
1290
+ ".js",
1291
+ ".jsx",
1292
+ ".ts",
1293
+ ".tsx",
1294
+ ".vue",
1295
+ ".svelte"
1296
+ ]);
1297
+ return {
1298
+ name: "wxt:unimport",
1299
+ async transform(code, id) {
1300
+ if (id.includes("node_modules")) return;
1301
+ if (!ENABLED_EXTENSIONS.has(extname2(id))) return;
1302
+ const injected = await unimport.injectImports(code, id);
1303
+ return {
1304
+ code: injected.code,
1305
+ map: injected.s.generateMap({ hires: "boundary", source: id })
1306
+ };
1307
+ }
1308
+ };
1309
+ }
1310
+ async function getImportsDeclarationEntry(unimport) {
1311
+ await unimport.init();
1312
+ return {
1313
+ path: "types/imports.d.ts",
1314
+ text: [
1315
+ "// Generated by wxt",
1316
+ await unimport.generateTypeDeclarations(),
1317
+ ""
1318
+ ].join("\n"),
1319
+ tsReference: true
1320
+ };
1321
+ }
1322
+ async function getEslintConfigEntry(unimport, version2, options) {
1323
+ const globals2 = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals3, name) => {
1324
+ globals3[name] = options.eslintrc.globalsPropValue;
1325
+ return globals3;
1326
+ }, {});
1327
+ if (version2 <= 8) return getEslint8ConfigEntry(options, globals2);
1328
+ else return getEslint9ConfigEntry(options, globals2);
1329
+ }
1330
+ function getEslint8ConfigEntry(options, globals2) {
1331
+ return {
1332
+ path: options.eslintrc.filePath,
1333
+ text: JSON.stringify({ globals: globals2 }, null, 2) + "\n"
1334
+ };
1335
+ }
1336
+ function getEslint9ConfigEntry(options, globals2) {
1337
+ return {
1338
+ path: options.eslintrc.filePath,
1339
+ text: `const globals = ${JSON.stringify(globals2, null, 2)}
1340
+
1341
+ export default {
1342
+ languageOptions: {
1343
+ globals,
1344
+ sourceType: "module",
1345
+ },
1346
+ };
1347
+ `
1348
+ };
1349
+ }
1350
+
1351
+ // src/builtin-modules/index.ts
1352
+ var builtinModules = [unimport_default];
1353
+
1264
1354
  // src/core/wxt.ts
1265
1355
  var wxt;
1266
1356
  async function registerWxt(command, inlineConfig = {}, getServer) {
@@ -1282,18 +1372,16 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
1282
1372
  builder,
1283
1373
  server
1284
1374
  };
1285
- for (const module of config.modules) {
1375
+ const initModule = async (module) => {
1286
1376
  if (module.hooks) wxt.hooks.addHooks(module.hooks);
1287
- if (wxt.config.imports !== false && module.imports) {
1288
- wxt.config.imports.imports ??= [];
1289
- wxt.config.imports.imports.push(...module.imports);
1290
- }
1291
1377
  await module.setup?.(
1292
1378
  wxt,
1293
1379
  // @ts-expect-error: Untyped configKey field
1294
1380
  module.configKey ? config[module.configKey] : void 0
1295
1381
  );
1296
- }
1382
+ };
1383
+ for (const builtinModule of builtinModules) await initModule(builtinModule);
1384
+ for (const userModule of config.userModules) await initModule(userModule);
1297
1385
  wxt.hooks.addHooks(config.hooks);
1298
1386
  await wxt.hooks.callHook("ready", wxt);
1299
1387
  }
@@ -1307,7 +1395,7 @@ async function writeFileIfDifferent(file, newContents) {
1307
1395
  }
1308
1396
  async function getPublicFiles() {
1309
1397
  if (!await fs3.exists(wxt.config.publicDir)) return [];
1310
- const files = await glob("**/*", { cwd: wxt.config.publicDir });
1398
+ const files = await glob2("**/*", { cwd: wxt.config.publicDir });
1311
1399
  return files.map(unnormalizePath);
1312
1400
  }
1313
1401
 
@@ -1341,13 +1429,17 @@ async function copyPublicDirectory() {
1341
1429
  await wxt.hooks.callHook("build:publicAssets", wxt, files);
1342
1430
  if (files.length === 0) return [];
1343
1431
  const publicAssets = [];
1344
- for (const { absoluteSrc, relativeDest } of files) {
1345
- const absoluteDest = resolve6(wxt.config.outDir, relativeDest);
1432
+ for (const file of files) {
1433
+ const absoluteDest = resolve6(wxt.config.outDir, file.relativeDest);
1346
1434
  await fs4.ensureDir(dirname3(absoluteDest));
1347
- await fs4.copyFile(absoluteSrc, absoluteDest);
1435
+ if ("absoluteSrc" in file) {
1436
+ await fs4.copyFile(file.absoluteSrc, absoluteDest);
1437
+ } else {
1438
+ await fs4.writeFile(absoluteDest, file.contents, "utf8");
1439
+ }
1348
1440
  publicAssets.push({
1349
1441
  type: "asset",
1350
- fileName: relativeDest
1442
+ fileName: file.relativeDest
1351
1443
  });
1352
1444
  }
1353
1445
  return publicAssets;
@@ -1451,12 +1543,12 @@ import fs5 from "fs-extra";
1451
1543
  import { minimatch } from "minimatch";
1452
1544
  import { parseHTML as parseHTML3 } from "linkedom";
1453
1545
  import JSON5 from "json5";
1454
- import glob2 from "fast-glob";
1546
+ import glob3 from "fast-glob";
1455
1547
  import pc2 from "picocolors";
1456
1548
  async function findEntrypoints() {
1457
1549
  await fs5.mkdir(wxt.config.wxtDir, { recursive: true });
1458
1550
  await fs5.writeJson(resolve7(wxt.config.wxtDir, "tsconfig.json"), {});
1459
- const relativePaths = await glob2(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
1551
+ const relativePaths = await glob3(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
1460
1552
  cwd: wxt.config.entrypointsDir
1461
1553
  });
1462
1554
  relativePaths.sort();
@@ -1465,7 +1557,7 @@ async function findEntrypoints() {
1465
1557
  const inputPath = resolve7(wxt.config.entrypointsDir, relativePath);
1466
1558
  const name = getEntrypointName(wxt.config.entrypointsDir, inputPath);
1467
1559
  const matchingGlob = pathGlobs.find(
1468
- (glob7) => minimatch(relativePath, glob7)
1560
+ (glob8) => minimatch(relativePath, glob8)
1469
1561
  );
1470
1562
  if (matchingGlob) {
1471
1563
  const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
@@ -1826,9 +1918,8 @@ var PATH_GLOB_TO_TYPE_MAP = {
1826
1918
  var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
1827
1919
 
1828
1920
  // src/core/utils/building/generate-wxt-dir.ts
1829
- import { createUnimport as createUnimport2 } from "unimport";
1830
1921
  import fs6 from "fs-extra";
1831
- import { relative as relative4, resolve as resolve8 } from "path";
1922
+ import { dirname as dirname4, relative as relative4, resolve as resolve8 } from "node:path";
1832
1923
  import path5 from "node:path";
1833
1924
 
1834
1925
  // src/core/utils/i18n.ts
@@ -1871,41 +1962,32 @@ function parseI18nMessages(messagesJson) {
1871
1962
  // src/core/utils/building/generate-wxt-dir.ts
1872
1963
  async function generateTypesDir(entrypoints) {
1873
1964
  await fs6.ensureDir(wxt.config.typesDir);
1874
- const references = [];
1875
- if (wxt.config.imports !== false) {
1876
- const unimport2 = createUnimport2(wxt.config.imports);
1877
- references.push(await writeImportsDeclarationFile(unimport2));
1878
- if (wxt.config.imports.eslintrc.enabled) {
1879
- await writeImportsEslintFile(unimport2, wxt.config.imports);
1880
- }
1881
- }
1882
- references.push(await writePathsDeclarationFile(entrypoints));
1883
- references.push(await writeI18nDeclarationFile());
1884
- references.push(await writeGlobalsDeclarationFile());
1885
- const mainReference = await writeMainDeclarationFile(references);
1886
- await writeTsConfigFile(mainReference);
1887
- }
1888
- async function writeImportsDeclarationFile(unimport2) {
1889
- const filePath = resolve8(wxt.config.typesDir, "imports.d.ts");
1890
- await unimport2.scanImportsFromDir(void 0, { cwd: wxt.config.srcDir });
1891
- await writeFileIfDifferent(
1892
- filePath,
1893
- ["// Generated by wxt", await unimport2.generateTypeDeclarations()].join(
1894
- "\n"
1895
- ) + "\n"
1896
- );
1897
- return filePath;
1898
- }
1899
- async function writeImportsEslintFile(unimport2, options) {
1900
- const globals2 = {};
1901
- const eslintrc = { globals: globals2 };
1902
- (await unimport2.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => {
1903
- eslintrc.globals[name] = options.eslintrc.globalsPropValue;
1965
+ const entries = [
1966
+ // Hard-coded entries
1967
+ { module: "wxt/vite-builder-env" }
1968
+ ];
1969
+ wxt.config.userModules.forEach((module) => {
1970
+ if (module.type === "node_module" && module.configKey != null)
1971
+ entries.push({ module: module.id });
1904
1972
  });
1905
- await fs6.writeJson(options.eslintrc.filePath, eslintrc, { spaces: 2 });
1973
+ entries.push(await getPathsDeclarationEntry(entrypoints));
1974
+ entries.push(await getI18nDeclarationEntry());
1975
+ entries.push(await getGlobalsDeclarationEntry());
1976
+ entries.push(await getTsConfigEntry());
1977
+ await wxt.hooks.callHook("prepare:types", wxt, entries);
1978
+ entries.push(getMainDeclarationEntry(entries));
1979
+ const absoluteFileEntries = entries.filter((entry) => "path" in entry).map((entry) => ({
1980
+ ...entry,
1981
+ path: resolve8(wxt.config.wxtDir, entry.path)
1982
+ }));
1983
+ await Promise.all(
1984
+ absoluteFileEntries.map(async (file) => {
1985
+ await fs6.ensureDir(dirname4(file.path));
1986
+ await writeFileIfDifferent(file.path, file.text);
1987
+ })
1988
+ );
1906
1989
  }
1907
- async function writePathsDeclarationFile(entrypoints) {
1908
- const filePath = resolve8(wxt.config.typesDir, "paths.d.ts");
1990
+ async function getPathsDeclarationEntry(entrypoints) {
1909
1991
  const unions = entrypoints.map(
1910
1992
  (entry) => getEntrypointBundlePath(
1911
1993
  entry,
@@ -1926,14 +2008,13 @@ declare module "wxt/browser" {
1926
2008
  }
1927
2009
  }
1928
2010
  `;
1929
- await writeFileIfDifferent(
1930
- filePath,
1931
- template.replace("{{ union }}", unions || " | never")
1932
- );
1933
- return filePath;
2011
+ return {
2012
+ path: "types/paths.d.ts",
2013
+ text: template.replace("{{ union }}", unions || " | never"),
2014
+ tsReference: true
2015
+ };
1934
2016
  }
1935
- async function writeI18nDeclarationFile() {
1936
- const filePath = resolve8(wxt.config.typesDir, "i18n.d.ts");
2017
+ async function getI18nDeclarationEntry() {
1937
2018
  const defaultLocale = wxt.config.manifest.default_locale;
1938
2019
  const template = `// Generated by wxt
1939
2020
  import "wxt/browser";
@@ -1979,18 +2060,17 @@ declare module "wxt/browser" {
1979
2060
  options?: GetMessageOptions,
1980
2061
  ): string;`;
1981
2062
  });
1982
- await writeFileIfDifferent(
1983
- filePath,
1984
- template.replace("{{ overrides }}", overrides.join("\n"))
1985
- );
1986
- return filePath;
2063
+ return {
2064
+ path: "types/i18n.d.ts",
2065
+ text: template.replace("{{ overrides }}", overrides.join("\n")),
2066
+ tsReference: true
2067
+ };
1987
2068
  }
1988
- async function writeGlobalsDeclarationFile() {
1989
- const filePath = resolve8(wxt.config.typesDir, "globals.d.ts");
2069
+ async function getGlobalsDeclarationEntry() {
1990
2070
  const globals2 = [...getGlobals(wxt.config), ...getEntrypointGlobals("")];
1991
- await writeFileIfDifferent(
1992
- filePath,
1993
- [
2071
+ return {
2072
+ path: "types/globals.d.ts",
2073
+ text: [
1994
2074
  "// Generated by wxt",
1995
2075
  "export {}",
1996
2076
  "interface ImportMetaEnv {",
@@ -1998,34 +2078,29 @@ async function writeGlobalsDeclarationFile() {
1998
2078
  "}",
1999
2079
  "interface ImportMeta {",
2000
2080
  " readonly env: ImportMetaEnv",
2001
- "}"
2002
- ].join("\n") + "\n"
2003
- );
2004
- return filePath;
2081
+ "}",
2082
+ ""
2083
+ ].join("\n"),
2084
+ tsReference: true
2085
+ };
2005
2086
  }
2006
- async function writeMainDeclarationFile(references) {
2007
- const dir = wxt.config.wxtDir;
2008
- const filePath = resolve8(dir, "wxt.d.ts");
2009
- await writeFileIfDifferent(
2010
- filePath,
2011
- [
2012
- "// Generated by wxt",
2013
- `/// <reference types="wxt/vite-builder-env" />`,
2014
- ...references.map(
2015
- (ref) => `/// <reference types="./${normalizePath(relative4(dir, ref))}" />`
2016
- ),
2017
- // Add references to modules installed from NPM to the TS project so
2018
- // their type augmentation can update InlineConfig correctly. Local
2019
- // modules defined in <root>/modules are already apart of the project, so
2020
- // we don't need to add them.
2021
- ...wxt.config.modules.filter(
2022
- (module) => module.type === "node_module" && module.configKey != null
2023
- ).map((module) => `/// <reference types="${module.id}" />`)
2024
- ].join("\n") + "\n"
2025
- );
2026
- return filePath;
2087
+ function getMainDeclarationEntry(references) {
2088
+ const lines = ["// Generated by wxt"];
2089
+ references.forEach((ref) => {
2090
+ if ("module" in ref) {
2091
+ return lines.push(`/// <reference types="${ref.module}" />`);
2092
+ } else if (ref.tsReference) {
2093
+ const absolutePath = resolve8(wxt.config.wxtDir, ref.path);
2094
+ const relativePath = relative4(wxt.config.wxtDir, absolutePath);
2095
+ lines.push(`/// <reference types="./${normalizePath(relativePath)}" />`);
2096
+ }
2097
+ });
2098
+ return {
2099
+ path: "wxt.d.ts",
2100
+ text: lines.join("\n") + "\n"
2101
+ };
2027
2102
  }
2028
- async function writeTsConfigFile(mainReference) {
2103
+ async function getTsConfigEntry() {
2029
2104
  const dir = wxt.config.wxtDir;
2030
2105
  const getTsconfigPath = (path11) => normalizePath(relative4(dir, path11));
2031
2106
  const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
@@ -2035,9 +2110,7 @@ async function writeTsConfigFile(mainReference) {
2035
2110
  ` "${alias}/*": ["${aliasPath}/*"]`
2036
2111
  ];
2037
2112
  }).join(",\n");
2038
- await writeFileIfDifferent(
2039
- resolve8(dir, "tsconfig.json"),
2040
- `{
2113
+ const text = `{
2041
2114
  "compilerOptions": {
2042
2115
  "target": "ESNext",
2043
2116
  "module": "ESNext",
@@ -2054,11 +2127,14 @@ ${paths}
2054
2127
  },
2055
2128
  "include": [
2056
2129
  "${getTsconfigPath(wxt.config.root)}/**/*",
2057
- "./${getTsconfigPath(mainReference)}"
2130
+ "./wxt.d.ts"
2058
2131
  ],
2059
2132
  "exclude": ["${getTsconfigPath(wxt.config.outBaseDir)}"]
2060
- }`
2061
- );
2133
+ }`;
2134
+ return {
2135
+ path: "tsconfig.json",
2136
+ text
2137
+ };
2062
2138
  }
2063
2139
 
2064
2140
  // src/core/utils/building/resolve-config.ts
@@ -2067,13 +2143,13 @@ import path6 from "node:path";
2067
2143
 
2068
2144
  // src/core/utils/cache.ts
2069
2145
  import fs7, { ensureDir as ensureDir3 } from "fs-extra";
2070
- import { dirname as dirname4, resolve as resolve9 } from "path";
2146
+ import { dirname as dirname5, resolve as resolve9 } from "path";
2071
2147
  function createFsCache(wxtDir) {
2072
2148
  const getPath = (key) => resolve9(wxtDir, "cache", encodeURIComponent(key));
2073
2149
  return {
2074
2150
  async set(key, value) {
2075
2151
  const path11 = getPath(key);
2076
- await ensureDir3(dirname4(path11));
2152
+ await ensureDir3(dirname5(path11));
2077
2153
  await writeFileIfDifferent(path11, value);
2078
2154
  },
2079
2155
  async get(key) {
@@ -2089,31 +2165,23 @@ function createFsCache(wxtDir) {
2089
2165
 
2090
2166
  // src/core/utils/building/resolve-config.ts
2091
2167
  import defu from "defu";
2092
-
2093
- // src/core/utils/package.ts
2094
- import { resolve as resolve10 } from "node:path";
2095
2168
  import fs8 from "fs-extra";
2096
- async function getPackageJson() {
2097
- const file = resolve10(wxt.config.root, "package.json");
2169
+ import glob4 from "fast-glob";
2170
+
2171
+ // src/core/utils/eslint.ts
2172
+ async function getEslintVersion() {
2098
2173
  try {
2099
- return await fs8.readJson(file);
2100
- } catch (err) {
2101
- wxt.logger.debug(
2102
- `Failed to read package.json at: ${file}. Returning undefined.`
2174
+ const require2 = (await import("node:module")).default.createRequire(
2175
+ import.meta.url
2103
2176
  );
2104
- return {};
2177
+ const { ESLint } = require2("eslint");
2178
+ return ESLint.version?.split(".") ?? [];
2179
+ } catch (error) {
2180
+ return [];
2105
2181
  }
2106
2182
  }
2107
- function isModuleInstalled(name) {
2108
- return import(
2109
- /* @vite-ignore */
2110
- name
2111
- ).then(() => true).catch(() => false);
2112
- }
2113
2183
 
2114
2184
  // src/core/utils/building/resolve-config.ts
2115
- import fs9 from "fs-extra";
2116
- import glob3 from "fast-glob";
2117
2185
  async function resolveConfig(inlineConfig, command) {
2118
2186
  let userConfig = {};
2119
2187
  let userConfigMetadata;
@@ -2190,14 +2258,20 @@ async function resolveConfig(inlineConfig, command) {
2190
2258
  hostname: "localhost"
2191
2259
  };
2192
2260
  }
2193
- const modules = await resolveWxtModules(modulesDir, mergedConfig.modules);
2194
- const moduleOptions = modules.reduce((map, module) => {
2195
- if (module.configKey) {
2196
- map[module.configKey] = // @ts-expect-error
2197
- mergedConfig[module.configKey];
2198
- }
2199
- return map;
2200
- }, {});
2261
+ const userModules = await resolveWxtUserModules(
2262
+ modulesDir,
2263
+ mergedConfig.modules
2264
+ );
2265
+ const moduleOptions = userModules.reduce(
2266
+ (map, module) => {
2267
+ if (module.configKey) {
2268
+ map[module.configKey] = // @ts-expect-error
2269
+ mergedConfig[module.configKey];
2270
+ }
2271
+ return map;
2272
+ },
2273
+ {}
2274
+ );
2201
2275
  return {
2202
2276
  browser,
2203
2277
  command,
@@ -2207,7 +2281,7 @@ async function resolveConfig(inlineConfig, command) {
2207
2281
  filterEntrypoints,
2208
2282
  env,
2209
2283
  fsCache: createFsCache(wxtDir),
2210
- imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
2284
+ imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
2211
2285
  logger,
2212
2286
  manifest: await resolveManifestConfig(env, mergedConfig.manifest),
2213
2287
  manifestVersion,
@@ -2221,7 +2295,7 @@ async function resolveConfig(inlineConfig, command) {
2221
2295
  srcDir,
2222
2296
  typesDir,
2223
2297
  wxtDir,
2224
- zip: resolveZipConfig(root, mergedConfig),
2298
+ zip: resolveZipConfig(root, outBaseDir, mergedConfig),
2225
2299
  transformManifest: mergedConfig.transformManifest,
2226
2300
  analysis: resolveAnalysisConfig(root, mergedConfig),
2227
2301
  userConfigMetadata: userConfigMetadata ?? {},
@@ -2236,7 +2310,8 @@ async function resolveConfig(inlineConfig, command) {
2236
2310
  },
2237
2311
  hooks: mergedConfig.hooks ?? {},
2238
2312
  vite: mergedConfig.vite ?? (() => ({})),
2239
- modules,
2313
+ builtinModules,
2314
+ userModules,
2240
2315
  plugins: [],
2241
2316
  ...moduleOptions
2242
2317
  };
@@ -2265,7 +2340,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
2265
2340
  ...builderConfig
2266
2341
  };
2267
2342
  }
2268
- function resolveZipConfig(root, mergedConfig) {
2343
+ function resolveZipConfig(root, outBaseDir, mergedConfig) {
2269
2344
  const downloadedPackagesDir = path6.resolve(root, ".wxt/local_modules");
2270
2345
  return {
2271
2346
  name: void 0,
@@ -2284,6 +2359,8 @@ function resolveZipConfig(root, mergedConfig) {
2284
2359
  // Tests
2285
2360
  "**/__tests__/**",
2286
2361
  "**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
2362
+ // Output directory
2363
+ `${path6.relative(root, outBaseDir)}/**`,
2287
2364
  // From user
2288
2365
  ...mergedConfig.zip?.excludeSources ?? []
2289
2366
  ],
@@ -2308,18 +2385,8 @@ function resolveAnalysisConfig(root, mergedConfig) {
2308
2385
  keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
2309
2386
  };
2310
2387
  }
2311
- async function getUnimportOptions(wxtDir, logger, config) {
2388
+ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
2312
2389
  if (config.imports === false) return false;
2313
- const enabledConfig = config.imports?.eslintrc?.enabled;
2314
- let enabled;
2315
- switch (enabledConfig) {
2316
- case void 0:
2317
- case "auto":
2318
- enabled = await isModuleInstalled("eslint");
2319
- break;
2320
- default:
2321
- enabled = enabledConfig;
2322
- }
2323
2390
  const defaultOptions = {
2324
2391
  debugLog: logger.debug,
2325
2392
  imports: [
@@ -2334,23 +2401,48 @@ async function getUnimportOptions(wxtDir, logger, config) {
2334
2401
  ],
2335
2402
  warn: logger.warn,
2336
2403
  dirs: ["components", "composables", "hooks", "utils"],
2337
- eslintrc: {
2338
- enabled,
2339
- filePath: path6.resolve(wxtDir, "eslintrc-auto-import.json"),
2340
- globalsPropValue: true
2341
- }
2404
+ dirsScanOptions: {
2405
+ cwd: srcDir
2406
+ },
2407
+ eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
2342
2408
  };
2343
2409
  return defu(
2344
2410
  config.imports ?? {},
2345
2411
  defaultOptions
2346
2412
  );
2347
2413
  }
2414
+ async function getUnimportEslintOptions(wxtDir, options) {
2415
+ const rawEslintEnabled = options?.enabled ?? "auto";
2416
+ let eslintEnabled;
2417
+ switch (rawEslintEnabled) {
2418
+ case "auto":
2419
+ const version2 = await getEslintVersion();
2420
+ let major = parseInt(version2[0]);
2421
+ if (major <= 8) eslintEnabled = 8;
2422
+ else if (major >= 9) eslintEnabled = 9;
2423
+ else eslintEnabled = 8;
2424
+ break;
2425
+ case true:
2426
+ eslintEnabled = 8;
2427
+ break;
2428
+ default:
2429
+ eslintEnabled = rawEslintEnabled;
2430
+ }
2431
+ return {
2432
+ enabled: eslintEnabled,
2433
+ filePath: path6.resolve(
2434
+ wxtDir,
2435
+ eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
2436
+ ),
2437
+ globalsPropValue: true
2438
+ };
2439
+ }
2348
2440
  async function resolveWxtModuleDir() {
2349
2441
  const requireResolve = __require?.resolve ?? (await import("node:module")).default.createRequire(import.meta.url).resolve;
2350
2442
  return path6.resolve(requireResolve("wxt"), "../..");
2351
2443
  }
2352
2444
  async function isDirMissing(dir) {
2353
- return !await fs9.exists(dir);
2445
+ return !await fs8.exists(dir);
2354
2446
  }
2355
2447
  function logMissingDir(logger, name, expected) {
2356
2448
  logger.warn(
@@ -2364,19 +2456,19 @@ var COMMAND_MODES = {
2364
2456
  serve: "development"
2365
2457
  };
2366
2458
  async function mergeBuilderConfig(inlineConfig, userConfig) {
2367
- const vite = await import("vite").catch(() => void 0);
2368
- if (vite) {
2459
+ const vite2 = await import("vite").catch(() => void 0);
2460
+ if (vite2) {
2369
2461
  return {
2370
2462
  vite: async (env) => {
2371
2463
  const resolvedInlineConfig = await inlineConfig.vite?.(env) ?? {};
2372
2464
  const resolvedUserConfig = await userConfig.vite?.(env) ?? {};
2373
- return vite.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
2465
+ return vite2.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
2374
2466
  }
2375
2467
  };
2376
2468
  }
2377
2469
  throw Error("Builder not found. Make sure vite is installed.");
2378
2470
  }
2379
- async function resolveWxtModules(modulesDir, modules = []) {
2471
+ async function resolveWxtUserModules(modulesDir, modules = []) {
2380
2472
  const npmModules = await Promise.all(
2381
2473
  modules.map(async (moduleId) => {
2382
2474
  const mod = await import(
@@ -2393,7 +2485,7 @@ async function resolveWxtModules(modulesDir, modules = []) {
2393
2485
  };
2394
2486
  })
2395
2487
  );
2396
- const localModulePaths = await glob3(["*.[tj]s", "*/index.[tj]s"], {
2488
+ const localModulePaths = await glob4(["*.[tj]s", "*/index.[tj]s"], {
2397
2489
  cwd: modulesDir,
2398
2490
  onlyFiles: true
2399
2491
  }).catch(() => []);
@@ -2464,23 +2556,23 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
2464
2556
 
2465
2557
  // src/core/utils/building/import-entrypoint.ts
2466
2558
  import createJITI from "jiti";
2467
- import { createUnimport as createUnimport3 } from "unimport";
2468
- import fs10 from "fs-extra";
2469
- import { relative as relative5, resolve as resolve11 } from "node:path";
2559
+ import { createUnimport as createUnimport2 } from "unimport";
2560
+ import fs9 from "fs-extra";
2561
+ import { relative as relative5, resolve as resolve10 } from "node:path";
2470
2562
  import { transformSync } from "esbuild";
2471
2563
  import { fileURLToPath } from "node:url";
2472
2564
  async function importEntrypointFile(path11) {
2473
2565
  wxt.logger.debug("Loading file metadata:", path11);
2474
2566
  const normalPath = normalizePath(path11);
2475
- const unimport2 = createUnimport3({
2567
+ const unimport = createUnimport2({
2476
2568
  ...wxt.config.imports,
2477
2569
  // Only allow specific imports, not all from the project
2478
2570
  dirs: []
2479
2571
  });
2480
- await unimport2.init();
2481
- const text = await fs10.readFile(path11, "utf-8");
2572
+ await unimport.init();
2573
+ const text = await fs9.readFile(path11, "utf-8");
2482
2574
  const textNoImports = removeProjectImportStatements(text);
2483
- const { code } = await unimport2.injectImports(textNoImports);
2575
+ const { code } = await unimport.injectImports(textNoImports);
2484
2576
  wxt.logger.debug(
2485
2577
  ["Text:", text, "No imports:", textNoImports, "Code:", code].join("\n")
2486
2578
  );
@@ -2491,7 +2583,7 @@ async function importEntrypointFile(path11) {
2491
2583
  debug: wxt.config.debug,
2492
2584
  esmResolve: true,
2493
2585
  alias: {
2494
- "webextension-polyfill": resolve11(
2586
+ "webextension-polyfill": resolve10(
2495
2587
  wxt.config.wxtModuleDir,
2496
2588
  "dist/virtual/mock-browser.js"
2497
2589
  )
@@ -2556,12 +2648,12 @@ import pc5 from "picocolors";
2556
2648
  import fs13 from "fs-extra";
2557
2649
 
2558
2650
  // src/core/utils/log/printBuildSummary.ts
2559
- import { resolve as resolve12 } from "path";
2651
+ import { resolve as resolve11 } from "path";
2560
2652
 
2561
2653
  // src/core/utils/log/printFileList.ts
2562
2654
  import path7 from "node:path";
2563
2655
  import pc3 from "picocolors";
2564
- import fs11 from "fs-extra";
2656
+ import fs10 from "fs-extra";
2565
2657
  import { filesize } from "filesize";
2566
2658
 
2567
2659
  // src/core/utils/log/printTable.ts
@@ -2599,7 +2691,7 @@ async function printFileList(log, header, baseDir, files) {
2599
2691
  ];
2600
2692
  const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
2601
2693
  const color = getChunkColor(file);
2602
- const stats = await fs11.lstat(file);
2694
+ const stats = await fs10.lstat(file);
2603
2695
  totalSize += stats.size;
2604
2696
  const size = String(filesize(stats.size));
2605
2697
  return [
@@ -2640,7 +2732,7 @@ async function printBuildSummary(log, header, output) {
2640
2732
  return l.fileName.localeCompare(r.fileName);
2641
2733
  });
2642
2734
  const files = chunks.map(
2643
- (chunk) => resolve12(wxt.config.outDir, chunk.fileName)
2735
+ (chunk) => resolve11(wxt.config.outDir, chunk.fileName)
2644
2736
  );
2645
2737
  await printFileList(log, header, wxt.config.outDir, files);
2646
2738
  }
@@ -2662,7 +2754,7 @@ function getChunkSortWeight(filename) {
2662
2754
  import pc4 from "picocolors";
2663
2755
 
2664
2756
  // package.json
2665
- var version = "0.18.8";
2757
+ var version = "0.18.10";
2666
2758
 
2667
2759
  // src/core/utils/log/printHeader.ts
2668
2760
  function printHeader() {
@@ -2671,7 +2763,7 @@ function printHeader() {
2671
2763
  }
2672
2764
 
2673
2765
  // src/core/utils/building/internal-build.ts
2674
- import glob4 from "fast-glob";
2766
+ import glob5 from "fast-glob";
2675
2767
 
2676
2768
  // src/core/utils/manifest.ts
2677
2769
  import fs12 from "fs-extra";
@@ -2779,6 +2871,21 @@ function getContentScriptJs(config, entrypoint) {
2779
2871
  return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
2780
2872
  }
2781
2873
 
2874
+ // src/core/utils/package.ts
2875
+ import { resolve as resolve12 } from "node:path";
2876
+ import fs11 from "fs-extra";
2877
+ async function getPackageJson() {
2878
+ const file = resolve12(wxt.config.root, "package.json");
2879
+ try {
2880
+ return await fs11.readJson(file);
2881
+ } catch (err) {
2882
+ wxt.logger.debug(
2883
+ `Failed to read package.json at: ${file}. Returning undefined.`
2884
+ );
2885
+ return {};
2886
+ }
2887
+ }
2888
+
2782
2889
  // src/core/utils/manifest.ts
2783
2890
  import defu2 from "defu";
2784
2891
  async function writeManifest(manifest, output) {
@@ -3436,7 +3543,7 @@ async function internalBuild() {
3436
3543
  return output;
3437
3544
  }
3438
3545
  async function combineAnalysisStats() {
3439
- const unixFiles = await glob4(`${wxt.config.analysis.outputName}-*.json`, {
3546
+ const unixFiles = await glob5(`${wxt.config.analysis.outputName}-*.json`, {
3440
3547
  cwd: wxt.config.analysis.outputDir,
3441
3548
  absolute: true
3442
3549
  });
@@ -3466,12 +3573,12 @@ function printValidationResults({
3466
3573
  return map;
3467
3574
  }, /* @__PURE__ */ new Map());
3468
3575
  Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
3469
- consola.log(relative6(cwd, entrypoint.inputPath));
3576
+ wxt.logger.log(relative6(cwd, entrypoint.inputPath));
3470
3577
  console.log();
3471
3578
  errors2.forEach((err) => {
3472
3579
  const type = err.type === "error" ? pc5.red("ERROR") : pc5.yellow("WARN");
3473
3580
  const recieved = pc5.dim(`(recieved: ${JSON.stringify(err.value)})`);
3474
- consola.log(` - ${type} ${err.message} ${recieved}`);
3581
+ wxt.logger.log(` - ${type} ${err.message} ${recieved}`);
3475
3582
  });
3476
3583
  console.log();
3477
3584
  });
@@ -3485,35 +3592,40 @@ async function build(config) {
3485
3592
 
3486
3593
  // src/core/clean.ts
3487
3594
  import path8 from "node:path";
3488
- import glob5 from "fast-glob";
3595
+ import glob6 from "fast-glob";
3489
3596
  import fs14 from "fs-extra";
3490
3597
  import pc6 from "picocolors";
3491
- async function clean(root = process.cwd()) {
3492
- consola.info("Cleaning Project");
3598
+ async function clean(config) {
3599
+ if (typeof config === "string") {
3600
+ config = { root: config };
3601
+ }
3602
+ await registerWxt("build", config);
3603
+ wxt.logger.info("Cleaning Project");
3604
+ const root = wxt.config.root;
3493
3605
  const tempDirs = [
3494
3606
  "node_modules/.vite",
3495
3607
  "node_modules/.cache",
3496
3608
  "**/.wxt",
3497
- ".output/*"
3609
+ `${path8.relative(root, wxt.config.outBaseDir)}/*`
3498
3610
  ];
3499
- consola.debug("Looking for:", tempDirs.map(pc6.cyan).join(", "));
3500
- const directories = await glob5(tempDirs, {
3501
- cwd: path8.resolve(root),
3611
+ wxt.logger.debug("Looking for:", tempDirs.map(pc6.cyan).join(", "));
3612
+ const directories = await glob6(tempDirs, {
3613
+ cwd: root,
3502
3614
  absolute: true,
3503
3615
  onlyDirectories: true,
3504
3616
  deep: 2
3505
3617
  });
3506
3618
  if (directories.length === 0) {
3507
- consola.debug("No generated files found.");
3619
+ wxt.logger.debug("No generated files found.");
3508
3620
  return;
3509
3621
  }
3510
- consola.debug(
3622
+ wxt.logger.debug(
3511
3623
  "Found:",
3512
3624
  directories.map((dir) => pc6.cyan(path8.relative(root, dir))).join(", ")
3513
3625
  );
3514
3626
  for (const directory of directories) {
3515
3627
  await fs14.rm(directory, { force: true, recursive: true });
3516
- consola.debug("Deleted " + pc6.cyan(path8.relative(root, directory)));
3628
+ wxt.logger.debug("Deleted " + pc6.cyan(path8.relative(root, directory)));
3517
3629
  }
3518
3630
  }
3519
3631
 
@@ -3776,19 +3888,19 @@ function createFileReloader(server) {
3776
3888
  switch (changes.type) {
3777
3889
  case "extension-reload":
3778
3890
  server.reloadExtension();
3779
- consola.success(`Reloaded extension`);
3891
+ wxt.logger.success(`Reloaded extension`);
3780
3892
  break;
3781
3893
  case "html-reload":
3782
3894
  const { reloadedNames } = reloadHtmlPages(
3783
3895
  changes.rebuildGroups,
3784
3896
  server
3785
3897
  );
3786
- consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
3898
+ wxt.logger.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
3787
3899
  break;
3788
3900
  case "content-script-reload":
3789
3901
  reloadContentScripts(changes.changedSteps, server);
3790
3902
  const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
3791
- consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
3903
+ wxt.logger.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
3792
3904
  break;
3793
3905
  }
3794
3906
  } catch (err) {
@@ -3989,7 +4101,7 @@ import path10 from "node:path";
3989
4101
  import fs16 from "fs-extra";
3990
4102
  import { minimatch as minimatch2 } from "minimatch";
3991
4103
  import JSZip from "jszip";
3992
- import glob6 from "fast-glob";
4104
+ import glob7 from "fast-glob";
3993
4105
  async function zip(config) {
3994
4106
  await registerWxt("build", config);
3995
4107
  const output = await internalBuild();
@@ -4037,7 +4149,7 @@ async function zip(config) {
4037
4149
  }
4038
4150
  async function zipDir(directory, outputPath, options) {
4039
4151
  const archive = new JSZip();
4040
- const files = (await glob6("**/*", {
4152
+ const files = (await glob7("**/*", {
4041
4153
  cwd: directory,
4042
4154
  // Ignore node_modules, otherwise this glob step takes forever
4043
4155
  ignore: ["**/node_modules"],
@@ -4155,7 +4267,7 @@ function createAliasedCommand(base, name, alias, bin, docsUrl) {
4155
4267
  const args = process.argv.slice(
4156
4268
  process.argv.indexOf(aliasedCommand.name) + 1
4157
4269
  );
4158
- const { execa } = await import("./execa-ATHZH2Y4.js");
4270
+ const { execa } = await import("./execa-QLUM2B3W.js");
4159
4271
  await execa(bin, args, {
4160
4272
  stdio: "inherit"
4161
4273
  });
@@ -4242,9 +4354,9 @@ cli.command("prepare [root]", "prepare typescript project").option("-c, --config
4242
4354
  });
4243
4355
  })
4244
4356
  );
4245
- cli.command("clean [root]", "clean generated files and caches").alias("cleanup").action(
4357
+ cli.command("clean [root]", "clean generated files and caches").alias("cleanup").option("-c, --config <file>", "use specified config file").action(
4246
4358
  wrapAction(async (root, flags) => {
4247
- await clean(root);
4359
+ await clean({ root, configFile: flags.config, debug: flags.debug });
4248
4360
  })
4249
4361
  );
4250
4362
  cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").action(