wxt 0.9.1 → 0.9.2

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.
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.9.1";
2
+ var version = "0.9.2";
3
3
 
4
4
  // src/core/utils/entrypoints.ts
5
5
  import path, { relative, resolve } from "node:path";
@@ -563,6 +563,30 @@ function bundleAnalysis() {
563
563
  });
564
564
  }
565
565
 
566
+ // src/core/vite-plugins/excludeBrowserPolyfill.ts
567
+ function excludeBrowserPolyfill(config) {
568
+ const virtualId = "virtual:wxt-webextension-polyfill-disabled";
569
+ return {
570
+ name: "wxt:exclude-browser-polyfill",
571
+ config() {
572
+ if (config.experimental.includeBrowserPolyfill)
573
+ return;
574
+ return {
575
+ resolve: {
576
+ alias: {
577
+ "webextension-polyfill": virtualId
578
+ }
579
+ }
580
+ };
581
+ },
582
+ load(id) {
583
+ if (id === virtualId) {
584
+ return "export default chrome";
585
+ }
586
+ }
587
+ };
588
+ }
589
+
566
590
  // src/core/utils/arrays.ts
567
591
  function every(array, predicate) {
568
592
  for (let i = 0; i < array.length; i++)
@@ -1159,7 +1183,10 @@ async function getInternalConfig(inlineConfig, command) {
1159
1183
  template: mergedConfig.analysis?.template ?? "treemap"
1160
1184
  },
1161
1185
  userConfigMetadata: userConfigMetadata ?? {},
1162
- alias
1186
+ alias,
1187
+ experimental: {
1188
+ includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
1189
+ }
1163
1190
  };
1164
1191
  finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
1165
1192
  return finalConfig;
@@ -1220,6 +1247,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1220
1247
  alias: {
1221
1248
  ...userConfig.alias,
1222
1249
  ...inlineConfig.alias
1250
+ },
1251
+ experimental: {
1252
+ ...userConfig.experimental,
1253
+ ...inlineConfig.experimental
1223
1254
  }
1224
1255
  };
1225
1256
  }
@@ -1272,6 +1303,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
1272
1303
  internalVite.plugins.push(bundleAnalysis());
1273
1304
  }
1274
1305
  internalVite.plugins.push(globals(finalConfig));
1306
+ internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
1275
1307
  return internalVite;
1276
1308
  }
1277
1309
 
package/dist/cli.cjs CHANGED
@@ -2415,7 +2415,7 @@ var init_execa = __esm({
2415
2415
  var import_cac = __toESM(require("cac"), 1);
2416
2416
 
2417
2417
  // package.json
2418
- var version = "0.9.1";
2418
+ var version = "0.9.2";
2419
2419
 
2420
2420
  // src/core/utils/building/build-entrypoints.ts
2421
2421
  var vite2 = __toESM(require("vite"), 1);
@@ -2948,6 +2948,30 @@ function globals(config) {
2948
2948
  // src/core/vite-plugins/webextensionPolyfillAlias.ts
2949
2949
  var import_node_path4 = __toESM(require("path"), 1);
2950
2950
 
2951
+ // src/core/vite-plugins/excludeBrowserPolyfill.ts
2952
+ function excludeBrowserPolyfill(config) {
2953
+ const virtualId = "virtual:wxt-webextension-polyfill-disabled";
2954
+ return {
2955
+ name: "wxt:exclude-browser-polyfill",
2956
+ config() {
2957
+ if (config.experimental.includeBrowserPolyfill)
2958
+ return;
2959
+ return {
2960
+ resolve: {
2961
+ alias: {
2962
+ "webextension-polyfill": virtualId
2963
+ }
2964
+ }
2965
+ };
2966
+ },
2967
+ load(id) {
2968
+ if (id === virtualId) {
2969
+ return "export default chrome";
2970
+ }
2971
+ }
2972
+ };
2973
+ }
2974
+
2951
2975
  // src/core/utils/fs.ts
2952
2976
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
2953
2977
  var import_fast_glob = __toESM(require("fast-glob"), 1);
@@ -3837,7 +3861,10 @@ async function getInternalConfig(inlineConfig, command) {
3837
3861
  template: mergedConfig.analysis?.template ?? "treemap"
3838
3862
  },
3839
3863
  userConfigMetadata: userConfigMetadata ?? {},
3840
- alias
3864
+ alias,
3865
+ experimental: {
3866
+ includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
3867
+ }
3841
3868
  };
3842
3869
  finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
3843
3870
  return finalConfig;
@@ -3898,6 +3925,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3898
3925
  alias: {
3899
3926
  ...userConfig.alias,
3900
3927
  ...inlineConfig.alias
3928
+ },
3929
+ experimental: {
3930
+ ...userConfig.experimental,
3931
+ ...inlineConfig.experimental
3901
3932
  }
3902
3933
  };
3903
3934
  }
