wxt 0.14.3 → 0.14.5

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.
@@ -0,0 +1,39 @@
1
+ import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ export {
36
+ __require,
37
+ __commonJS,
38
+ __toESM
39
+ };
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.14.3";
2
+ var version = "0.14.5";
3
3
 
4
4
  // src/core/utils/arrays.ts
5
5
  function every(array, predicate) {
@@ -1237,6 +1237,7 @@ async function getInternalConfig(inlineConfig, command, server) {
1237
1237
  const typesDir = path4.resolve(wxtDir, "types");
1238
1238
  const outBaseDir = path4.resolve(root, mergedConfig.outDir ?? ".output");
1239
1239
  const outDir = path4.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
1240
+ const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
1240
1241
  const runnerConfig = await loadConfig({
1241
1242
  name: "web-ext",
1242
1243
  cwd: root,
@@ -1289,7 +1290,10 @@ async function getInternalConfig(inlineConfig, command, server) {
1289
1290
  experimental: {
1290
1291
  includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
1291
1292
  },
1292
- server
1293
+ server,
1294
+ dev: {
1295
+ reloadCommand
1296
+ }
1293
1297
  };
1294
1298
  const builder = await createViteBuilder(
1295
1299
  inlineConfig,
@@ -1356,7 +1360,11 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1356
1360
  ...inlineConfig.experimental
1357
1361
  },
1358
1362
  vite: void 0,
1359
- transformManifest: void 0
1363
+ transformManifest: void 0,
1364
+ dev: {
1365
+ ...userConfig.dev,
1366
+ ...inlineConfig.dev
1367
+ }
1360
1368
  };
1361
1369
  }
1362
1370
  function resolveInternalZipConfig(root, mergedConfig) {
@@ -1768,6 +1776,7 @@ async function writeManifest(manifest, output, config) {
1768
1776
  });
1769
1777
  }
1770
1778
  async function generateManifest(entrypoints, buildOutput, config) {
1779
+ const warnings = [];
1771
1780
  const pkg = await getPackageJson(config);
1772
1781
  let versionName = config.manifest.version_name ?? config.manifest.version ?? pkg?.version;
1773
1782
  if (versionName == null) {
@@ -1785,21 +1794,26 @@ async function generateManifest(entrypoints, buildOutput, config) {
1785
1794
  short_name: pkg?.shortName,
1786
1795
  icons: discoverIcons(buildOutput)
1787
1796
  };
1788
- if (config.command === "serve") {
1789
- baseManifest.commands = {
1790
- "wxt:reload-extension": {
1791
- description: "Reload the extension during development",
1792
- suggested_key: {
1793
- default: "Alt+R"
1794
- }
1795
- }
1796
- };
1797
- }
1798
1797
  const userManifest = config.manifest;
1799
1798
  const manifest = defu3(
1800
1799
  userManifest,
1801
1800
  baseManifest
1802
1801
  );
1802
+ if (config.command === "serve" && config.dev.reloadCommand) {
1803
+ if (manifest.commands && Object.keys(manifest.commands).length >= 4) {
1804
+ warnings.push([
1805
+ "Extension already has 4 registered commands, WXT's reload command is disabled"
1806
+ ]);
1807
+ } else {
1808
+ manifest.commands ??= {};
1809
+ manifest.commands["wxt:reload-extension"] = {
1810
+ description: "Reload the extension during development",
1811
+ suggested_key: {
1812
+ default: config.dev.reloadCommand
1813
+ }
1814
+ };
1815
+ }
1816
+ }
1803
1817
  manifest.version = version2;
1804
1818
  manifest.version_name = // Firefox doesn't support version_name
1805
1819
  config.browser === "firefox" || versionName === version2 ? void 0 : versionName;
@@ -1818,7 +1832,10 @@ async function generateManifest(entrypoints, buildOutput, config) {
1818
1832
  "Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
1819
1833
  );
1820
1834
  }
1821
- return finalManifest;
1835
+ return {
1836
+ manifest: finalManifest,
1837
+ warnings
1838
+ };
1822
1839
  }
1823
1840
  function simplifyVersion(versionName) {
1824
1841
  const version2 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
@@ -2179,11 +2196,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
2179
2196
  steps: [...existingOutput.steps, ...newOutput.steps],
2180
2197
  publicAssets: [...existingOutput.publicAssets, ...newOutput.publicAssets]
2181
2198
  };
2182
- const newManifest = await generateManifest(
2183
- allEntrypoints,
2184
- mergedOutput,
2185
- config
2186
- );
2199
+ const { manifest: newManifest, warnings: manifestWarnings } = await generateManifest(allEntrypoints, mergedOutput, config);
2187
2200
  const finalOutput = {
2188
2201
  manifest: newManifest,
2189
2202
  ...newOutput
@@ -2199,7 +2212,8 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
2199
2212
  ...finalOutput.publicAssets
2200
2213
  ]
2201
2214
  },
