wxt 0.17.10 → 0.17.12

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/README.md CHANGED
@@ -29,6 +29,8 @@
29
29
  <a href="https://wxt.dev/api/config.html" target="_blank">Configuration</a>
30
30
  &bull;
31
31
  <a href="https://wxt.dev/examples.html" target="_blank">Examples</a>
32
+ &bull;
33
+ <a href="https://discord.gg/ZFsZqGery9" target="_blank">Discord</a>
32
34
  </p>
33
35
 
34
36
  ![Example CLI Output](./docs/assets/cli-output.png)
@@ -0,0 +1,22 @@
1
+ // src/core/utils/arrays.ts
2
+ function every(array, predicate) {
3
+ for (let i = 0; i < array.length; i++)
4
+ if (!predicate(array[i], i))
5
+ return false;
6
+ return true;
7
+ }
8
+ function some(array, predicate) {
9
+ for (let i = 0; i < array.length; i++)
10
+ if (predicate(array[i], i))
11
+ return true;
12
+ return false;
13
+ }
14
+ function toArray(a) {
15
+ return Array.isArray(a) ? a : [a];
16
+ }
17
+
18
+ export {
19
+ every,
20
+ some,
21
+ toArray
22
+ };
@@ -1,9 +1,14 @@
1
+ import {
2
+ every,
3
+ some,
4
+ toArray
5
+ } from "./chunk-5X3S6AWF.js";
1
6
  import {
2
7
  __require
3
8
  } from "./chunk-VBXJIVYU.js";
4
9
 
5
10
  // package.json
6
- var version = "0.17.10";
11
+ var version = "0.17.12";
7
12
 
8
13
  // src/core/utils/paths.ts
9
14
  import systemPath from "node:path";
@@ -488,32 +493,50 @@ async function removeEmptyDirs(dir) {
488
493
  }
489
494
  }
490
495
 
491
- // src/core/builders/vite/plugins/virtualEntrypoint.ts
496
+ // src/core/utils/virtual-modules.ts
497
+ var virtualEntrypointTypes = [
498
+ "content-script-main-world",
499
+ "content-script-isolated-world",
500
+ "background",
501
+ "unlisted-script"
502
+ ];
503
+ var virtualEntrypointModuleNames = virtualEntrypointTypes.map(
504
+ (name) => `${name}-entrypoint`
505
+ );
506
+ var virtualModuleNames = [
507
+ ...virtualEntrypointModuleNames,
508
+ "mock-browser",
509
+ "reload-html"
510
+ ];
511
+
512
+ // src/core/builders/vite/plugins/resolveVirtualModules.ts
492
513
  import fs2 from "fs-extra";
493
514
  import { resolve as resolve4 } from "path";
