wxt 0.14.2-alpha2 → 0.14.3

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/index.cjs CHANGED
@@ -40,7 +40,7 @@ var require_windows = __commonJS({
40
40
  module2.exports = isexe;
41
41
  isexe.sync = sync;
42
42
  var fs16 = require("fs");
43
- function checkPathExt(path9, options) {
43
+ function checkPathExt(path10, options) {
44
44
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
45
45
  if (!pathext) {
46
46
  return true;
@@ -51,25 +51,25 @@ var require_windows = __commonJS({
51
51
  }
52
52
  for (var i = 0; i < pathext.length; i++) {
53
53
  var p = pathext[i].toLowerCase();
54
- if (p && path9.substr(-p.length).toLowerCase() === p) {
54
+ if (p && path10.substr(-p.length).toLowerCase() === p) {
55
55
  return true;
56
56
  }
57
57
  }
58
58
  return false;
59
59
  }
60
- function checkStat(stat, path9, options) {
60
+ function checkStat(stat, path10, options) {
61
61
  if (!stat.isSymbolicLink() && !stat.isFile()) {
62
62
  return false;
63
63
  }
64
- return checkPathExt(path9, options);
64
+ return checkPathExt(path10, options);
65
65
  }
66
- function isexe(path9, options, cb) {
67
- fs16.stat(path9, function(er, stat) {
68
- cb(er, er ? false : checkStat(stat, path9, options));
66
+ function isexe(path10, options, cb) {
67
+ fs16.stat(path10, function(er, stat) {
68
+ cb(er, er ? false : checkStat(stat, path10, options));
69
69
  });
70
70
  }
71
- function sync(path9, options) {
72
- return checkStat(fs16.statSync(path9), path9, options);
71
+ function sync(path10, options) {
72
+ return checkStat(fs16.statSync(path10), path10, options);
73
73
  }
74
74
  }
75
75
  });
@@ -81,13 +81,13 @@ var require_mode = __commonJS({
81
81
  module2.exports = isexe;
82
82
  isexe.sync = sync;
83
83
  var fs16 = require("fs");
84
- function isexe(path9, options, cb) {
85
- fs16.stat(path9, function(er, stat) {
84
+ function isexe(path10, options, cb) {
85
+ fs16.stat(path10, function(er, stat) {
86
86
  cb(er, er ? false : checkStat(stat, options));
87
87
  });
88
88
  }
89
- function sync(path9, options) {
90
- return checkStat(fs16.statSync(path9), options);
89
+ function sync(path10, options) {
90
+ return checkStat(fs16.statSync(path10), options);
91
91
  }
92
92
  function checkStat(stat, options) {
93
93
  return stat.isFile() && checkMode(stat, options);
@@ -121,7 +121,7 @@ var require_isexe = __commonJS({
121
121
  }
122
122
  module2.exports = isexe;
123
123
  isexe.sync = sync;
124
- function isexe(path9, options, cb) {
124
+ function isexe(path10, options, cb) {
125
125
  if (typeof options === "function") {
126
126
  cb = options;
127
127
  options = {};
@@ -131,7 +131,7 @@ var require_isexe = __commonJS({
131
131
  throw new TypeError("callback not provided");
132
132
  }
133
133
  return new Promise(function(resolve14, reject) {
134
- isexe(path9, options || {}, function(er, is) {
134
+ isexe(path10, options || {}, function(er, is) {
135
135
  if (er) {
136
136
  reject(er);
137
137
  } else {
@@ -140,7 +140,7 @@ var require_isexe = __commonJS({
140
140
  });
141
141
  });
142
142
  }
143
- core(path9, options || {}, function(er, is) {
143
+ core(path10, options || {}, function(er, is) {
144
144
  if (er) {
145
145
  if (er.code === "EACCES" || options && options.ignoreErrors) {
146
146
  er = null;
@@ -150,9 +150,9 @@ var require_isexe = __commonJS({
150
150
  cb(er, is);
151
151
  });
152
152
  }
153
- function sync(path9, options) {
153
+ function sync(path10, options) {
154
154
  try {
155
- return core.sync(path9, options || {});
155
+ return core.sync(path10, options || {});
156
156
  } catch (er) {
157
157
  if (options && options.ignoreErrors || er.code === "EACCES") {
158
158
  return false;
@@ -169,7 +169,7 @@ var require_which = __commonJS({
169
169
  "node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module2) {
170
170
  "use strict";
171
171
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
172
- var path9 = require("path");
172
+ var path10 = require("path");
173
173
  var COLON = isWindows ? ";" : ":";
174
174
  var isexe = require_isexe();
175
175
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -207,7 +207,7 @@ var require_which = __commonJS({
207
207
  return opt.all && found.length ? resolve14(found) : reject(getNotFoundError(cmd));
208
208
  const ppRaw = pathEnv[i];
209
209
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
210
- const pCmd = path9.join(pathPart, cmd);
210
+ const pCmd = path10.join(pathPart, cmd);
211
211
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
212
212
  resolve14(subStep(p, i, 0));
213
213
  });
@@ -234,7 +234,7 @@ var require_which = __commonJS({
234
234
  for (let i = 0; i < pathEnv.length; i++) {
235
235
  const ppRaw = pathEnv[i];
236
236
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
237
- const pCmd = path9.join(pathPart, cmd);
237
+ const pCmd = path10.join(pathPart, cmd);
238
238
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
239
239
  for (let j = 0; j < pathExt.length; j++) {
240
240
  const cur = p + pathExt[j];
@@ -282,7 +282,7 @@ var require_path_key = __commonJS({
282
282
  var require_resolveCommand = __commonJS({
283
283
  "node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
284
284
  "use strict";
285
- var path9 = require("path");
285
+ var path10 = require("path");
286
286
  var which = require_which();
287
287
  var getPathKey = require_path_key();
288
288
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -300,7 +300,7 @@ var require_resolveCommand = __commonJS({
300
300
  try {
301
301
  resolved = which.sync(parsed.command, {
302
302
  path: env[getPathKey({ env })],
303
- pathExt: withoutPathExt ? path9.delimiter : void 0
303
+ pathExt: withoutPathExt ? path10.delimiter : void 0
304
304
  });
305
305
  } catch (e) {
306
306
  } finally {
@@ -309,7 +309,7 @@ var require_resolveCommand = __commonJS({
309
309
  }
310
310
  }
311
311
  if (resolved) {
312
- resolved = path9.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
312
+ resolved = path10.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
313
313
  }
314
314
  return resolved;
315
315
  }
@@ -363,8 +363,8 @@ var require_shebang_command = __commonJS({
363
363
  if (!match) {
364
364
  return null;
365
365
  }
366
- const [path9, argument] = match[0].replace(/#! ?/, "").split(" ");
367
- const binary = path9.split("/").pop();
366
+ const [path10, argument] = match[0].replace(/#! ?/, "").split(" ");
367
+ const binary = path10.split("/").pop();
368
368
  if (binary === "env") {
369
369
  return argument;
370
370
  }
@@ -399,7 +399,7 @@ var require_readShebang = __commonJS({
399
399
  var require_parse = __commonJS({
400
400
  "node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
401
401
  "use strict";
402
- var path9 = require("path");
402
+ var path10 = require("path");
403
403
  var resolveCommand = require_resolveCommand();
404
404
  var escape = require_escape();
405
405
  var readShebang = require_readShebang();
@@ -424,7 +424,7 @@ var require_parse = __commonJS({
424
424
  const needsShell = !isExecutableRegExp.test(commandFile);
425
425
  if (parsed.options.forceShell || needsShell) {
426
426
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
427
- parsed.command = path9.normalize(parsed.command);
427
+ parsed.command = path10.normalize(parsed.command);
428
428
  parsed.command = escape.command(parsed.command);
429
429
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
430
430
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -590,9 +590,9 @@ function npmRunPath(options = {}) {
590
590
  }
591
591
  function npmRunPathEnv({ env = import_node_process.default.env, ...options } = {}) {
592
592
  env = { ...env };
593
- const path9 = pathKey({ env });
594
- options.path = env[path9];
595
- env[path9] = npmRunPath(options);
593
+ const path10 = pathKey({ env });
594
+ options.path = env[path10];
595
+ env[path10] = npmRunPath(options);
596
596
  return env;
597
597
  }
598
598
  var import_node_process, import_node_path11, import_node_url2;
@@ -1891,12 +1891,12 @@ var require_merge_stream = __commonJS({
1891
1891
  });
1892
1892
 
1893
1893
  // node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.js
1894
- var import_node_fs2, import_promises2, import_merge_stream, validateInputOptions, getInputSync, handleInputSync, getInput, handleInput, makeAllStream, getBufferedData, getStreamPromise, applyEncoding, getSpawnedResult;
1894
+ var import_node_fs2, import_promises, import_merge_stream, validateInputOptions, getInputSync, handleInputSync, getInput, handleInput, makeAllStream, getBufferedData, getStreamPromise, applyEncoding, getSpawnedResult;
1895
1895
  var init_stream = __esm({
1896
1896
  "node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.js"() {
1897
1897
  "use strict";
1898
1898
  import_node_fs2 = require("fs");
1899
- import_promises2 = require("timers/promises");
1899
+ import_promises = require("timers/promises");
1900
1900
  init_is_stream();
1901
1901
  init_source();
1902
1902
  import_merge_stream = __toESM(require_merge_stream(), 1);
@@ -1954,7 +1954,7 @@ var init_stream = __esm({
1954
1954
  if (!stream || streamPromise === void 0) {
1955
1955
  return;
1956
1956
  }
1957
- await (0, import_promises2.setTimeout)(0);
1957
+ await (0, import_promises.setTimeout)(0);
1958
1958
  stream.destroy();
1959
1959
  try {
1960
1960
  return await streamPromise;
@@ -2434,11 +2434,11 @@ var import_fast_glob = __toESM(require("fast-glob"), 1);
2434
2434
  // src/core/utils/paths.ts
2435
2435
  var import_node_path = __toESM(require("path"), 1);
2436
2436
  var import_normalize_path = __toESM(require("normalize-path"), 1);
2437
- function normalizePath(path9) {
2438
- return (0, import_normalize_path.default)(path9);
2437
+ function normalizePath(path10) {
2438
+ return (0, import_normalize_path.default)(path10);
2439
2439
  }
2440
- function unnormalizePath(path9) {
2441
- return import_node_path.default.normalize(path9);
2440
+ function unnormalizePath(path10) {
2441
+ return import_node_path.default.normalize(path10);
2442
2442
  }
2443
2443
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
2444
2444
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
@@ -2459,145 +2459,8 @@ async function getPublicFiles(config) {
2459
2459
 
2460
2460
  // src/core/utils/building/build-entrypoints.ts
2461
2461
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
2462
- var import_node_path2 = require("path");
2462
+ var import_path = require("path");
2463
2463
  var import_picocolors = __toESM(require("picocolors"), 1);
2464
-
2465
- // src/i18n/node.ts
2466
- var import_promises = require("fs/promises");
2467
- var import_json5 = __toESM(require("json5"), 1);
2468
- var import_yaml = __toESM(require("yaml"), 1);
2469
- async function readMessagesFile(file) {
2470
- const text = await (0, import_promises.readFile)(file, "utf-8");
2471
- return readMessagesText(text);
2472
- }
2473
- function readMessagesText(text) {
2474
- const parsers = [
2475
- JSON.parse,
2476
- import_json5.default.parse,
2477
- import_yaml.default.parse
2478
- ];
2479
- for (const parse of parsers) {
2480
- try {
2481
- const result = parse(text);
2482
- if (typeof result === "object") {
2483
- return readMessagesObject(result);
2484
- }
2485
- } catch {
2486
- continue;
2487
- }
2488
- }
2489
- throw Error("I18n messages text is not valid JSON, JSON5, or YAML");
2490
- }
2491
- function readMessagesObject(input) {
2492
- const messagesFromInput = findEntries([], input);
2493
- return [...messagesFromInput, ...PREDEFINED_MESSAGES];
2494
- }
2495
- function convertMessagesToManifest(messages) {
2496
- return messages.filter((message) => !message.isBuiltin).reduce((schema, { name, entry }) => {
2497
- schema[name] = entry;
2498
- return schema;
2499
- }, {});
2500
- }
2501
- function findEntries(keyPath, input) {
2502
- const name = keyPath.join("_");
2503
- if (isBasicEntry(input))
2504
- return [
2505
- {
2506
- name,
2507
- entry: { message: input }
2508
- }
2509
- ];
2510
- if (isManifestEntry(input))
2511
- return [
2512
- {
2513
- name,
2514
- entry: input
2515
- }
2516
- ];
2517
- if (isPluralEntry(input))
2518
- return [
2519
- {
2520
- name,
2521
- entry: {
2522
- message: Object.values(input).join(" | ")
2523
- },
2524
- isPlural: true
2525
- }
2526
- ];
2527
- return Object.entries(input).reduce((items, [key, child]) => {
2528
- const nestedEntries = findEntries(keyPath.concat(key), child);
2529
- return [...items, ...nestedEntries];
2530
- }, []);
2531
- }
2532
- function isBasicEntry(entry) {
2533
- return typeof entry === "string";
2534
- }
2535
- function isManifestEntry(entry) {
2536
- const keys = Object.keys(entry);
2537
- if (keys.length < 1 || keys.length > 3)
2538
- return false;
2539
- const knownKeys = /* @__PURE__ */ new Set(["message", "placeholders", "description"]);
2540
- const unknownKeys = keys.filter((key) => !knownKeys.has(key));
2541
- return unknownKeys.length === 0;
2542
- }
2543
- function isPluralEntry(entry) {
2544
- const keys = Object.keys(entry);
2545
- if (keys.length === 0)
2546
- return false;
2547
- const invalidKeys = keys.filter((key) => key !== "n" && isNaN(Number(key)));
2548
- return invalidKeys.length === 0;
2549
- }
2550
- var PREDEFINED_MESSAGES = [
2551
- {
2552
- name: "@@extension_id",
2553
- isBuiltin: true,
2554
- entry: {
2555
- message: "<browser.runtime.id>",
2556
- description: "The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.\nNote: You can't use this message in a manifest file."
2557
- }
2558
- },
2559
- {
2560
- name: "@@ui_locale",
2561
- isBuiltin: true,
2562
- entry: {
2563
- message: "<browser.i18n.getUiLocale()>"
2564
- }
2565
- },
2566
- {
2567
- name: "@@bidi_dir",
2568
- isBuiltin: true,
2569
- entry: {
2570
- message: "<ltr|rtl>",
2571
- description: 'The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.'
2572
- }
2573
- },
2574
- {
2575
- name: "@@bidi_reversed_dir",
2576
- isBuiltin: true,
2577
- entry: {
2578
- message: "<rtl|ltr>",
2579
- description: `If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".`
2580
- }
2581
- },
2582
- {
2583
- name: "@@bidi_start_edge",
2584
- isBuiltin: true,
2585
- entry: {
2586
- message: "<left|right>",
2587
- description: `If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".`
2588
- }
2589
- },
2590
- {
2591
- name: "@@bidi_end_edge",
2592
- isBuiltin: true,
2593
- entry: {
2594
- message: "<right|left>",
2595
- description: `If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".`
2596
- }
2597
- }
2598
- ];
2599
-
2600
- // src/core/utils/building/build-entrypoints.ts
2601
2464
  async function buildEntrypoints(groups, config, spinner) {
2602
2465
  const steps = [];
2603
2466
  for (let i = 0; i < groups.length; i++) {
@@ -2606,10 +2469,7 @@ async function buildEntrypoints(groups, config, spinner) {
2606
2469
  spinner.text = import_picocolors.default.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNames}`;
2607
2470
  steps.push(await config.builder.build(group));
2608
2471
  }
2609
- const publicAssets = (await Promise.all([
2610
- copyPublicDirectory(config),
2611
- copyLocalesDirectory(config)
2612
- ])).flat();
2472
+ const publicAssets = await copyPublicDirectory(config);
2613
2473
  return { publicAssets, steps };
2614
2474
  }
2615
2475
  async function copyPublicDirectory(config) {
@@ -2618,9 +2478,9 @@ async function copyPublicDirectory(config) {
2618
2478
  return [];
2619
2479
  const publicAssets = [];
2620
2480
  for (const file of files) {
2621
- const srcPath = (0, import_node_path2.resolve)(config.publicDir, file);
2622
- const outPath = (0, import_node_path2.resolve)(config.outDir, file);
2623
- await import_fs_extra2.default.ensureDir((0, import_node_path2.dirname)(outPath));
2481
+ const srcPath = (0, import_path.resolve)(config.publicDir, file);
2482
+ const outPath = (0, import_path.resolve)(config.outDir, file);
2483
+ await import_fs_extra2.default.ensureDir((0, import_path.dirname)(outPath));
2624
2484
  await import_fs_extra2.default.copyFile(srcPath, outPath);
2625
2485
  publicAssets.push({
2626
2486
  type: "asset",
@@ -2629,28 +2489,6 @@ async function copyPublicDirectory(config) {
2629
2489
  }
2630
2490
  return publicAssets;
2631
2491
  }
2632
- async function copyLocalesDirectory(config) {
2633
- const localesExist = await import_fs_extra2.default.exists(config.localesDir);
2634
- if (!localesExist || config.manifest.default_locale == null)
2635
- return [];
2636
- const files = await import_fs_extra2.default.readdir(config.localesDir);
2637
- return await Promise.all(
2638
- files.map(async (file) => {
2639
- const locale = file.replace((0, import_node_path2.extname)(file), "");
2640
- const fileName = unnormalizePath(`_locales/${locale}/messages.json`);
2641
- const srcPath = (0, import_node_path2.resolve)(config.localesDir, file);
2642
- const outPath = (0, import_node_path2.resolve)(config.outDir, fileName);
2643
- const messages = await readMessagesFile(srcPath);
2644
- const json = convertMessagesToManifest(messages);
2645
- await import_fs_extra2.default.ensureDir((0, import_node_path2.dirname)(outPath));
2646
- await import_fs_extra2.default.writeJson(outPath, json);
2647
- return {
2648
- fileName,
2649
- type: "asset"
2650
- };
2651
- })
2652
- );
2653
- }
2654
2492
 
2655
2493
  // src/core/utils/arrays.ts
2656
2494
  function every(array, predicate) {
@@ -2745,26 +2583,26 @@ function findEffectedSteps(changedFile, currentOutput) {
2745
2583
  }
2746
2584
 
2747
2585
  // src/core/utils/building/find-entrypoints.ts
2748
- var import_path = require("path");
2586
+ var import_path2 = require("path");
2749
2587
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
2750
2588
  var import_minimatch = require("minimatch");
2751
2589
  var import_linkedom = require("linkedom");
2752
- var import_json52 = __toESM(require("json5"), 1);
2590
+ var import_json5 = __toESM(require("json5"), 1);
2753
2591
  var import_fast_glob2 = __toESM(require("fast-glob"), 1);
2754
2592
 
2755
2593
  // src/core/utils/entrypoints.ts
2756
- var import_node_path3 = __toESM(require("path"), 1);
2594
+ var import_node_path2 = __toESM(require("path"), 1);
2757
2595
  function getEntrypointName(entrypointsDir, inputPath) {
2758
- const relativePath = import_node_path3.default.relative(entrypointsDir, inputPath);
2596
+ const relativePath = import_node_path2.default.relative(entrypointsDir, inputPath);
2759
2597
  const name = relativePath.split(/[\.\/\\]/, 2)[0];
2760
2598
  return name;
2761
2599
  }
2762
2600
  function getEntrypointOutputFile(entrypoint, ext) {
2763
- return (0, import_node_path3.resolve)(entrypoint.outputDir, `${entrypoint.name}${ext}`);
2601
+ return (0, import_node_path2.resolve)(entrypoint.outputDir, `${entrypoint.name}${ext}`);
2764
2602
  }
2765
2603
  function getEntrypointBundlePath(entrypoint, outDir, ext) {
2766
2604
  return normalizePath(
2767
- (0, import_node_path3.relative)(outDir, getEntrypointOutputFile(entrypoint, ext))
2605
+ (0, import_node_path2.relative)(outDir, getEntrypointOutputFile(entrypoint, ext))
2768
2606
  );
2769
2607
  }
2770
2608
  function resolvePerBrowserOption(option, browser) {
@@ -2777,6 +2615,7 @@ function resolvePerBrowserOption(option, browser) {
2777
2615
  var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
2778
2616
 
2779
2617
  // src/core/utils/building/find-entrypoints.ts
2618
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
2780
2619
  async function findEntrypoints(config) {
2781
2620
  const relativePaths = await (0, import_fast_glob2.default)(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
2782
2621
  cwd: config.entrypointsDir
@@ -2784,14 +2623,19 @@ async function findEntrypoints(config) {
2784
2623
  relativePaths.sort();
2785
2624
  const pathGlobs = Object.keys(PATH_GLOB_TO_TYPE_MAP);
2786
2625
  const entrypointInfos = relativePaths.reduce((results, relativePath) => {
2787
- const inputPath = (0, import_path.resolve)(config.entrypointsDir, relativePath);
2626
+ const inputPath = (0, import_path2.resolve)(config.entrypointsDir, relativePath);
2788
2627
  const name = getEntrypointName(config.entrypointsDir, inputPath);
2789
2628
  const matchingGlob = pathGlobs.find(
2790
- (glob6) => (0, import_minimatch.minimatch)(relativePath, glob6)
2629
+ (glob5) => (0, import_minimatch.minimatch)(relativePath, glob5)
2791
2630
  );
2792
2631
  if (matchingGlob) {
2793
2632
  const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
2794
- results.push({ name, inputPath, type });
2633
+ results.push({
2634
+ name,
2635
+ inputPath,
2636
+ type,
2637
+ skipped: config.filterEntrypoints != null && !config.filterEntrypoints.has(name)
2638
+ });
2795
2639
  }
2796
2640
  return results;
2797
2641
  }, []);
@@ -2819,7 +2663,7 @@ async function findEntrypoints(config) {
2819
2663
  return {
2820
2664
  ...info,
2821
2665
  type,
2822
- outputDir: (0, import_path.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
2666
+ outputDir: (0, import_path2.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
2823
2667
  options: {
2824
2668
  include: void 0,
2825
2669
  exclude: void 0
@@ -2843,11 +2687,19 @@ async function findEntrypoints(config) {
2843
2687
  await getBackgroundEntrypoint(config, {
2844
2688
  inputPath: VIRTUAL_NOOP_BACKGROUND_MODULE_ID,
2845
2689
  name: "background",
2846
- type: "background"
2690
+ type: "background",
2691
+ skipped: false
2847
2692
  })
2848
2693
  );
2849
2694
  }
2850
2695
  config.logger.debug("All entrypoints:", entrypoints);
2696
+ const skippedEntrypointNames = entrypointInfos.filter((item) => item.skipped).map((item) => item.name);
2697
+ if (skippedEntrypointNames.length) {
2698
+ config.logger.warn(
2699
+ `Filter excluded the following entrypoints:
2700
+ ${skippedEntrypointNames.map((item) => `${import_picocolors2.default.dim("-")} ${import_picocolors2.default.cyan(item)}`).join("\n")}`
2701
+ );
2702
+ }
2851
2703
  const targetEntrypoints = entrypoints.filter((entry) => {
2852
2704
  const { include, exclude } = entry.options;
2853
2705
  if (include?.length && exclude?.length) {
@@ -2862,6 +2714,9 @@ async function findEntrypoints(config) {
2862
2714
  if (include?.length && !exclude?.length) {
2863
2715
  return include.includes(config.browser);
2864
2716
  }
2717
+ if (skippedEntrypointNames.includes(entry.name)) {
2718
+ return false;
2719
+ }
2865
2720
  return true;
2866
2721
  });
2867
2722
  config.logger.debug(`${config.browser} entrypoints:`, targetEntrypoints);
@@ -2881,7 +2736,7 @@ function preventDuplicateEntrypointNames(config, files) {
2881
2736
  if (absolutePaths.length > 1) {
2882
2737
  lines.push(`- ${name}`);
2883
2738
  absolutePaths.forEach((absolutePath) => {
2884
- lines.push(` - ${(0, import_path.relative)(config.root, absolutePath)}`);
2739
+ lines.push(` - ${(0, import_path2.relative)(config.root, absolutePath)}`);
2885
2740
  });
2886
2741
  }
2887
2742
  return lines;
@@ -2906,15 +2761,15 @@ function getHtmlBaseOptions(document) {
2906
2761
  const options = {};
2907
2762
  const includeContent = document.querySelector("meta[name='manifest.include']")?.getAttribute("content");
2908
2763
  if (includeContent) {
2909
- options.include = import_json52.default.parse(includeContent);
2764
+ options.include = import_json5.default.parse(includeContent);
2910
2765
  }
2911
2766
  const excludeContent = document.querySelector("meta[name='manifest.exclude']")?.getAttribute("content");
2912
2767
  if (excludeContent) {
2913
- options.exclude = import_json52.default.parse(excludeContent);
2768
+ options.exclude = import_json5.default.parse(excludeContent);
2914
2769
  }
2915
2770
  return options;
2916
2771
  }
2917
- async function getPopupEntrypoint(config, { inputPath, name }) {
2772
+ async function getPopupEntrypoint(config, { inputPath, name, skipped }) {
2918
2773
  const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
2919
2774
  const { document } = (0, import_linkedom.parseHTML)(content);
2920
2775
  const options = getHtmlBaseOptions(document);
@@ -2924,7 +2779,7 @@ async function getPopupEntrypoint(config, { inputPath, name }) {
2924
2779
  const defaultIconContent = document.querySelector("meta[name='manifest.default_icon']")?.getAttribute("content");
2925
2780
  if (defaultIconContent) {
2926
2781
  try {
2927
- options.defaultIcon = import_json52.default.parse(defaultIconContent);
2782
+ options.defaultIcon = import_json5.default.parse(defaultIconContent);
2928
2783
  } catch (err) {
2929
2784
  config.logger.fatal(
2930
2785
  `Failed to parse default_icon meta tag content as JSON5. content=${defaultIconContent}`,
@@ -2945,10 +2800,11 @@ async function getPopupEntrypoint(config, { inputPath, name }) {
2945
2800
  name: "popup",
2946
2801
  options,
2947
2802
  inputPath,
2948
- outputDir: config.outDir
2803
+ outputDir: config.outDir,
2804
+ skipped
2949
2805
  };
2950
2806
  }
2951
- async function getOptionsEntrypoint(config, { inputPath, name }) {
2807
+ async function getOptionsEntrypoint(config, { inputPath, name, skipped }) {
2952
2808
  const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
2953
2809
  const { document } = (0, import_linkedom.parseHTML)(content);
2954
2810
  const options = getHtmlBaseOptions(document);
@@ -2969,10 +2825,11 @@ async function getOptionsEntrypoint(config, { inputPath, name }) {
2969
2825
  name: "options",
2970
2826
  options,
2971
2827
  inputPath,
2972
- outputDir: config.outDir
2828
+ outputDir: config.outDir,
2829
+ skipped
2973
2830
  };
2974
2831
  }
2975
- async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
2832
+ async function getUnlistedPageEntrypoint(config, { inputPath, name, skipped }) {
2976
2833
  const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
2977
2834
  const { document } = (0, import_linkedom.parseHTML)(content);
2978
2835
  return {
@@ -2980,10 +2837,11 @@ async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
2980
2837
  name: getEntrypointName(config.entrypointsDir, inputPath),
2981
2838
  inputPath,
2982
2839
  outputDir: config.outDir,
2983
- options: getHtmlBaseOptions(document)
2840
+ options: getHtmlBaseOptions(document),
2841
+ skipped
2984
2842
  };
2985
2843
  }
2986
- async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
2844
+ async function getUnlistedScriptEntrypoint(config, { inputPath, name, skipped }) {
2987
2845
  const defaultExport = await importEntrypointFile(
2988
2846
  inputPath,
2989
2847
  config
@@ -3000,10 +2858,11 @@ async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
3000
2858
  name,
3001
2859
  inputPath,
3002
2860
  outputDir: config.outDir,
3003
- options
2861
+ options,
2862
+ skipped
3004
2863
  };
3005
2864
  }
3006
- async function getBackgroundEntrypoint(config, { inputPath, name }) {
2865
+ async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
3007
2866
  let options = {};
3008
2867
  if (inputPath !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
3009
2868
  const defaultExport = await importEntrypointFile(
@@ -3027,10 +2886,11 @@ async function getBackgroundEntrypoint(config, { inputPath, name }) {
3027
2886
  ...options,
3028
2887
  type: resolvePerBrowserOption(options.type, config.browser),
3029
2888
  persistent: resolvePerBrowserOption(options.persistent, config.browser)
3030
- }
2889
+ },
2890
+ skipped
3031
2891
  };
3032
2892
  }
3033
- async function getContentScriptEntrypoint(config, { inputPath, name }) {
2893
+ async function getContentScriptEntrypoint(config, { inputPath, name, skipped }) {
3034
2894
  const { main: _, ...options } = await importEntrypointFile(inputPath, config);
3035
2895
  if (options == null) {
3036
2896
  throw Error(
@@ -3041,8 +2901,9 @@ async function getContentScriptEntrypoint(config, { inputPath, name }) {
3041
2901
  type: "content-script",
3042
2902
  name,
3043
2903
  inputPath,
3044
- outputDir: (0, import_path.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
3045
- options
2904
+ outputDir: (0, import_path2.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
2905
+ options,
2906
+ skipped
3046
2907
  };
3047
2908
  }
3048
2909
  var PATH_GLOB_TO_TYPE_MAP = {
@@ -3089,7 +2950,7 @@ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
3089
2950
  // src/core/utils/building/generate-wxt-dir.ts
3090
2951
  var import_unimport = require("unimport");
3091
2952
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
3092
- var import_path2 = require("path");
2953
+ var import_path3 = require("path");
3093
2954
 
3094
2955
  // src/core/utils/unimport.ts
3095
2956
  var import_defu = require("defu");
@@ -3100,8 +2961,7 @@ function getUnimportOptions(config) {
3100
2961
  debugLog: config.logger.debug,
3101
2962
  imports: [
3102
2963
  { name: "defineConfig", from: "wxt" },
3103
- { name: "fakeBrowser", from: "wxt/testing" },
3104
- { name: "i18n", from: "wxt/i18n" }
2964
+ { name: "fakeBrowser", from: "wxt/testing" }
3105
2965
  ],
3106
2966
  presets: [
3107
2967
  { package: "wxt/client" },
@@ -3174,7 +3034,46 @@ function surroundInUnderscore(name) {
3174
3034
  }
3175
3035
 
3176
3036
  // src/core/utils/building/generate-wxt-dir.ts
3177
- var import_fast_glob3 = __toESM(require("fast-glob"), 1);
3037
+ var import_node_path3 = __toESM(require("path"), 1);
3038
+
3039
+ // src/core/utils/i18n.ts
3040
+ var predefinedMessages = {
3041
+ "@@extension_id": {
3042
+ message: "<browser.runtime.id>",
3043
+ description: "The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.\nNote: You can't use this message in a manifest file."
3044
+ },
3045
+ "@@ui_locale": {
3046
+ message: "<browser.i18n.getUiLocale()>",
3047
+ description: ""
3048
+ },
3049
+ "@@bidi_dir": {
3050
+ message: "<ltr|rtl>",
3051
+ description: 'The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.'
3052
+ },
3053
+ "@@bidi_reversed_dir": {
3054
+ message: "<rtl|ltr>",
3055
+ description: `If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".`
3056
+ },
3057
+ "@@bidi_start_edge": {
3058
+ message: "<left|right>",
3059
+ description: `If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".`
3060
+ },
3061
+ "@@bidi_end_edge": {
3062
+ message: "<right|left>",
3063
+ description: `If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".`
3064
+ }
3065
+ };
3066
+ function parseI18nMessages(messagesJson) {
3067
+ return Object.entries({
3068
+ ...predefinedMessages,
3069
+ ...messagesJson
3070
+ }).map(([name, details]) => ({
3071
+ name,
3072
+ ...details
3073
+ }));
3074
+ }
3075
+
3076
+ // src/core/utils/building/generate-wxt-dir.ts
3178
3077
  async function generateTypesDir(entrypoints, config) {
3179
3078
  await import_fs_extra4.default.ensureDir(config.typesDir);
3180
3079
  const references = [];
@@ -3189,7 +3088,7 @@ async function generateTypesDir(entrypoints, config) {
3189
3088
  await writeTsConfigFile(mainReference, config);
3190
3089
  }
3191
3090
  async function writeImportsDeclarationFile(config, unimportOptions) {
3192
- const filePath = (0, import_path2.resolve)(config.typesDir, "imports.d.ts");
3091
+ const filePath = (0, import_path3.resolve)(config.typesDir, "imports.d.ts");
3193
3092
  const unimport2 = (0, import_unimport.createUnimport)(unimportOptions);
3194
3093
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
3195
3094
  await writeFileIfDifferent(
@@ -3201,22 +3100,24 @@ async function writeImportsDeclarationFile(config, unimportOptions) {
3201
3100
  return filePath;
3202
3101
  }
3203
3102
  async function writePathsDeclarationFile(entrypoints, config) {
3204
- const filePath = (0, import_path2.resolve)(config.typesDir, "paths.d.ts");
3103
+ const filePath = (0, import_path3.resolve)(config.typesDir, "paths.d.ts");
3205
3104
  const unions = entrypoints.map(
3206
3105
  (entry) => getEntrypointBundlePath(
3207
3106
  entry,
3208
3107
  config.outDir,
3209
3108
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
3210
3109
  )
3211
- ).concat(await getPublicFiles(config)).map(normalizePath).map((path9) => ` | "/${path9}"`).sort().join("\n");
3110
+ ).concat(await getPublicFiles(config)).map(normalizePath).map((path10) => ` | "/${path10}"`).sort().join("\n");
3212
3111
  const template = `// Generated by wxt
3213
3112
  import "wxt/browser";
3214
3113
 
3215
3114
  declare module "wxt/browser" {
3216
3115
  export type PublicPath =
3217
3116
  {{ union }}
3117
+ type HtmlPublicPath = Extract<PublicPath, \`\${string}.html\`>
3218
3118
  export interface WxtRuntime extends Runtime.Static {
3219
3119
  getURL(path: PublicPath): string;
3120
+ getURL(path: \`\${HtmlPublicPath}\${string}\`): string;
3220
3121
  }
3221
3122
  }
3222
3123
  `;
@@ -3227,7 +3128,7 @@ declare module "wxt/browser" {
3227
3128
  return filePath;
3228
3129
  }
3229
3130
  async function writeI18nDeclarationFile(config) {
3230
- const filePath = (0, import_path2.resolve)(config.typesDir, "i18n.d.ts");
3131
+ const filePath = (0, import_path3.resolve)(config.typesDir, "i18n.d.ts");
3231
3132
  const defaultLocale = config.manifest.default_locale;
3232
3133
  const template = `// Generated by wxt
3233
3134
  import "wxt/browser";
@@ -3244,36 +3145,28 @@ declare module "wxt/browser" {
3244
3145
  }
3245
3146
 
3246
3147
  export interface WxtI18n extends I18n.Static {
3247
- {{ browserOverrides }}
3248
- }
3249
- }
3250
-
3251
- declare module "wxt/i18n" {
3252
- export interface WxtMessageSchema {
3253
- t: {
3254
- {{ translationTOverrides }}
3255
- };
3256
- tp: {
3257
- {{ translationTpOverrides }}
3258
- };
3148
+ {{ overrides }}
3259
3149
  }
3260
3150
  }
3261
3151
  `;
3262
3152
  let messages;
3263
3153
  if (defaultLocale) {
3264
- const [defaultLocalePath] = await (0, import_fast_glob3.default)(`${defaultLocale}.*`, {
3265
- cwd: config.localesDir,
3266
- absolute: true
3267
- });
3268
- messages = await readMessagesFile(defaultLocalePath);
3154
+ const defaultLocalePath = import_node_path3.default.resolve(
3155
+ config.publicDir,
3156
+ "_locales",
3157
+ defaultLocale,
3158
+ "messages.json"
3159
+ );
3160
+ const content = JSON.parse(await import_fs_extra4.default.readFile(defaultLocalePath, "utf-8"));
3161
+ messages = parseI18nMessages(content);
3269
3162
  } else {
3270
- messages = PREDEFINED_MESSAGES;
3163
+ messages = parseI18nMessages({});
3271
3164
  }
3272
3165
  const overrides = messages.map((message) => {
3273
3166
  return ` /**
3274
- * ${message.entry.description ?? "No message description."}
3167
+ * ${message.description ?? "No message description."}
3275
3168
  *
3276
- * "${message.entry.message}"
3169
+ * "${message.message}"
3277
3170
  */
3278
3171
  getMessage(
3279
3172
  messageName: "${message.name}",
@@ -3283,18 +3176,12 @@ declare module "wxt/i18n" {
3283
3176
  });
3284
3177
  await writeFileIfDifferent(
3285
3178
  filePath,
3286
- template.replace("{{ browserOverrides }}", overrides.join("\n")).replace(
3287
- "{{ translationTOverrides }}",
3288
- messages.filter((message) => !message.isPlural).map((message) => ` "${message.name}": any;`).join("\n")
3289
- ).replace(
3290
- "{{ translationTpOverrides }}",
3291
- messages.filter((message) => message.isPlural).map((message) => ` "${message.name}": any;`).join("\n")
3292
- )
3179
+ template.replace("{{ overrides }}", overrides.join("\n"))
3293
3180
  );
3294
3181
  return filePath;
3295
3182
  }
3296
3183
  async function writeGlobalsDeclarationFile(config) {
3297
- const filePath = (0, import_path2.resolve)(config.typesDir, "globals.d.ts");
3184
+ const filePath = (0, import_path3.resolve)(config.typesDir, "globals.d.ts");
3298
3185
  const globals2 = [...getGlobals(config), ...getEntrypointGlobals("")];
3299
3186
  await writeFileIfDifferent(
3300
3187
  filePath,
@@ -3310,14 +3197,14 @@ async function writeGlobalsDeclarationFile(config) {
3310
3197
  }
3311
3198
  async function writeMainDeclarationFile(references, config) {
3312
3199
  const dir = config.wxtDir;
3313
- const filePath = (0, import_path2.resolve)(dir, "wxt.d.ts");
3200
+ const filePath = (0, import_path3.resolve)(dir, "wxt.d.ts");
3314
3201
  await writeFileIfDifferent(
3315
3202
  filePath,
3316
3203
  [
3317
3204
  "// Generated by wxt",
3318
3205
  `/// <reference types="wxt/vite-builder-env" />`,
3319
3206
  ...references.map(
3320
- (ref) => `/// <reference types="./${normalizePath((0, import_path2.relative)(dir, ref))}" />`
3207
+ (ref) => `/// <reference types="./${normalizePath((0, import_path3.relative)(dir, ref))}" />`
3321
3208
  )
3322
3209
  ].join("\n") + "\n"
3323
3210
  );
@@ -3325,7 +3212,7 @@ async function writeMainDeclarationFile(references, config) {
3325
3212
  }
3326
3213
  async function writeTsConfigFile(mainReference, config) {
3327
3214
  const dir = config.wxtDir;
3328
- const getTsconfigPath = (path9) => normalizePath((0, import_path2.relative)(dir, path9));
3215
+ const getTsconfigPath = (path10) => normalizePath((0, import_path3.relative)(dir, path10));
3329
3216
  const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
3330
3217
  const aliasPath = getTsconfigPath(absolutePath);
3331
3218
  return [
@@ -3334,7 +3221,7 @@ async function writeTsConfigFile(mainReference, config) {
3334
3221
  ];
3335
3222
  }).join(",\n");
3336
3223
  await writeFileIfDifferent(
3337
- (0, import_path2.resolve)(dir, "tsconfig.json"),
3224
+ (0, import_path3.resolve)(dir, "tsconfig.json"),
3338
3225
  `{
3339
3226
  "compilerOptions": {
3340
3227
  "target": "ESNext",
@@ -3365,19 +3252,19 @@ var import_node_path7 = __toESM(require("path"), 1);
3365
3252
 
3366
3253
  // src/core/utils/cache.ts
3367
3254
  var import_fs_extra5 = __toESM(require("fs-extra"), 1);
3368
- var import_path3 = require("path");
3255
+ var import_path4 = require("path");
3369
3256
  function createFsCache(wxtDir) {
3370
- const getPath = (key) => (0, import_path3.resolve)(wxtDir, "cache", encodeURIComponent(key));
3257
+ const getPath = (key) => (0, import_path4.resolve)(wxtDir, "cache", encodeURIComponent(key));
3371
3258
  return {
3372
3259
  async set(key, value) {
3373
- const path9 = getPath(key);
3374
- await (0, import_fs_extra5.ensureDir)((0, import_path3.dirname)(path9));
3375
- await writeFileIfDifferent(path9, value);
3260
+ const path10 = getPath(key);
3261
+ await (0, import_fs_extra5.ensureDir)((0, import_path4.dirname)(path10));
3262
+ await writeFileIfDifferent(path10, value);
3376
3263
  },
3377
3264
  async get(key) {
3378
- const path9 = getPath(key);
3265
+ const path10 = getPath(key);
3379
3266
  try {
3380
- return await import_fs_extra5.default.readFile(path9, "utf-8");
3267
+ return await import_fs_extra5.default.readFile(path10, "utf-8");
3381
3268
  } catch {
3382
3269
  return void 0;
3383
3270
  }
@@ -3659,7 +3546,7 @@ async function removeEmptyDirs(dir) {
3659
3546
 
3660
3547
  // src/core/builders/vite/plugins/unimport.ts
3661
3548
  var import_unimport3 = require("unimport");
3662
- var import_path4 = require("path");
3549
+ var import_path5 = require("path");
3663
3550
  var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
3664
3551
  ".js",
3665
3552
  ".jsx",
@@ -3681,7 +3568,7 @@ function unimport(config) {
3681
3568
  async transform(code, id) {
3682
3569
  if (id.includes("node_modules"))
3683
3570
  return;
3684
- if (!ENABLED_EXTENSIONS.has((0, import_path4.extname)(id)))
3571
+ if (!ENABLED_EXTENSIONS.has((0, import_path5.extname)(id)))
3685
3572
  return;
3686
3573
  return unimport2.injectImports(code, id);
3687
3574
  }
@@ -3690,7 +3577,7 @@ function unimport(config) {
3690
3577
 
3691
3578
  // src/core/builders/vite/plugins/virtualEntrypoint.ts
3692
3579
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
3693
- var import_path5 = require("path");
3580
+ var import_path6 = require("path");
3694
3581
  function virtualEntrypoint(type, config) {
3695
3582
  const virtualId = `virtual:wxt-${type}?`;
3696
3583
  const resolvedVirtualId = `\0${virtualId}`;
@@ -3708,7 +3595,7 @@ function virtualEntrypoint(type, config) {
3708
3595
  return;
3709
3596
  const inputPath = id.replace(resolvedVirtualId, "");
3710
3597
  const template = await import_fs_extra7.default.readFile(
3711
- (0, import_path5.resolve)(
3598
+ (0, import_path6.resolve)(
3712
3599
  config.root,
3713
3600
  `node_modules/wxt/dist/virtual/${type}-entrypoint.js`
3714
3601
  ),
@@ -4085,8 +3972,8 @@ async function getInternalConfig(inlineConfig, command, server) {
4085
3972
  srcDir,
4086
3973
  mergedConfig.entrypointsDir ?? "entrypoints"
4087
3974
  );
3975
+ const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
4088
3976
  const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
4089
- const localesDir = import_node_path7.default.resolve(srcDir, mergedConfig.localesDir ?? "locales");
4090
3977
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
4091
3978
  const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
4092
3979
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
@@ -4112,6 +3999,7 @@ async function getInternalConfig(inlineConfig, command, server) {
4112
3999
  command,
4113
4000
  debug,
4114
4001
  entrypointsDir,
4002
+ filterEntrypoints,
4115
4003
  env,
4116
4004
  fsCache: createFsCache(wxtDir),
4117
4005
  imports: mergedConfig.imports ?? {},
@@ -4122,7 +4010,6 @@ async function getInternalConfig(inlineConfig, command, server) {
4122
4010
  outBaseDir,
4123
4011
  outDir,
4124
4012
  publicDir,
4125
- localesDir,
4126
4013
  root,
4127
4014
  runnerConfig,
4128
4015
  srcDir,
@@ -4186,12 +4073,12 @@ function mergeInlineConfig(inlineConfig, userConfig) {
4186
4073
  configFile: inlineConfig.configFile,
4187
4074
  debug: inlineConfig.debug ?? userConfig.debug,
4188
4075
  entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
4076
+ filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
4189
4077
  imports,
4190
4078
  logger: inlineConfig.logger ?? userConfig.logger,
4191
4079
  manifest,
4192
4080
  mode: inlineConfig.mode ?? userConfig.mode,
4193
4081
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
4194
- localesDir: inlineConfig.localesDir ?? userConfig.localesDir,
4195
4082
  runner,
4196
4083
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
4197
4084
  outDir: inlineConfig.outDir ?? userConfig.outDir,
@@ -4297,16 +4184,16 @@ ${noImports}`;
4297
4184
  var import_esbuild = require("esbuild");
4298
4185
  var import_node_url = require("url");
4299
4186
  var import_meta = {};
4300
- async function importEntrypointFile(path9, config) {
4301
- config.logger.debug("Loading file metadata:", path9);
4302
- const normalPath = normalizePath(path9);
4187
+ async function importEntrypointFile(path10, config) {
4188
+ config.logger.debug("Loading file metadata:", path10);
4189
+ const normalPath = normalizePath(path10);
4303
4190
  const unimport2 = (0, import_unimport5.createUnimport)({
4304
4191
  ...getUnimportOptions(config),
4305
4192
  // Only allow specific imports, not all from the project
4306
4193
  dirs: []
4307
4194
  });
4308
4195
  await unimport2.init();
4309
- const text = await import_fs_extra8.default.readFile(path9, "utf-8");
4196
+ const text = await import_fs_extra8.default.readFile(path10, "utf-8");
4310
4197
  const textNoImports = removeProjectImportStatements(text);
4311
4198
  const { code } = await unimport2.injectImports(textNoImports);
4312
4199
  config.logger.debug(
@@ -4349,11 +4236,19 @@ async function importEntrypointFile(path9, config) {
4349
4236
  }
4350
4237
  );
4351
4238
  try {
4352
- const res = await jiti(path9);
4239
+ const res = await jiti(path10);
4353
4240
  return res.default;
4354
4241
  } catch (err) {
4355
- config.logger.error(err);
4356
- throw err;
4242
+ if (err instanceof ReferenceError) {
4243
+ const variableName = err.message.replace(" is not defined", "");
4244
+ const filePath = (0, import_node_path8.relative)(config.root, path10);
4245
+ throw Error(
4246
+ `${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
4247
+ { cause: err }
4248
+ );
4249
+ } else {
4250
+ throw err;
4251
+ }
4357
4252
  }
4358
4253
  }
4359
4254
  function getEsbuildOptions(opts) {
@@ -4366,15 +4261,15 @@ function getEsbuildOptions(opts) {
4366
4261
  }
4367
4262
 
4368
4263
  // src/core/utils/building/internal-build.ts
4369
- var import_picocolors4 = __toESM(require("picocolors"), 1);
4264
+ var import_picocolors5 = __toESM(require("picocolors"), 1);
4370
4265
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
4371
4266
 
4372
4267
  // src/core/utils/log/printBuildSummary.ts
4373
- var import_path6 = require("path");
4268
+ var import_path7 = require("path");
4374
4269
 
4375
4270
  // src/core/utils/log/printFileList.ts
4376
4271
  var import_node_path9 = __toESM(require("path"), 1);
4377
- var import_picocolors2 = __toESM(require("picocolors"), 1);
4272
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
4378
4273
  var import_fs_extra9 = __toESM(require("fs-extra"), 1);
4379
4274
  var import_filesize = require("filesize");
4380
4275
 
@@ -4420,25 +4315,25 @@ async function printFileList(log, header, baseDir, files) {
4420
4315
  totalSize += stats.size;
4421
4316
  const size = String((0, import_filesize.filesize)(stats.size));
4422
4317
  return [
4423
- `${import_picocolors2.default.gray(prefix)} ${import_picocolors2.default.dim(parts[0])}${color(parts[1])}`,
4424
- import_picocolors2.default.dim(size)
4318
+ `${import_picocolors3.default.gray(prefix)} ${import_picocolors3.default.dim(parts[0])}${color(parts[1])}`,
4319
+ import_picocolors3.default.dim(size)
4425
4320
  ];
4426
4321
  })
4427
4322
  );
4428
- fileRows.push([`${import_picocolors2.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`]);
4323
+ fileRows.push([`${import_picocolors3.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`]);
4429
4324
  printTable(log, header, fileRows);
4430
4325
  }
4431
- var DEFAULT_COLOR = import_picocolors2.default.blue;
4326
+ var DEFAULT_COLOR = import_picocolors3.default.blue;
4432
4327
  var CHUNK_COLORS = {
4433
- ".js.map": import_picocolors2.default.gray,
4434
- ".cjs.map": import_picocolors2.default.gray,
4435
- ".mjs.map": import_picocolors2.default.gray,
4436
- ".html": import_picocolors2.default.green,
4437
- ".css": import_picocolors2.default.magenta,
4438
- ".js": import_picocolors2.default.cyan,
4439
- ".cjs": import_picocolors2.default.cyan,
4440
- ".mjs": import_picocolors2.default.cyan,
4441
- ".zip": import_picocolors2.default.yellow
4328
+ ".js.map": import_picocolors3.default.gray,
4329
+ ".cjs.map": import_picocolors3.default.gray,
4330
+ ".mjs.map": import_picocolors3.default.gray,
4331
+ ".html": import_picocolors3.default.green,
4332
+ ".css": import_picocolors3.default.magenta,
4333
+ ".js": import_picocolors3.default.cyan,
4334
+ ".cjs": import_picocolors3.default.cyan,
4335
+ ".mjs": import_picocolors3.default.cyan,
4336
+ ".zip": import_picocolors3.default.yellow
4442
4337
  };
4443
4338
  function getChunkColor(filename) {
4444
4339
  return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
@@ -4457,7 +4352,7 @@ async function printBuildSummary(log, header, output, config) {
4457
4352
  return diff;
4458
4353
  return l.fileName.localeCompare(r.fileName);
4459
4354
  });
4460
- const files = chunks.map((chunk) => (0, import_path6.resolve)(config.outDir, chunk.fileName));
4355
+ const files = chunks.map((chunk) => (0, import_path7.resolve)(config.outDir, chunk.fileName));
4461
4356
  await printFileList(log, header, config.outDir, files);
4462
4357
  }
4463
4358
  var DEFAULT_SORT_WEIGHT = 100;
@@ -4475,20 +4370,20 @@ function getChunkSortWeight(filename) {
4475
4370
  }
4476
4371
 
4477
4372
  // src/core/utils/log/printHeader.ts
4478
- var import_picocolors3 = __toESM(require("picocolors"), 1);
4373
+ var import_picocolors4 = __toESM(require("picocolors"), 1);
4479
4374
 
4480
4375
  // package.json
4481
- var version = "0.14.2-alpha2";
4376
+ var version = "0.14.3";
4482
4377
 
4483
4378
  // src/core/utils/log/printHeader.ts
4484
4379
  var import_consola2 = require("consola");
4485
4380
 
4486
4381
  // src/core/utils/building/internal-build.ts
4487
- var import_fast_glob4 = __toESM(require("fast-glob"), 1);
4382
+ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
4488
4383
 
4489
4384
  // src/core/utils/manifest.ts
4490
4385
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
4491
- var import_path7 = require("path");
4386
+ var import_path8 = require("path");
4492
4387
 
4493
4388
  // src/core/utils/content-security-policy.ts
4494
4389
  var ContentSecurityPolicy = class _ContentSecurityPolicy {
@@ -4612,7 +4507,7 @@ var import_defu3 = __toESM(require("defu"), 1);
4612
4507
  async function writeManifest(manifest, output, config) {
4613
4508
  const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
4614
4509
  await import_fs_extra11.default.ensureDir(config.outDir);
4615
- await writeFileIfDifferent((0, import_path7.resolve)(config.outDir, "manifest.json"), str);
4510
+ await writeFileIfDifferent((0, import_path8.resolve)(config.outDir, "manifest.json"), str);
4616
4511
  output.publicAssets.unshift({
4617
4512
  type: "asset",
4618
4513
  fileName: "manifest.json"
@@ -5059,7 +4954,7 @@ async function internalBuild(config) {
5059
4954
  const verb = config.command === "serve" ? "Pre-rendering" : "Building";
5060
4955
  const target = `${config.browser}-mv${config.manifestVersion}`;
5061
4956
  config.logger.info(
5062
- `${verb} ${import_picocolors4.default.cyan(target)} for ${import_picocolors4.default.cyan(config.mode)} with ${import_picocolors4.default.green(
4957
+ `${verb} ${import_picocolors5.default.cyan(target)} for ${import_picocolors5.default.cyan(config.mode)} with ${import_picocolors5.default.green(
5063
4958
  `${config.builder.name} ${config.builder.version}`
5064
4959
  )}`
5065
4960
  );
@@ -5080,14 +4975,14 @@ async function internalBuild(config) {
5080
4975
  await combineAnalysisStats(config);
5081
4976
  config.logger.info(
5082
4977
  `Analysis complete:
5083
- ${import_picocolors4.default.gray("\u2514\u2500")} ${import_picocolors4.default.yellow("stats.html")}`
4978
+ ${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow("stats.html")}`
5084
4979
  );
5085
4980
  }
5086
4981
  return output;
5087
4982
  }
5088
4983
  async function combineAnalysisStats(config) {
5089
4984
  const { execaCommand: execaCommand2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
5090
- const unixFiles = await (0, import_fast_glob4.default)(`stats-*.json`, {
4985
+ const unixFiles = await (0, import_fast_glob3.default)(`stats-*.json`, {
5091
4986
  cwd: config.outDir,
5092
4987
  absolute: true
5093
4988
  });
@@ -5106,10 +5001,10 @@ async function build(config) {
5106
5001
 
5107
5002
  // src/core/clean.ts
5108
5003
  var import_node_path13 = __toESM(require("path"), 1);
5109
- var import_fast_glob5 = __toESM(require("fast-glob"), 1);
5004
+ var import_fast_glob4 = __toESM(require("fast-glob"), 1);
5110
5005
  var import_fs_extra13 = __toESM(require("fs-extra"), 1);
5111
5006
  var import_consola3 = require("consola");
5112
- var import_picocolors5 = __toESM(require("picocolors"), 1);
5007
+ var import_picocolors6 = __toESM(require("picocolors"), 1);
5113
5008
  async function clean(root = process.cwd()) {
5114
5009
  import_consola3.consola.info("Cleaning Project");
5115
5010
  const tempDirs = [
@@ -5118,8 +5013,8 @@ async function clean(root = process.cwd()) {
5118
5013
  "**/.wxt",
5119
5014
  ".output/*"
5120
5015
  ];
5121
- import_consola3.consola.debug("Looking for:", tempDirs.map(import_picocolors5.default.cyan).join(", "));
5122
- const directories = await (0, import_fast_glob5.default)(tempDirs, {
5016
+ import_consola3.consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
5017
+ const directories = await (0, import_fast_glob4.default)(tempDirs, {
5123
5018
  cwd: import_node_path13.default.resolve(root),
5124
5019
  absolute: true,
5125
5020
  onlyDirectories: true,
@@ -5131,11 +5026,11 @@ async function clean(root = process.cwd()) {
5131
5026
  }
5132
5027
  import_consola3.consola.debug(
5133
5028
  "Found:",
5134
- directories.map((dir) => import_picocolors5.default.cyan(import_node_path13.default.relative(root, dir))).join(", ")
5029
+ directories.map((dir) => import_picocolors6.default.cyan(import_node_path13.default.relative(root, dir))).join(", ")
5135
5030
  );
5136
5031
  for (const directory of directories) {
5137
5032
  await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
5138
- import_consola3.consola.debug("Deleted " + import_picocolors5.default.cyan(import_node_path13.default.relative(root, directory)));
5033
+ import_consola3.consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path13.default.relative(root, directory)));
5139
5034
  }
5140
5035
  }
5141
5036
 
@@ -5280,7 +5175,7 @@ async function createExtensionRunner(config) {
5280
5175
  // src/core/create-server.ts
5281
5176
  var import_consola4 = require("consola");
5282
5177
  var import_async_mutex = require("async-mutex");
5283
- var import_picocolors6 = __toESM(require("picocolors"), 1);
5178
+ var import_picocolors7 = __toESM(require("picocolors"), 1);
5284
5179
  var import_node_path17 = require("path");
5285
5180
  async function createServer(inlineConfig) {
5286
5181
  const port = await getPort();
@@ -5311,8 +5206,8 @@ async function createServer(inlineConfig) {
5311
5206
  reloadContentScript(contentScript) {
5312
5207
  server.ws.send("wxt:reload-content-script", contentScript);
5313
5208
  },
5314
- reloadPage(path9) {
5315
- server.ws.send("wxt:reload-page", path9);
5209
+ reloadPage(path10) {
5210
+ server.ws.send("wxt:reload-page", path10);
5316
5211
  },
5317
5212
  reloadExtension() {
5318
5213
  server.ws.send("wxt:reload-extension");
@@ -5347,12 +5242,12 @@ function createFileReloader(options) {
5347
5242
  const { server, getLatestConfig, updateConfig } = options;
5348
5243
  const fileChangedMutex = new import_async_mutex.Mutex();
5349
5244
  const changeQueue = [];
5350
- return async (event, path9) => {
5245
+ return async (event, path10) => {
5351
5246
  const config = await getLatestConfig();
5352
5247
  updateConfig(config);
5353
- if (path9.startsWith(config.outBaseDir))
5248
+ if (path10.startsWith(config.outBaseDir))
5354
5249
  return;
5355
- changeQueue.push([event, path9]);
5250
+ changeQueue.push([event, path10]);
5356
5251
  await fileChangedMutex.runExclusive(async () => {
5357
5252
  const fileChanges = changeQueue.splice(0, changeQueue.length);
5358
5253
  if (fileChanges.length === 0)
@@ -5361,13 +5256,13 @@ function createFileReloader(options) {
5361
5256
  if (changes.type === "no-change")
5362
5257
  return;
5363
5258
  config.logger.info(
5364
- `Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors6.default.dim((0, import_node_path17.relative)(config.root, file))).join(", ")}`
5259
+ `Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors7.default.dim((0, import_node_path17.relative)(config.root, file))).join(", ")}`
5365
5260
  );
5366
5261
  const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
5367
- return import_picocolors6.default.cyan(
5262
+ return import_picocolors7.default.cyan(
5368
5263
  (0, import_node_path17.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
5369
5264
  );
5370
- }).join(import_picocolors6.default.dim(", "));
5265
+ }).join(import_picocolors7.default.dim(", "));
5371
5266
  const allEntrypoints = await findEntrypoints(config);
5372
5267
  const { output: newOutput } = await rebuild(
5373
5268
  config,
@@ -5424,8 +5319,8 @@ function reloadContentScripts(steps, config, server) {
5424
5319
  }
5425
5320
  function reloadHtmlPages(groups, server, config) {
5426
5321
  groups.flat().forEach((entry) => {
5427
- const path9 = getEntrypointBundlePath(entry, config.outDir, ".html");
5428
- server.reloadPage(path9);
5322
+ const path10 = getEntrypointBundlePath(entry, config.outDir, ".html");
5323
+ server.reloadPage(path10);
5429
5324
  });
5430
5325
  }
5431
5326
 
@@ -5435,7 +5330,7 @@ var import_consola5 = require("consola");
5435
5330
  var import_giget = require("giget");
5436
5331
  var import_fs_extra14 = __toESM(require("fs-extra"), 1);
5437
5332
  var import_node_path18 = __toESM(require("path"), 1);
5438
- var import_picocolors7 = __toESM(require("picocolors"), 1);
5333
+ var import_picocolors8 = __toESM(require("picocolors"), 1);
5439
5334
  async function initialize(options) {
5440
5335
  import_consola5.consola.info("Initalizing new project");
5441
5336
  const templates = await listTemplates();
@@ -5464,11 +5359,11 @@ async function initialize(options) {
5464
5359
  type: () => options.packageManager == null ? "select" : void 0,
5465
5360
  message: "Package Manager",
5466
5361
  choices: [
5467
- { title: import_picocolors7.default.red("npm"), value: "npm" },
5468
- { title: import_picocolors7.default.yellow("pnpm"), value: "pnpm" },
5469
- { title: import_picocolors7.default.cyan("yarn"), value: "yarn" },
5362
+ { title: import_picocolors8.default.red("npm"), value: "npm" },
5363
+ { title: import_picocolors8.default.yellow("pnpm"), value: "pnpm" },
5364
+ { title: import_picocolors8.default.cyan("yarn"), value: "yarn" },
5470
5365
  {
5471
- title: `${import_picocolors7.default.magenta("bun")}${import_picocolors7.default.gray(" (experimental)")}`,
5366
+ title: `${import_picocolors8.default.magenta("bun")}${import_picocolors8.default.gray(" (experimental)")}`,
5472
5367
  value: "bun"
5473
5368
  }
5474
5369
  ]
@@ -5491,8 +5386,8 @@ async function initialize(options) {
5491
5386
  import_consola5.consola.log("Next steps:");
5492
5387
  let step = 0;
5493
5388
  if (cdPath !== "")
5494
- import_consola5.consola.log(` ${++step}.`, import_picocolors7.default.cyan(`cd ${cdPath}`));
5495
- import_consola5.consola.log(` ${++step}.`, import_picocolors7.default.cyan(`${input.packageManager} install`));
5389
+ import_consola5.consola.log(` ${++step}.`, import_picocolors8.default.cyan(`cd ${cdPath}`));
5390
+ import_consola5.consola.log(` ${++step}.`, import_picocolors8.default.cyan(`${input.packageManager} install`));
5496
5391
  console.log();
5497
5392
  }
5498
5393
  async function listTemplates() {
@@ -5546,11 +5441,11 @@ async function cloneProject({
5546
5441
  }
5547
5442
  }
5548
5443
  var TEMPLATE_COLORS = {
5549
- vanilla: import_picocolors7.default.blue,
5550
- vue: import_picocolors7.default.green,
5551
- react: import_picocolors7.default.cyan,
5552
- svelte: import_picocolors7.default.red,
5553
- solid: import_picocolors7.default.blue
5444
+ vanilla: import_picocolors8.default.blue,
5445
+ vue: import_picocolors8.default.green,
5446
+ react: import_picocolors8.default.cyan,
5447
+ svelte: import_picocolors8.default.red,
5448
+ solid: import_picocolors8.default.blue
5554
5449
  };
5555
5450
  var TEMPLATE_SORT_WEIGHT = {
5556
5451
  vanilla: 0,
@@ -5601,8 +5496,8 @@ async function zip(config) {
5601
5496
  );
5602
5497
  await (0, import_zip_dir.default)(internalConfig.zip.sourcesRoot, {
5603
5498
  saveTo: sourcesZipPath,
5604
- filter(path9) {
5605
- const relativePath = (0, import_node_path19.relative)(internalConfig.zip.sourcesRoot, path9);
5499
+ filter(path10) {
5500
+ const relativePath = (0, import_node_path19.relative)(internalConfig.zip.sourcesRoot, path10);
5606
5501
  const matchedPattern = internalConfig.zip.ignoredSources.find(
5607
5502
  (pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
5608
5503
  );