2202
- manifest: newManifest
2215
+ manifest: newManifest,
2216
+ warnings: manifestWarnings
2203
2217
  };
2204
2218
  }
2205
2219
 
@@ -2218,13 +2232,21 @@ async function internalBuild(config) {
2218
2232
  const entrypoints = await findEntrypoints(config);
2219
2233
  config.logger.debug("Detected entrypoints:", entrypoints);
2220
2234
  const groups = groupEntrypoints(entrypoints);
2221
- const { output } = await rebuild(config, entrypoints, groups, void 0);
2235
+ const { output, warnings } = await rebuild(
2236
+ config,
2237
+ entrypoints,
2238
+ groups,
2239
+ void 0
2240
+ );
2222
2241
  await printBuildSummary(
2223
2242
  config.logger.success,
2224
2243
  `Built extension in ${formatDuration(Date.now() - startTime)}`,
2225
2244
  output,
2226
2245
  config
2227
2246
  );
2247
+ for (const warning of warnings) {
2248
+ config.logger.warn(...warning);
2249
+ }
2228
2250
  if (config.analysis.enabled) {
2229
2251
  await combineAnalysisStats(config);
2230
2252
  config.logger.info(
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js CHANGED
@@ -1,10 +1,11 @@
1
- import "./chunk-VBXJIVYU.js";
1
+ import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
+ import "./chunk-73I7FAJU.js";
2
3
 
3
4
  // src/cli.ts
4
5
  import cac from "cac";
5
6
 
6
7
  // package.json
7
- var version = "0.14.3";
8
+ var version = "0.14.5";
8
9
 
9
10
  // src/core/utils/fs.ts
10
11
  import fs from "fs-extra";
@@ -1553,6 +1554,7 @@ async function getInternalConfig(inlineConfig, command, server) {
1553
1554
  const typesDir = path3.resolve(wxtDir, "types");
1554
1555
  const outBaseDir = path3.resolve(root, mergedConfig.outDir ?? ".output");
1555
1556
  const outDir = path3.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
1557
+ const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
1556
1558
  const runnerConfig = await loadConfig({
1557
1559
  name: "web-ext",
1558
1560
  cwd: root,
@@ -1605,7 +1607,10 @@ async function getInternalConfig(inlineConfig, command, server) {
1605
1607
  experimental: {
1606
1608
  includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
1607
1609
  },
1608
- server
1610
+ server,
1611
+ dev: {
1612
+ reloadCommand
1613
+ }
1609
1614
  };
1610
1615
  const builder = await createViteBuilder(
1611
1616
  inlineConfig,
@@ -1672,7 +1677,11 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1672
1677
  ...inlineConfig.experimental
1673
1678
  },
1674
1679
  vite: void 0,
1675
- transformManifest: void 0
1680
+ transformManifest: void 0,
1681
+ dev: {
1682
+ ...userConfig.dev,
1683
+ ...inlineConfig.dev
1684
+ }
1676
1685
  };
1677
1686
  }
1678
1687
  function resolveInternalZipConfig(root, mergedConfig) {
@@ -2088,6 +2097,7 @@ async function writeManifest(manifest, output, config) {
2088
2097
  });
2089
2098
  }
2090
2099
  async function generateManifest(entrypoints, buildOutput, config) {
2100
+ const warnings = [];
2091
2101
  const pkg = await getPackageJson(config);
2092
2102
  let versionName = config.manifest.version_name ?? config.manifest.version ?? pkg?.version;
2093
2103
  if (versionName == null) {
@@ -2105,21 +2115,26 @@ async function generateManifest(entrypoints, buildOutput, config) {
2105
2115
  short_name: pkg?.shortName,
2106
2116
  icons: discoverIcons(buildOutput)
2107
2117
  };
2108
- if (config.command === "serve") {
2109
- baseManifest.commands = {
2110
- "wxt:reload-extension": {
2111
- description: "Reload the extension during development",
2112
- suggested_key: {
2113
- default: "Alt+R"
2114
- }
2115
- }
2116
- };
2117
- }
2118
2118
  const userManifest = config.manifest;
2119
2119
  const manifest = defu3(
2120
2120
  userManifest,
2121
2121
  baseManifest
2122
2122
  );
2123
+ if (config.command === "serve" && config.dev.reloadCommand) {
2124
+ if (manifest.commands && Object.keys(manifest.commands).length >= 4) {
2125
+ warnings.push([
2126
+ "Extension already has 4 registered commands, WXT's reload command is disabled"
2127
+ ]);
2128
+ } else {
2129
+ manifest.commands ??= {};
2130
+ manifest.commands["wxt:reload-extension"] = {
2131
+ description: "Reload the extension during development",
2132
+ suggested_key: {
2133
+ default: config.dev.reloadCommand
2134
+ }
2135
+ };
2136
+ }
2137
+ }
2123
2138
  manifest.version = version2;
2124
2139
  manifest.version_name = // Firefox doesn't support version_name
2125
2140
  config.browser === "firefox" || versionName === version2 ? void 0 : versionName;
@@ -2138,7 +2153,10 @@ async function generateManifest(entrypoints, buildOutput, config) {
2138
2153
  "Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
2139
2154
  );
2140
2155
  }
2141
- return finalManifest;
2156
+ return {
2157
+ manifest: finalManifest,
2158
+ warnings
2159
+ };
2142
2160
  }
2143
2161
  function simplifyVersion(versionName) {
2144
2162
  const version2 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
@@ -2499,11 +2517,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
2499
2517
  steps: [...existingOutput.steps, ...newOutput.steps],
2500
2518
  publicAssets: [...existingOutput.publicAssets, ...newOutput.publicAssets]
2501
2519
  };
2502
- const newManifest = await generateManifest(
2503
- allEntrypoints,
2504
- mergedOutput,
2505
- config
2506
- );
2520
+ const { manifest: newManifest, warnings: manifestWarnings } = await generateManifest(allEntrypoints, mergedOutput, config);
2507
2521
  const finalOutput = {
2508
2522
  manifest: newManifest,
2509
2523
  ...newOutput
@@ -2519,7 +2533,8 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
2519
2533
  ...finalOutput.publicAssets
2520
2534
  ]
2521
2535
  },
2522
- manifest: newManifest
2536
+ manifest: newManifest,
2537
+ warnings: manifestWarnings
2523
2538
  };
2524
2539
  }