@@ -3950,6 +3981,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
3950
3981
  internalVite.plugins.push(bundleAnalysis());
3951
3982
  }
3952
3983
  internalVite.plugins.push(globals(finalConfig));
3984
+ internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
3953
3985
  return internalVite;
3954
3986
  }
3955
3987
 
@@ -284,6 +284,31 @@ interface InlineConfig {
284
284
  * }
285
285
  */
286
286
  alias?: Record<string, string>;
287
+ /**
288
+ * Experimental settings - use with caution.
289
+ */
290
+ experimental?: {
291
+ /**
292
+ * Whether to use [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill)
293
+ * when importing `browser` from `wxt/browser`.
294
+ *
295
+ * When set to `false`, WXT will export the chrome global instead of the polyfill from
296
+ * `wxt/browser`.
297
+ *
298
+ * You should use `browser` to access the web extension APIs.
299
+ *
300
+ * @experimental This option will remain experimental until Manifest V2 is dead.
301
+ *
302
+ * @default true
303
+ * @example
304
+ * export default defineConfig({
305
+ * experimental: {
306
+ * includeBrowserPolyfill: false
307
+ * }
308
+ * })
309
+ */
310
+ includeBrowserPolyfill?: boolean;
311
+ };
287
312
  }
288
313
  interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
289
314
  build?: Omit<vite.BuildOptions, 'outDir'>;
package/dist/index.cjs CHANGED
@@ -2958,6 +2958,30 @@ function globals(config) {
2958
2958
  // src/core/vite-plugins/webextensionPolyfillAlias.ts
2959
2959
  var import_node_path4 = __toESM(require("path"), 1);
2960
2960
 
2961
+ // src/core/vite-plugins/excludeBrowserPolyfill.ts
2962
+ function excludeBrowserPolyfill(config) {
2963
+ const virtualId = "virtual:wxt-webextension-polyfill-disabled";
2964
+ return {
2965
+ name: "wxt:exclude-browser-polyfill",
2966
+ config() {
2967
+ if (config.experimental.includeBrowserPolyfill)
2968
+ return;
2969
+ return {
2970
+ resolve: {
2971
+ alias: {
2972
+ "webextension-polyfill": virtualId
2973
+ }
2974
+ }
2975
+ };
2976
+ },
2977
+ load(id) {
2978
+ if (id === virtualId) {
2979
+ return "export default chrome";
2980
+ }
2981
+ }
2982
+ };
2983
+ }
2984
+
2961
2985
  // src/core/utils/fs.ts
2962
2986
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
2963
2987
  var import_fast_glob = __toESM(require("fast-glob"), 1);
@@ -3847,7 +3871,10 @@ async function getInternalConfig(inlineConfig, command) {
3847
3871
  template: mergedConfig.analysis?.template ?? "treemap"
3848
3872
  },
3849
3873
  userConfigMetadata: userConfigMetadata ?? {},
3850
- alias
3874
+ alias,
3875
+ experimental: {
3876
+ includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
3877
+ }
3851
3878
  };
3852
3879
  finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
3853
3880
  return finalConfig;
@@ -3908,6 +3935,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3908
3935
  alias: {
3909
3936
  ...userConfig.alias,
3910
3937
  ...inlineConfig.alias
3938
+ },
3939
+ experimental: {
3940
+ ...userConfig.experimental,
3941
+ ...inlineConfig.experimental
3911
3942
  }
3912
3943
  };
3913
3944
  }
@@ -3960,6 +3991,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
3960
3991
  internalVite.plugins.push(bundleAnalysis());
3961
3992
  }