494
- function virtualEntrypoint(type, config) {
495
- const virtualId = `virtual:wxt-${type}?`;
496
- const resolvedVirtualId = `\0${virtualId}`;
497
- return {
498
- name: `wxt:virtual-entrypoint`,
499
- resolveId(id) {
500
- const index = id.indexOf(virtualId);
501
- if (index === -1)
502
- return;
503
- const inputPath = normalizePath(id.substring(index + virtualId.length));
504
- return resolvedVirtualId + inputPath;
505
- },
506
- async load(id) {
507
- if (!id.startsWith(resolvedVirtualId))
508
- return;
509
- const inputPath = id.replace(resolvedVirtualId, "");
510
- const template = await fs2.readFile(
511
- resolve4(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
512
- "utf-8"
513
- );
514
- return template.replace(`virtual:user-${type}`, inputPath);
515
- }
516
- };
515
+ function resolveVirtualModules(config) {
516
+ return virtualModuleNames.map((name) => {
517
+ const virtualId = `virtual:wxt-${name}?`;
518
+ const resolvedVirtualId = "\0" + virtualId;
519
+ return {
520
+ name: `wxt:resolve-virtual-${name}`,
521
+ resolveId(id) {
522
+ const index = id.indexOf(virtualId);
523
+ if (index === -1)
524
+ return;
525
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
526
+ return resolvedVirtualId + inputPath;
527
+ },
528
+ async load(id) {
529
+ if (!id.startsWith(resolvedVirtualId))
530
+ return;
531
+ const inputPath = id.replace(resolvedVirtualId, "");
532
+ const template = await fs2.readFile(
533
+ resolve4(config.wxtModuleDir, `dist/virtual/${name}.js`),
534
+ "utf-8"
535
+ );
536
+ return template.replace(`virtual:user-${name}`, inputPath);
537
+ }
538
+ };
539
+ });
517
540
  }
518
541
 
519
542
  // src/core/utils/constants.ts
@@ -656,7 +679,7 @@ async function buildEntrypoints(groups, spinner) {
656
679
  const steps = [];
657
680
  for (let i = 0; i < groups.length; i++) {
658
681
  const group = groups[i];
659
- const groupNames = [group].flat().map((e) => e.name);
682
+ const groupNames = toArray(group).map((e) => e.name);
660
683
  const groupNameColored = groupNames.join(pc.dim(", "));
661
684
  spinner.text = pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
662
685
  try {
@@ -688,20 +711,6 @@ async function copyPublicDirectory() {
688
711
  return publicAssets;
689
712
  }
690
713
 
691
- // src/core/utils/arrays.ts
692
- function every(array, predicate) {
693
- for (let i = 0; i < array.length; i++)
694
- if (!predicate(array[i], i))
695
- return false;
696
- return true;
697
- }
698
- function some(array, predicate) {
699
- for (let i = 0; i < array.length; i++)
700
- if (predicate(array[i], i))
701
- return true;
702
- return false;
703
- }
704
-
705
714
  // src/core/utils/building/detect-dev-changes.ts
706
715
  function detectDevChanges(changedFiles, currentOutput) {
707
716
  const isConfigChange = some(
@@ -2069,6 +2078,9 @@ function mapWxtOptionsToRegisteredContentScript(options, js, css) {
2069
2078
  world: options.world
2070
2079
  };
2071
2080
  }
2081
+ function getContentScriptJs(config, entrypoint) {
2082
+ return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
2083
+ }
2072
2084
 
2073
2085
  // src/core/utils/manifest.ts
2074
2086
  import defu2 from "defu";
@@ -2982,15 +2994,19 @@ var packageManagers = {
2982
2994
  };
2983
2995
 
2984
2996
  // src/core/builders/vite/index.ts
2985
- async function createViteBuilder(wxtConfig, server) {
2997
+ async function createViteBuilder(wxtConfig, hooks, server) {
2986
2998
  const vite = await import("vite");
2987
2999
  const getBaseConfig = async () => {
2988
- const config = await wxtConfig.vite(wxtConfig.env);
3000
+ const config = await wxtConfig.vite({
3001
+ ...wxtConfig.env
3002
+ });
2989
3003
  config.root = wxtConfig.root;
2990
3004
  config.configFile = false;
2991
3005
  config.logLevel = "warn";
2992
3006
  config.mode = wxtConfig.mode;
2993
3007
  config.build ??= {};
3008
+ config.publicDir = wxtConfig.publicDir;
3009
+ config.build.copyPublicDir = false;
2994
3010
  config.build.outDir = wxtConfig.outDir;
2995
3011
  config.build.emptyOutDir = false;
2996
3012
  if (config.build.minify == null && wxtConfig.command === "serve") {
@@ -3004,10 +3020,7 @@ async function createViteBuilder(wxtConfig, server) {
3004
3020
  download(wxtConfig),
3005
3021
  devHtmlPrerender(wxtConfig, server),
3006
3022
  unimport(wxtConfig),
3007
- virtualEntrypoint("background", wxtConfig),
3008
- virtualEntrypoint("content-script-isolated-world", wxtConfig),
3009
- virtualEntrypoint("content-script-main-world", wxtConfig),
3010
- virtualEntrypoint("unlisted-script", wxtConfig),
3023
+ resolveVirtualModules(wxtConfig),
3011
3024
  devServerGlobals(wxtConfig, server),
3012
3025
  tsconfigPaths(wxtConfig),
3013
3026
  noopBackground(),
@@ -3131,6 +3144,11 @@ async function createViteBuilder(wxtConfig, server) {
3131
3144
  else
3132
3145
  entryConfig = getLibModeConfig(group);
3133
3146
  const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
3147
+ await hooks.callHook(
3148
+ "vite:build:extendConfig",
3149
+ toArray(group),
3150
+ buildConfig
3151
+ );
3134
3152
  const result = await vite.build(buildConfig);
3135
3153
  return {
3136
3154
  entrypoints: group,
@@ -3147,9 +3165,9 @@ async function createViteBuilder(wxtConfig, server) {
3147
3165
  }
3148
3166
  };
3149
3167
  const baseConfig = await getBaseConfig();
3150
- const viteServer = await vite.createServer(
3151
- vite.mergeConfig(baseConfig, serverConfig)
3152
- );
3168
+ const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
3169
+ await hooks.callHook("vite:devServer:extendConfig", finalConfig);
3170
+ const viteServer = await vite.createServer(finalConfig);
3153
3171
  const server2 = {
3154
3172
  async listen() {
3155
3173
  await viteServer.listen(info.port);
@@ -3192,7 +3210,11 @@ function getRollupEntry(entrypoint) {
3192
3210
  virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
3193
3211
  break;
3194
3212
  }
3195
- return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
3213
+ if (virtualEntrypointType) {
3214
+ const moduleId = `virtual:wxt-${virtualEntrypointType}-entrypoint`;
3215
+ return `${moduleId}?${entrypoint.inputPath}`;
3216
+ }
3217
+ return entrypoint.inputPath;
3196
3218
  }
3197
3219
 
3198
3220
  // src/core/wxt.ts
@@ -3201,7 +3223,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
3201
3223
  const hooks = createHooks();
3202
3224
  const config = await resolveConfig(inlineConfig, command);
3203
3225
  const server = await getServer?.(config);
3204
- const builder = await createViteBuilder(config, server);
3226
+ const builder = await createViteBuilder(config, hooks, server);
3205
3227
  const pm = await createWxtPackageManager(config.root);
3206
3228
  wxt = {
3207
3229
  config,
@@ -3242,6 +3264,7 @@ export {
3242
3264
  printFileList,
3243
3265
  version,
3244
3266
  mapWxtOptionsToRegisteredContentScript,
3267
+ getContentScriptJs,
3245
3268
  getContentScriptCssFiles,
3246
3269
  getContentScriptsCssMap,
3247
3270
  rebuild,
package/dist/cli.js CHANGED
@@ -593,32 +593,50 @@ function unimport(config) {
593
593
  };
594
594
  }
595
595
 
596
- // src/core/builders/vite/plugins/virtualEntrypoint.ts
596
+ // src/core/utils/virtual-modules.ts
597
+ var virtualEntrypointTypes = [
598
+ "content-script-main-world",
599
+ "content-script-isolated-world",
600
+ "background",
601
+ "unlisted-script"
602
+ ];
603
+ var virtualEntrypointModuleNames = virtualEntrypointTypes.map(
604
+ (name) => `${name}-entrypoint`
605
+ );
606
+ var virtualModuleNames = [
607
+ ...virtualEntrypointModuleNames,
608
+ "mock-browser",
609
+ "reload-html"
610
+ ];
611
+
612
+ // src/core/builders/vite/plugins/resolveVirtualModules.ts
597
613
  import fs2 from "fs-extra";
598
614
  import { resolve as resolve4 } from "path";
599
- function virtualEntrypoint(type, config) {
600
- const virtualId = `virtual:wxt-${type}?`;
601
- const resolvedVirtualId = `\0${virtualId}`;
602
- return {
603
- name: `wxt:virtual-entrypoint`,
604
- resolveId(id) {
605
- const index = id.indexOf(virtualId);
606
- if (index === -1)
607
- return;
608
- const inputPath = normalizePath(id.substring(index + virtualId.length));
609
- return resolvedVirtualId + inputPath;
610
- },
611
- async load(id) {
612
- if (!id.startsWith(resolvedVirtualId))
613
- return;
614
- const inputPath = id.replace(resolvedVirtualId, "");
615
- const template = await fs2.readFile(
616
- resolve4(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
617
- "utf-8"
618
- );
619
- return template.replace(`virtual:user-${type}`, inputPath);
620
- }
621
- };
615
+ function resolveVirtualModules(config) {
616
+ return virtualModuleNames.map((name) => {
617
+ const virtualId = `virtual:wxt-${name}?`;
618
+ const resolvedVirtualId = "\0" + virtualId;
619
+ return {
620
+ name: `wxt:resolve-virtual-${name}`,
621
+ resolveId(id) {
622
+ const index = id.indexOf(virtualId);
623
+ if (index === -1)
624
+ return;
625
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
626
+ return resolvedVirtualId + inputPath;
627
+ },
628
+ async load(id) {
629
+ if (!id.startsWith(resolvedVirtualId))
630
+ return;
631
+ const inputPath = id.replace(resolvedVirtualId, "");
632
+ const template = await fs2.readFile(
633
+ resolve4(config.wxtModuleDir, `dist/virtual/${name}.js`),
634
+ "utf-8"
635
+ );
636
+ return template.replace(`virtual:user-${name}`, inputPath);
637
+ }
638
+ };
639
+ });
622
640
  }
623
641
 
624
642
  // src/core/builders/vite/plugins/tsconfigPaths.ts
@@ -822,16 +840,40 @@ function defineImportMeta() {
822
840
  };
823
841
  }
824
842
 
843
+ // src/core/utils/arrays.ts
844
+ function every(array, predicate) {
845
+ for (let i = 0; i < array.length; i++)
846
+ if (!predicate(array[i], i))
847
+ return false;
848
+ return true;
849
+ }
850
+ function some(array, predicate) {
851
+ for (let i = 0; i < array.length; i++)
852
+ if (predicate(array[i], i))
853
+ return true;
854
+ return false;
855
+ }
856
+ function toArray(a) {
857
+ return Array.isArray(a) ? a : [a];
858
+ }
859
+ function filterTruthy(array) {
860
+ return array.filter((item) => !!item);
861
+ }
862
+
825
863
  // src/core/builders/vite/index.ts
826
- async function createViteBuilder(wxtConfig, server) {
864
+ async function createViteBuilder(wxtConfig, hooks, server) {
827
865
  const vite = await import("vite");
828
866
  const getBaseConfig = async () => {
829
- const config = await wxtConfig.vite(wxtConfig.env);
867
+ const config = await wxtConfig.vite({
868
+ ...wxtConfig.env
869
+ });
830
870
  config.root = wxtConfig.root;
831
871
  config.configFile = false;
832
872
  config.logLevel = "warn";
833
873
  config.mode = wxtConfig.mode;
834
874
  config.build ??= {};
875
+ config.publicDir = wxtConfig.publicDir;
876
+ config.build.copyPublicDir = false;
835
877
  config.build.outDir = wxtConfig.outDir;
836
878
  config.build.emptyOutDir = false;
837
879
  if (config.build.minify == null && wxtConfig.command === "serve") {
@@ -845,10 +887,7 @@ async function createViteBuilder(wxtConfig, server) {
845
887
  download(wxtConfig),
846
888
  devHtmlPrerender(wxtConfig, server),
847
889
  unimport(wxtConfig),
848
- virtualEntrypoint("background", wxtConfig),
849
- virtualEntrypoint("content-script-isolated-world", wxtConfig),
850
- virtualEntrypoint("content-script-main-world", wxtConfig),
851
- virtualEntrypoint("unlisted-script", wxtConfig),
890
+ resolveVirtualModules(wxtConfig),
852
891
  devServerGlobals(wxtConfig, server),
853
892
  tsconfigPaths(wxtConfig),
854
893
  noopBackground(),
@@ -972,6 +1011,11 @@ async function createViteBuilder(wxtConfig, server) {
972
1011
  else
973
1012
  entryConfig = getLibModeConfig(group);
974
1013
  const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
1014
+ await hooks.callHook(
1015
+ "vite:build:extendConfig",
1016
+ toArray(group),
1017
+ buildConfig
1018
+ );
975
1019
  const result = await vite.build(buildConfig);
976
1020
  return {
977
1021
  entrypoints: group,
@@ -988,9 +1032,9 @@ async function createViteBuilder(wxtConfig, server) {
988
1032
  }
989
1033
  };
990
1034
  const baseConfig = await getBaseConfig();
991
- const viteServer = await vite.createServer(
992
- vite.mergeConfig(baseConfig, serverConfig)
993
- );
1035
+ const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
1036
+ await hooks.callHook("vite:devServer:extendConfig", finalConfig);
1037
+ const viteServer = await vite.createServer(finalConfig);
994
1038
  const server2 = {
995
1039
  async listen() {
996
1040
  await viteServer.listen(info.port);
@@ -1033,7 +1077,11 @@ function getRollupEntry(entrypoint) {
1033
1077
  virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
1034
1078
  break;
1035
1079
  }
1036
- return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
1080
+ if (virtualEntrypointType) {
1081
+ const moduleId = `virtual:wxt-${virtualEntrypointType}-entrypoint`;
1082
+ return `${moduleId}?${entrypoint.inputPath}`;
1083
+ }
1084
+ return entrypoint.inputPath;
1037
1085
  }
1038
1086
 
1039
1087
  // src/core/wxt.ts
@@ -1042,7 +1090,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
1042
1090
  const hooks = createHooks();
1043
1091
  const config = await resolveConfig(inlineConfig, command);
1044
1092
  const server = await getServer?.(config);
1045
- const builder = await createViteBuilder(config, server);
1093
+ const builder = await createViteBuilder(config, hooks, server);
1046
1094
  const pm = await createWxtPackageManager(config.root);
1047
1095
  wxt = {
1048
1096
  config,
@@ -1083,7 +1131,7 @@ async function buildEntrypoints(groups, spinner) {
1083
1131
  const steps = [];
1084
1132
  for (let i = 0; i < groups.length; i++) {
1085
1133
  const group = groups[i];
1086
- const groupNames = [group].flat().map((e) => e.name);
1134
+ const groupNames = toArray(group).map((e) => e.name);
1087
1135
  const groupNameColored = groupNames.join(pc.dim(", "));
1088
1136
  spinner.text = pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
1089
1137
  try {
@@ -1115,20 +1163,6 @@ async function copyPublicDirectory() {
1115
1163
  return publicAssets;
1116
1164
  }
1117
1165
 
1118
- // src/core/utils/arrays.ts
1119
- function every(array, predicate) {
1120
- for (let i = 0; i < array.length; i++)
1121
- if (!predicate(array[i], i))
1122
- return false;
1123
- return true;
1124
- }
1125
- function some(array, predicate) {
1126
- for (let i = 0; i < array.length; i++)
1127
- if (predicate(array[i], i))
1128
- return true;
1129
- return false;
1130
- }
1131
-
1132
1166
  // src/core/utils/building/detect-dev-changes.ts
1133
1167
  function detectDevChanges(changedFiles, currentOutput) {
1134
1168
  const isConfigChange = some(
@@ -2386,7 +2420,7 @@ function getChunkSortWeight(filename) {
2386
2420
  import pc4 from "picocolors";
2387
2421
 
2388
2422
  // package.json
2389
- var version = "0.17.10";
2423
+ var version = "0.17.12";
2390
2424
 
2391
2425
  // src/core/utils/log/printHeader.ts
2392
2426
  import { consola as consola2 } from "consola";
@@ -2505,6 +2539,9 @@ function mapWxtOptionsToRegisteredContentScript(options, js, css) {
2505
2539
  world: options.world
2506
2540
  };
2507
2541
  }
2542
+ function getContentScriptJs(config, entrypoint) {
2543
+ return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
2544
+ }
2508
2545
 
2509
2546
  // src/core/utils/manifest.ts
2510
2547
  import defu2 from "defu";
@@ -3546,7 +3583,7 @@ function reloadContentScripts(steps, server) {
3546
3583
  const entry = step.entrypoints;
3547
3584
  if (Array.isArray(entry) || entry.type !== "content-script")
3548
3585
  return;
3549
- const js = [getEntrypointBundlePath(entry, wxt.config.outDir, ".js")];
3586
+ const js = getContentScriptJs(wxt.config, entry);
3550
3587
  const cssMap = getContentScriptsCssMap(server.currentOutput, [entry]);
3551
3588
  const css = getContentScriptCssFiles([entry], cssMap);
3552
3589
  server.reloadContentScript({
@@ -3889,8 +3926,8 @@ function wrapAction(cb, options) {
3889
3926
  };
3890
3927
  }
3891
3928
  function getArrayFromFlags(flags, name) {
3892
- const array = [flags[name]].flat();
3893
- const result = array.filter((item) => item != null);
3929
+ const array = toArray(flags[name]);
3930
+ const result = filterTruthy(array);
3894
3931
  return result.length ? result : void 0;
3895
3932
  }
3896
3933
  var aliasCommandNames = /* @__PURE__ */ new Set();
package/dist/client.js CHANGED
@@ -244,10 +244,13 @@ function createIntegratedUi(ctx, options) {
244
244
  const remove = () => {
245
245
  options.onRemove?.(mounted);
246
246
  wrapper.remove();
247
+ mounted = void 0;
247
248
  };
248
249
  ctx.onInvalidated(remove);
249
250
  return {
250
- mounted,
251
+ get mounted() {
252
+ return mounted;
253
+ },
251
254
  wrapper,
252
255
  mount,
253
256
  remove
@@ -268,10 +271,13 @@ function createIframeUi(ctx, options) {
268
271
  const remove = () => {
269
272
  options.onRemove?.(mounted);
270
273
  wrapper.remove();
274
+ mounted = void 0;
271
275
  };
272
276
  ctx.onInvalidated(remove);
273
277
  return {
274
- mounted,
278
+ get mounted() {
279
+ return mounted;
280
+ },
275
281
  iframe,
276
282
  wrapper,
277
283
  mount,
@@ -308,6 +314,7 @@ async function createShadowRootUi(ctx, options) {
308
314
  shadowHost.remove();
309
315
  while (uiContainer.lastChild)
310
316
  uiContainer.removeChild(uiContainer.lastChild);
317
+ mounted = void 0;
311
318
  };
312
319
  ctx.onInvalidated(remove);
313
320
  return {
@@ -316,7 +323,9 @@ async function createShadowRootUi(ctx, options) {
316
323
  uiContainer,
317
324
  mount,
318
325
  remove,
319
- mounted
326
+ get mounted() {
327
+ return mounted;
328
+ }
320
329
  };
321
330
  }
322
331
  function applyPosition(root, positionedElement, options) {
@@ -291,7 +291,7 @@ interface InlineConfig {
291
291
  *
292
292
  * @example
293
293
  * [
294
- * "coverage", // Ignore the coverage directory in the `sourcesRoot`
294
+ * "coverage", // Include the coverage directory in the `sourcesRoot`
295
295
  * ]
296
296
  */
297
297
  excludeSources?: string[];
@@ -967,6 +967,23 @@ interface ServerInfo {
967
967
  origin: string;
968
968
  }
969
969
  type HookResult = Promise<void> | void;
970
+ interface WxtHooks {
971
+ /**
972
+ * Called when WXT has created Vite's config for a build step. Useful if you
973
+ * want to add plugins or update the vite config per entrypoint group.
974
+ *
975
+ * @param entrypoints The list of entrypoints being built with the provided config.
976
+ * @param viteConfig The config that will be used for the dev server.
977
+ */
978
+ 'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
979
+ /**
980
+ * Called when WXT has created Vite's config for the dev server. Useful if
981
+ * you want to add plugins or update the vite config per entrypoint group.
982
+ *
983
+ * @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
984
+ */
985
+ 'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
986
+ }
970
987
  interface WxtHooks {
971
988
  /**
972
989
  * Called after WXT initialization, when the WXT instance is ready to work.
@@ -1110,7 +1127,6 @@ interface ExtensionRunner {
1110
1127
  openBrowser(): Promise<void>;
1111
1128
  closeBrowser(): Promise<void>;
1112
1129
  }
1113
- type VirtualEntrypointType = 'content-script-main-world' | 'content-script-isolated-world' | 'background' | 'unlisted-script';
1114
1130
  type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
1115
1131
  interface Eslintrc {
1116
1132
  /**
@@ -1186,4 +1202,4 @@ interface Dependency {
1186
1202
  version: string;
1187
1203
  }
1188
1204
 
1189
- export type { VirtualEntrypointType as $, ResolvedPerBrowserOptions as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifest as D, ExtensionRunnerConfig as E, UserManifestFn as F, GenericEntrypoint as G, ConfigEnv as H, InlineConfig as I, WxtCommand as J, WxtBuilder as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilderServer as N, OutputFile as O, PopupEntrypointOptions as P, ServerInfo as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, HookResult as V, WxtDevServer as W, WxtHooks as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, EslintGlobalsPropValue as a0, Eslintrc as a1, ResolvedEslintrc as a2, WxtUnimportOptions as a3, WxtResolvedUnimportOptions as a4, WxtPackageManager as a5, Dependency as a6, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, ReloadContentScriptPayload as e, TargetManifestVersion as f, BaseEntrypointOptions as g, BackgroundEntrypointOptions as h, BaseContentScriptEntrypointOptions as i, IsolatedWorldContentScriptEntrypointOptions as j, OptionsEntrypointOptions as k, BaseEntrypoint as l, BackgroundEntrypoint as m, PopupEntrypoint as n, OptionsEntrypoint as o, SidepanelEntrypoint as p, Entrypoint as q, EntrypointGroup as r, OnContentScriptStopped as s, IsolatedWorldContentScriptDefinition as t, MainWorldContentScriptDefinition as u, ContentScriptDefinition as v, BackgroundDefinition as w, UnlistedScriptDefinition as x, PerBrowserOption as y, PerBrowserMap as z };
1205
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
@@ -291,7 +291,7 @@ interface InlineConfig {
291
291
  *
292
292
  * @example
293
293
  * [
294
- * "coverage", // Ignore the coverage directory in the `sourcesRoot`
294
+ * "coverage", // Include the coverage directory in the `sourcesRoot`
295
295
  * ]
296
296
  */
297
297
  excludeSources?: string[];
@@ -967,6 +967,23 @@ interface ServerInfo {
967
967
  origin: string;
968
968
  }
969
969
  type HookResult = Promise<void> | void;
970
+ interface WxtHooks {
971
+ /**
972
+ * Called when WXT has created Vite's config for a build step. Useful if you
973
+ * want to add plugins or update the vite config per entrypoint group.
974
+ *
975
+ * @param entrypoints The list of entrypoints being built with the provided config.
976
+ * @param viteConfig The config that will be used for the dev server.
977
+ */
978
+ 'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
979
+ /**
980
+ * Called when WXT has created Vite's config for the dev server. Useful if
981
+ * you want to add plugins or update the vite config per entrypoint group.
982
+ *
983
+ * @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
984
+ */
985
+ 'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
986
+ }
970
987
  interface WxtHooks {
971
988
  /**
972
989
  * Called after WXT initialization, when the WXT instance is ready to work.
@@ -1110,7 +1127,6 @@ interface ExtensionRunner {
1110
1127
  openBrowser(): Promise<void>;
1111
1128
  closeBrowser(): Promise<void>;
1112
1129
  }
1113
- type VirtualEntrypointType = 'content-script-main-world' | 'content-script-isolated-world' | 'background' | 'unlisted-script';
1114
1130
  type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
1115
1131
  interface Eslintrc {
1116
1132
  /**
@@ -1186,4 +1202,4 @@ interface Dependency {
1186
1202
  version: string;
1187
1203
  }
1188
1204
 
1189
- export type { VirtualEntrypointType as $, ResolvedPerBrowserOptions as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifest as D, ExtensionRunnerConfig as E, UserManifestFn as F, GenericEntrypoint as G, ConfigEnv as H, InlineConfig as I, WxtCommand as J, WxtBuilder as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilderServer as N, OutputFile as O, PopupEntrypointOptions as P, ServerInfo as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, HookResult as V, WxtDevServer as W, WxtHooks as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, EslintGlobalsPropValue as a0, Eslintrc as a1, ResolvedEslintrc as a2, WxtUnimportOptions as a3, WxtResolvedUnimportOptions as a4, WxtPackageManager as a5, Dependency as a6, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, ReloadContentScriptPayload as e, TargetManifestVersion as f, BaseEntrypointOptions as g, BackgroundEntrypointOptions as h, BaseContentScriptEntrypointOptions as i, IsolatedWorldContentScriptEntrypointOptions as j, OptionsEntrypointOptions as k, BaseEntrypoint as l, BackgroundEntrypoint as m, PopupEntrypoint as n, OptionsEntrypoint as o, SidepanelEntrypoint as p, Entrypoint as q, EntrypointGroup as r, OnContentScriptStopped as s, IsolatedWorldContentScriptDefinition as t, MainWorldContentScriptDefinition as u, ContentScriptDefinition as v, BackgroundDefinition as w, UnlistedScriptDefinition as x, PerBrowserOption as y, PerBrowserMap as z };
1205
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
package/dist/index.cjs CHANGED
@@ -3007,32 +3007,50 @@ function unimport(config) {
3007
3007
  };
3008
3008
  }
3009
3009
 
3010
- // src/core/builders/vite/plugins/virtualEntrypoint.ts
3010
+ // src/core/utils/virtual-modules.ts
3011
+ var virtualEntrypointTypes = [
3012
+ "content-script-main-world",
3013
+ "content-script-isolated-world",
3014
+ "background",
3015
+ "unlisted-script"
3016
+ ];
3017
+ var virtualEntrypointModuleNames = virtualEntrypointTypes.map(
3018
+ (name) => `${name}-entrypoint`
3019
+ );
3020
+ var virtualModuleNames = [
3021
+ ...virtualEntrypointModuleNames,
3022
+ "mock-browser",
3023
+ "reload-html"
3024
+ ];
3025
+
3026
+ // src/core/builders/vite/plugins/resolveVirtualModules.ts
3011
3027
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
3012
3028
  var import_path2 = require("path");
3013
- function virtualEntrypoint(type, config) {
3014
- const virtualId = `virtual:wxt-${type}?`;
3015
- const resolvedVirtualId = `\0${virtualId}`;
3016
- return {
3017
- name: `wxt:virtual-entrypoint`,
3018
- resolveId(id) {
3019
- const index = id.indexOf(virtualId);
3020
- if (index === -1)
3021
- return;
3022
- const inputPath = normalizePath(id.substring(index + virtualId.length));
3023
- return resolvedVirtualId + inputPath;
3024
- },
3025
- async load(id) {
3026
- if (!id.startsWith(resolvedVirtualId))
3027
- return;
3028
- const inputPath = id.replace(resolvedVirtualId, "");
3029
- const template = await import_fs_extra3.default.readFile(
3030
- (0, import_path2.resolve)(config.wxtModuleDir, `dist/virtual/${type}-entrypoint.js`),
3031
- "utf-8"
3032
- );
3033
- return template.replace(`virtual:user-${type}`, inputPath);
3034
- }
3035
- };
3029
+ function resolveVirtualModules(config) {
3030
+ return virtualModuleNames.map((name) => {
3031
+ const virtualId = `virtual:wxt-${name}?`;
3032
+ const resolvedVirtualId = "\0" + virtualId;
3033
+ return {
3034
+ name: `wxt:resolve-virtual-${name}`,
3035
+ resolveId(id) {
3036
+ const index = id.indexOf(virtualId);
3037
+ if (index === -1)
3038
+ return;
3039
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
3040
+ return resolvedVirtualId + inputPath;
3041
+ },
3042
+ async load(id) {
3043
+ if (!id.startsWith(resolvedVirtualId))
3044
+ return;
3045
+ const inputPath = id.replace(resolvedVirtualId, "");
3046
+ const template = await import_fs_extra3.default.readFile(
3047
+ (0, import_path2.resolve)(config.wxtModuleDir, `dist/virtual/${name}.js`),
3048
+ "utf-8"
3049
+ );
3050
+ return template.replace(`virtual:user-${name}`, inputPath);
3051
+ }
3052
+ };
3053
+ });
3036
3054
  }
3037
3055
 
3038
3056
  // src/core/builders/vite/plugins/tsconfigPaths.ts
@@ -3239,16 +3257,37 @@ function defineImportMeta() {
3239
3257
  };
3240
3258
  }
3241
3259
 
3260
+ // src/core/utils/arrays.ts
3261
+ function every(array, predicate) {
3262
+ for (let i = 0; i < array.length; i++)
3263
+ if (!predicate(array[i], i))
3264
+ return false;
3265
+ return true;
3266
+ }
3267
+ function some(array, predicate) {
3268
+ for (let i = 0; i < array.length; i++)
3269
+ if (predicate(array[i], i))
3270
+ return true;
3271
+ return false;
3272
+ }
3273
+ function toArray(a) {
3274
+ return Array.isArray(a) ? a : [a];
3275
+ }
3276
+
3242
3277
  // src/core/builders/vite/index.ts
3243
- async function createViteBuilder(wxtConfig, server) {
3278
+ async function createViteBuilder(wxtConfig, hooks, server) {
3244
3279
  const vite = await import("vite");
3245
3280
  const getBaseConfig = async () => {
3246
- const config = await wxtConfig.vite(wxtConfig.env);
3281
+ const config = await wxtConfig.vite({
3282
+ ...wxtConfig.env
3283
+ });
3247
3284
  config.root = wxtConfig.root;
3248
3285
  config.configFile = false;
3249
3286
  config.logLevel = "warn";
3250
3287
  config.mode = wxtConfig.mode;
3251
3288
  config.build ??= {};
3289
+ config.publicDir = wxtConfig.publicDir;
3290
+ config.build.copyPublicDir = false;
3252
3291
  config.build.outDir = wxtConfig.outDir;
3253
3292
  config.build.emptyOutDir = false;
3254
3293
  if (config.build.minify == null && wxtConfig.command === "serve") {
@@ -3262,10 +3301,7 @@ async function createViteBuilder(wxtConfig, server) {
3262
3301
  download(wxtConfig),
3263
3302
  devHtmlPrerender(wxtConfig, server),
3264
3303
  unimport(wxtConfig),
3265
- virtualEntrypoint("background", wxtConfig),
3266
- virtualEntrypoint("content-script-isolated-world", wxtConfig),
3267
- virtualEntrypoint("content-script-main-world", wxtConfig),
3268
- virtualEntrypoint("unlisted-script", wxtConfig),
3304
+ resolveVirtualModules(wxtConfig),
3269
3305
  devServerGlobals(wxtConfig, server),
3270
3306
  tsconfigPaths(wxtConfig),
3271
3307
  noopBackground(),
@@ -3389,6 +3425,11 @@ async function createViteBuilder(wxtConfig, server) {
3389
3425
  else
3390
3426
  entryConfig = getLibModeConfig(group);
3391
3427
  const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
3428
+ await hooks.callHook(
3429
+ "vite:build:extendConfig",
3430
+ toArray(group),
3431
+ buildConfig
3432
+ );
3392
3433
  const result = await vite.build(buildConfig);
3393
3434
  return {
3394
3435
  entrypoints: group,
@@ -3405,9 +3446,9 @@ async function createViteBuilder(wxtConfig, server) {
3405
3446
  }
3406
3447
  };
3407
3448
  const baseConfig = await getBaseConfig();
3408
- const viteServer = await vite.createServer(
3409
- vite.mergeConfig(baseConfig, serverConfig)
3410
- );
3449
+ const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
3450
+ await hooks.callHook("vite:devServer:extendConfig", finalConfig);
3451
+ const viteServer = await vite.createServer(finalConfig);
3411
3452
  const server2 = {
3412
3453
  async listen() {
3413
3454
  await viteServer.listen(info.port);
@@ -3450,7 +3491,11 @@ function getRollupEntry(entrypoint) {
3450
3491
  virtualEntrypointType = entrypoint.options.world === "MAIN" ? "content-script-main-world" : "content-script-isolated-world";
3451
3492
  break;
3452
3493
  }
3453
- return virtualEntrypointType ? `virtual:wxt-${virtualEntrypointType}?${entrypoint.inputPath}` : entrypoint.inputPath;
3494
+ if (virtualEntrypointType) {
3495
+ const moduleId = `virtual:wxt-${virtualEntrypointType}-entrypoint`;
3496
+ return `${moduleId}?${entrypoint.inputPath}`;
3497
+ }
3498
+ return entrypoint.inputPath;
3454
3499
  }
3455
3500
 
3456
3501
  // src/core/wxt.ts
@@ -3459,7 +3504,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
3459
3504
  const hooks = (0, import_hookable.createHooks)();
3460
3505
  const config = await resolveConfig(inlineConfig, command);
3461
3506
  const server = await getServer?.(config);
3462
- const builder = await createViteBuilder(config, server);
3507
+ const builder = await createViteBuilder(config, hooks, server);
3463
3508
  const pm = await createWxtPackageManager(config.root);
3464
3509
  wxt = {
3465
3510
  config,
@@ -3500,7 +3545,7 @@ async function buildEntrypoints(groups, spinner) {
3500
3545
  const steps = [];
3501
3546
  for (let i = 0; i < groups.length; i++) {
3502
3547
  const group = groups[i];
3503
- const groupNames = [group].flat().map((e) => e.name);
3548
+ const groupNames = toArray(group).map((e) => e.name);
3504
3549
  const groupNameColored = groupNames.join(import_picocolors.default.dim(", "));
3505
3550
  spinner.text = import_picocolors.default.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
3506
3551
  try {
@@ -3532,20 +3577,6 @@ async function copyPublicDirectory() {
3532
3577
  return publicAssets;
3533
3578
  }
3534
3579
 
3535
- // src/core/utils/arrays.ts
3536
- function every(array, predicate) {
3537
- for (let i = 0; i < array.length; i++)
3538
- if (!predicate(array[i], i))
3539
- return false;
3540
- return true;
3541
- }
3542
- function some(array, predicate) {
3543
- for (let i = 0; i < array.length; i++)
3544
- if (predicate(array[i], i))
3545
- return true;
3546
- return false;
3547
- }
3548
-
3549
3580
  // src/core/utils/building/detect-dev-changes.ts
3550
3581
  function detectDevChanges(changedFiles, currentOutput) {
3551
3582
  const isConfigChange = some(
@@ -4805,7 +4836,7 @@ function getChunkSortWeight(filename) {
4805
4836
  var import_picocolors4 = __toESM(require("picocolors"), 1);
4806
4837
 
4807
4838
  // package.json
4808
- var version = "0.17.10";
4839
+ var version = "0.17.12";
4809
4840
 
4810
4841
  // src/core/utils/log/printHeader.ts
4811
4842
  var import_consola2 = require("consola");
@@ -4920,6 +4951,9 @@ function mapWxtOptionsToRegisteredContentScript(options, js, css) {
4920
4951
  world: options.world
4921
4952
  };
4922
4953
  }
4954
+ function getContentScriptJs(config, entrypoint) {
4955
+ return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
4956
+ }
4923
4957
 
4924
4958
  // src/core/utils/manifest.ts
4925
4959
  var import_defu2 = __toESM(require("defu"), 1);
@@ -5971,7 +6005,7 @@ function reloadContentScripts(steps, server) {
5971
6005
  const entry = step.entrypoints;
5972
6006
  if (Array.isArray(entry) || entry.type !== "content-script")
5973
6007
  return;
5974
- const js = [getEntrypointBundlePath(entry, wxt.config.outDir, ".js")];
6008
+ const js = getContentScriptJs(wxt.config, entry);
5975
6009
  const cssMap = getContentScriptsCssMap(server.currentOutput, [entry]);
5976
6010
  const css = getContentScriptCssFiles([entry], cssMap);
5977
6011
  server.reloadContentScript({
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-w7ohFTEX.cjs';
2
- export { w as BackgroundDefinition, m as BackgroundEntrypoint, h as BackgroundEntrypointOptions, i as BaseContentScriptEntrypointOptions, l as BaseEntrypoint, g as BaseEntrypointOptions, d as BuildStepOutput, H as ConfigEnv, v as ContentScriptDefinition, C as ContentScriptEntrypoint, a6 as Dependency, q as Entrypoint, r as EntrypointGroup, a0 as EslintGlobalsPropValue, a1 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, V as HookResult, t as IsolatedWorldContentScriptDefinition, j as IsolatedWorldContentScriptEntrypointOptions, L as Logger, u as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, s as OnContentScriptStopped, o as OptionsEntrypoint, k as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, z as PerBrowserMap, y as PerBrowserOption, n as PopupEntrypoint, P as PopupEntrypointOptions, e as ReloadContentScriptPayload, R as ResolvedConfig, a2 as ResolvedEslintrc, A as ResolvedPerBrowserOptions, Q as ServerInfo, p as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, f as TargetManifestVersion, x as UnlistedScriptDefinition, D as UserManifest, F as UserManifestFn, $ as VirtualEntrypointType, Y as Wxt, K as WxtBuilder, N as WxtBuilderServer, J as WxtCommand, X as WxtHooks, a5 as WxtPackageManager, a4 as WxtResolvedUnimportOptions, a3 as WxtUnimportOptions, a as WxtViteConfig } from './index-w7ohFTEX.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-NHTTcok1.cjs';
2
+ export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-NHTTcok1.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
65
  */
66
66
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
67
 
68
- var version = "0.17.10";
68
+ var version = "0.17.12";
69
69
 
70
70
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-w7ohFTEX.js';
2
- export { w as BackgroundDefinition, m as BackgroundEntrypoint, h as BackgroundEntrypointOptions, i as BaseContentScriptEntrypointOptions, l as BaseEntrypoint, g as BaseEntrypointOptions, d as BuildStepOutput, H as ConfigEnv, v as ContentScriptDefinition, C as ContentScriptEntrypoint, a6 as Dependency, q as Entrypoint, r as EntrypointGroup, a0 as EslintGlobalsPropValue, a1 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, V as HookResult, t as IsolatedWorldContentScriptDefinition, j as IsolatedWorldContentScriptEntrypointOptions, L as Logger, u as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, s as OnContentScriptStopped, o as OptionsEntrypoint, k as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, z as PerBrowserMap, y as PerBrowserOption, n as PopupEntrypoint, P as PopupEntrypointOptions, e as ReloadContentScriptPayload, R as ResolvedConfig, a2 as ResolvedEslintrc, A as ResolvedPerBrowserOptions, Q as ServerInfo, p as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, f as TargetManifestVersion, x as UnlistedScriptDefinition, D as UserManifest, F as UserManifestFn, $ as VirtualEntrypointType, Y as Wxt, K as WxtBuilder, N as WxtBuilderServer, J as WxtCommand, X as WxtHooks, a5 as WxtPackageManager, a4 as WxtResolvedUnimportOptions, a3 as WxtUnimportOptions, a as WxtViteConfig } from './index-w7ohFTEX.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-NHTTcok1.js';
2
+ export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-NHTTcok1.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
65
  */
66
66
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
67
 
68
- var version = "0.17.10";
68
+ var version = "0.17.12";
69
69
 
70
70
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  formatDuration,
5
5
  generateTypesDir,
6
6
  getContentScriptCssFiles,
7
+ getContentScriptJs,
7
8
  getContentScriptsCssMap,
8
9
  getEntrypointBundlePath,
9
10
  getPackageJson,
@@ -18,7 +19,8 @@ import {
18
19
  unnormalizePath,
19
20
  version,
20
21
  wxt
21
- } from "./chunk-2SH4GQGN.js";
22
+ } from "./chunk-C4ZVXF53.js";
23
+ import "./chunk-5X3S6AWF.js";
22
24
  import "./chunk-VBXJIVYU.js";
23
25
 
24
26
  // src/core/build.ts
@@ -368,7 +370,7 @@ function reloadContentScripts(steps, server) {
368
370
  const entry = step.entrypoints;
369
371
  if (Array.isArray(entry) || entry.type !== "content-script")
370
372
  return;
371
- const js = [getEntrypointBundlePath(entry, wxt.config.outDir, ".js")];
373
+ const js = getContentScriptJs(wxt.config, entry);
372
374
  const cssMap = getContentScriptsCssMap(server.currentOutput, [entry]);
373
375
  const css = getContentScriptCssFiles([entry], cssMap);
374
376
  server.reloadContentScript({
package/dist/storage.cjs CHANGED
@@ -60,6 +60,11 @@ var logger = {
60
60
  error: (...args) => print(console.error, ...args)
61
61
  };
62
62
 
63
+ // src/core/utils/arrays.ts
64
+ function toArray(a) {
65
+ return Array.isArray(a) ? a : [a];
66
+ }
67
+
63
68
  // src/storage.ts
64
69
  var storage = createStorage();
65
70
  function createStorage() {
@@ -132,7 +137,7 @@ function createStorage() {
132
137
  await driver.removeItem(metaKey);
133
138
  } else {
134
139
  const newFields = getMetaValue(await driver.getItem(metaKey));
135
- [properties].flat().forEach((field) => delete newFields[field]);
140
+ toArray(properties).forEach((field) => delete newFields[field]);
136
141
  await driver.setItem(metaKey, newFields);
137
142
  }
138
143
  };
package/dist/storage.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ toArray
3
+ } from "./chunk-5X3S6AWF.js";
1
4
  import "./chunk-VBXJIVYU.js";
2
5
 
3
6
  // src/browser.ts
@@ -97,7 +100,7 @@ function createStorage() {
97
100
  await driver.removeItem(metaKey);
98
101
  } else {
99
102
  const newFields = getMetaValue(await driver.getItem(metaKey));
100
- [properties].flat().forEach((field) => delete newFields[field]);
103
+ toArray(properties).forEach((field) => delete newFields[field]);
101
104
  await driver.setItem(metaKey, newFields);
102
105
  }
103
106
  };
package/dist/testing.cjs CHANGED
@@ -162,7 +162,23 @@ function unimport(config) {
162
162
  };
163
163
  }
164
164
 
165
- // src/core/builders/vite/plugins/virtualEntrypoint.ts
165
+ // src/core/utils/virtual-modules.ts
166
+ var virtualEntrypointTypes = [
167
+ "content-script-main-world",
168
+ "content-script-isolated-world",
169
+ "background",
170
+ "unlisted-script"
171
+ ];
172
+ var virtualEntrypointModuleNames = virtualEntrypointTypes.map(
173
+ (name) => `${name}-entrypoint`
174
+ );
175
+ var virtualModuleNames = [
176
+ ...virtualEntrypointModuleNames,
177
+ "mock-browser",
178
+ "reload-html"
179
+ ];
180
+
181
+ // src/core/builders/vite/plugins/resolveVirtualModules.ts
166
182
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
167
183
 
168
184
  // src/core/builders/vite/plugins/tsconfigPaths.ts
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-w7ohFTEX.cjs';
3
+ import { I as InlineConfig } from './index-NHTTcok1.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-w7ohFTEX.js';
3
+ import { I as InlineConfig } from './index-NHTTcok1.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,8 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-2SH4GQGN.js";
8
+ } from "./chunk-C4ZVXF53.js";
9
+ import "./chunk-5X3S6AWF.js";
9
10
  import "./chunk-VBXJIVYU.js";
10
11
 
11
12
  // src/testing/fake-browser.ts
@@ -1,5 +1,5 @@
1
1
  // src/virtual/background-entrypoint.ts
2
- import definition from "virtual:user-background";
2
+ import definition from "virtual:user-background-entrypoint";
3
3
 
4
4
  // src/sandbox/utils/logger.ts
5
5
  function print(method, ...args) {
@@ -1,5 +1,5 @@
1
1
  // src/virtual/content-script-isolated-world-entrypoint.ts
2
- import definition from "virtual:user-content-script-isolated-world";
2
+ import definition from "virtual:user-content-script-isolated-world-entrypoint";
3
3
 
4
4
  // src/sandbox/utils/logger.ts
5
5
  function print(method, ...args) {
@@ -1,5 +1,5 @@
1
1
  // src/virtual/content-script-main-world-entrypoint.ts
2
- import definition from "virtual:user-content-script-main-world";
2
+ import definition from "virtual:user-content-script-main-world-entrypoint";
3
3
 
4
4
  // src/sandbox/utils/logger.ts
5
5
  function print(method, ...args) {
@@ -1,5 +1,5 @@
1
1
  // src/virtual/unlisted-script-entrypoint.ts
2
- import definition from "virtual:user-unlisted-script";
2
+ import definition from "virtual:user-unlisted-script-entrypoint";
3
3
 
4
4
  // src/sandbox/utils/logger.ts
5
5
  function print(method, ...args) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.17.10",
4
+ "version": "0.17.12",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",