2525
2540
 
@@ -2538,13 +2553,21 @@ async function internalBuild(config) {
2538
2553
  const entrypoints = await findEntrypoints(config);
2539
2554
  config.logger.debug("Detected entrypoints:", entrypoints);
2540
2555
  const groups = groupEntrypoints(entrypoints);
2541
- const { output } = await rebuild(config, entrypoints, groups, void 0);
2556
+ const { output, warnings } = await rebuild(
2557
+ config,
2558
+ entrypoints,
2559
+ groups,
2560
+ void 0
2561
+ );
2542
2562
  await printBuildSummary(
2543
2563
  config.logger.success,
2544
2564
  `Built extension in ${formatDuration(Date.now() - startTime)}`,
2545
2565
  output,
2546
2566
  config
2547
2567
  );
2568
+ for (const warning of warnings) {
2569
+ config.logger.warn(...warning);
2570
+ }
2548
2571
  if (config.analysis.enabled) {
2549
2572
  await combineAnalysisStats(config);
2550
2573
  config.logger.info(
@@ -2555,7 +2578,7 @@ async function internalBuild(config) {
2555
2578
  return output;
2556
2579
  }
2557
2580
  async function combineAnalysisStats(config) {
2558
- const { execaCommand } = await import("./execa-4F7CCWCA.js");
2581
+ const { execaCommand } = await import("./execa-Y2EWTC4S.js");
2559
2582
  const unixFiles = await glob3(`stats-*.json`, {
2560
2583
  cwd: config.outDir,
2561
2584
  absolute: true
@@ -3122,9 +3145,7 @@ cli.command("build [root]", "build for production").option("-c, --config <file>"
3122
3145
  manifestVersion: flags.mv3 ? 3 : flags.mv2 ? 2 : void 0,
3123
3146
  configFile: flags.config,
3124
3147
  debug: flags.debug,
3125
- analysis: {
3126
- enabled: flags.analyze
3127
- },
3148
+ analysis: flags.analyze ? { enabled: true } : void 0,
3128
3149
  filterEntrypoints: getArrayFromFlags(flags, "filterEntrypoint")
3129
3150
  });
3130
3151
  })
@@ -3167,7 +3188,7 @@ cli.command("init [directory]", "initialize a new project").option("-t, --templa
3167
3188
  { disableFinishedLog: true }
3168
3189
  )
3169
3190
  );
3170
- cli.parse();
3191
+ cli.parse(process.argv);
3171
3192
  function wrapAction(cb, options) {
3172
3193
  return async (...args) => {
3173
3194
  const isDebug = !!args.find((arg) => arg?.debug);