3962
3993
  internalVite.plugins.push(globals(finalConfig));
3994
+ internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
3963
3995
  return internalVite;
3964
3996
  }
3965
3997
 
@@ -4192,7 +4224,7 @@ function getChunkSortWeight(filename) {
4192
4224
  var import_picocolors3 = __toESM(require("picocolors"), 1);
4193
4225
 
4194
4226
  // package.json
4195
- var version = "0.9.1";
4227
+ var version = "0.9.2";
4196
4228
 
4197
4229
  // src/core/utils/log/printHeader.ts
4198
4230
  var import_consola2 = require("consola");
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 './external-9e212597.js';
2
- export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9e212597.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-9115d0fb.js';
2
+ export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
61
61
  */
62
62
  declare function zip(config?: InlineConfig): Promise<string[]>;
63
63
 
64
- var version = "0.9.1";
64
+ var version = "0.9.2";
65
65
 
66
66
  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 './external-9e212597.js';
2
- export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9e212597.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-9115d0fb.js';
2
+ export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
61
61
  */
62
62
  declare function zip(config?: InlineConfig): Promise<string[]>;
63
63
 
64
- var version = "0.9.1";
64
+ var version = "0.9.2";
65
65
 
66
66
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  rebuild,
16
16
  resolvePerBrowserOption,
17
17
  version
18
- } from "./chunk-2BIYR4TE.js";
18
+ } from "./chunk-OKMB7FJI.js";
19
19
  import "./chunk-YUG22S6W.js";
20
20
 
21
21
  // src/core/build.ts
package/dist/testing.cjs CHANGED
@@ -504,6 +504,30 @@ function webextensionPolyfillInlineDeps() {
504
504
  };
505
505
  }
506
506
 
507
+ // src/core/vite-plugins/excludeBrowserPolyfill.ts
508
+ function excludeBrowserPolyfill(config) {
509
+ const virtualId = "virtual:wxt-webextension-polyfill-disabled";
510
+ return {
511
+ name: "wxt:exclude-browser-polyfill",
512
+ config() {
513
+ if (config.experimental.includeBrowserPolyfill)
514
+ return;
515
+ return {
516
+ resolve: {
517
+ alias: {
518
+ "webextension-polyfill": virtualId
519
+ }
520
+ }
521
+ };
522
+ },
523
+ load(id) {
524
+ if (id === virtualId) {
525
+ return "export default chrome";
526
+ }
527
+ }
528
+ };
529
+ }
530
+
507
531
  // src/core/utils/building/build-entrypoints.ts
508
532
  var vite2 = __toESM(require("vite"), 1);
509
533
 
@@ -687,7 +711,10 @@ async function getInternalConfig(inlineConfig, command) {
687
711
  template: mergedConfig.analysis?.template ?? "treemap"
688
712
  },
689
713
  userConfigMetadata: userConfigMetadata ?? {},
690
- alias
714
+ alias,
715
+ experimental: {
716
+ includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
717
+ }
691
718
  };
692
719
  finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
693
720
  return finalConfig;
@@ -748,6 +775,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
748
775
  alias: {
749
776
  ...userConfig.alias,
750
777
  ...inlineConfig.alias
778
+ },
779
+ experimental: {
780
+ ...userConfig.experimental,
781
+ ...inlineConfig.experimental
751
782
  }
752
783
  };
753
784
  }
@@ -800,6 +831,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
800
831
  internalVite.plugins.push(bundleAnalysis());
801
832
  }
802
833
  internalVite.plugins.push(globals(finalConfig));
834
+ internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
803
835
  return internalVite;
804
836
  }
805
837
 
@@ -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 './external-9e212597.js';
3
+ import { I as InlineConfig } from './external-9115d0fb.js';
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 './external-9e212597.js';
3
+ import { I as InlineConfig } from './external-9115d0fb.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  unimport,
7
7
  webextensionPolyfillAlias,
8
8
  webextensionPolyfillInlineDeps
9
- } from "./chunk-2BIYR4TE.js";
9
+ } from "./chunk-OKMB7FJI.js";
10
10
  import "./chunk-YUG22S6W.js";
11
11
 
12
12
  // src/testing/fake-browser.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.9.1",
4
+ "version": "0.9.2",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",