wxt 0.17.12 → 0.17.13-alpha1

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.
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-VBXJIVYU.js";
9
9
 
10
10
  // package.json
11
- var version = "0.17.12";
11
+ var version = "0.17.13-alpha1";
12
12
 
13
13
  // src/core/utils/paths.ts
14
14
  import systemPath from "node:path";
@@ -655,6 +655,26 @@ function defineImportMeta() {
655
655
  };
656
656
  }
657
657
 
658
+ // src/core/utils/strings.ts
659
+ function kebabCaseAlphanumeric(str) {
660
+ return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
661
+ }
662
+ function safeVarName(str) {
663
+ return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
664
+ }
665
+ function removeImportStatements(text) {
666
+ return text.replace(
667
+ /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
668
+ ""
669
+ );
670
+ }
671
+ function removeProjectImportStatements(text) {
672
+ const noImports = removeImportStatements(text);
673
+ return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
674
+
675
+ ${noImports}`;
676
+ }
677
+
658
678
  // src/core/utils/fs.ts
659
679
  import fs3 from "fs-extra";
660
680
  import glob from "fast-glob";
@@ -1602,6 +1622,7 @@ function resolveZipConfig(root, mergedConfig) {
1602
1622
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
1603
1623
  sourcesRoot: root,
1604
1624
  includeSources: [],
1625
+ compressionLevel: 9,
1605
1626
  ...mergedConfig.zip,
1606
1627
  excludeSources: [
1607
1628
  "**/node_modules",
@@ -1750,25 +1771,6 @@ import createJITI from "jiti";
1750
1771
  import { createUnimport as createUnimport3 } from "unimport";
1751
1772
  import fs10 from "fs-extra";
1752
1773
  import { relative as relative5, resolve as resolve10 } from "node:path";
1753
-
1754
- // src/core/utils/strings.ts
1755
- function kebabCaseAlphanumeric(str) {
1756
- return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
1757
- }
1758
- function removeImportStatements(text) {
1759
- return text.replace(
1760
- /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
1761
- ""
1762
- );
1763
- }
1764
- function removeProjectImportStatements(text) {
1765
- const noImports = removeImportStatements(text);
1766
- return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
1767
-
1768
- ${noImports}`;
1769
- }
1770
-
1771
- // src/core/utils/building/import-entrypoint.ts
1772
1774
  import { transformSync } from "esbuild";
1773
1775
  import { fileURLToPath } from "node:url";
1774
1776
  async function importEntrypointFile(path8) {
@@ -2997,9 +2999,7 @@ var packageManagers = {
2997
2999
  async function createViteBuilder(wxtConfig, hooks, server) {
2998
3000
  const vite = await import("vite");
2999
3001
  const getBaseConfig = async () => {
3000
- const config = await wxtConfig.vite({
3001
- ...wxtConfig.env
3002
- });
3002
+ const config = await wxtConfig.vite(wxtConfig.env);
3003
3003
  config.root = wxtConfig.root;
3004
3004
  config.configFile = false;
3005
3005
  config.logLevel = "warn";
@@ -3041,14 +3041,22 @@ async function createViteBuilder(wxtConfig, hooks, server) {
3041
3041
  if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
3042
3042
  plugins.push(cssEntrypoints(entrypoint, wxtConfig));
3043
3043
  }
3044
+ const iifeReturnValueName = safeVarName(entrypoint.name);
3044
3045
  const libMode = {
3045
3046
  mode: wxtConfig.mode,
3046
3047
  plugins,
3048
+ esbuild: {
3049
+ // Add a footer with the returned value so it can return values to `scripting.executeScript`
3050
+ // Footer is added apart of esbuild to make sure it's not minified. It
3051
+ // get's removed if added to `build.rollupOptions.output.footer`
3052
+ // See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
3053
+ footer: iifeReturnValueName + ";"
3054
+ },
3047
3055
  build: {
3048
3056
  lib: {
3049
3057
  entry,
3050
3058
  formats: ["iife"],
3051
- name: "_",
3059
+ name: iifeReturnValueName,
3052
3060
  fileName: entrypoint.name
3053
3061
  },
3054
3062
  rollupOptions: {
@@ -3253,6 +3261,7 @@ export {
3253
3261
  tsconfigPaths,
3254
3262
  globals,
3255
3263
  webextensionPolyfillMock,
3264
+ kebabCaseAlphanumeric,
3256
3265
  wxt,
3257
3266
  registerWxt,
3258
3267
  detectDevChanges,
@@ -3260,7 +3269,6 @@ export {
3260
3269
  generateTypesDir,
3261
3270
  getPackageJson,
3262
3271
  resolveConfig,
3263
- kebabCaseAlphanumeric,
3264
3272
  printFileList,
3265
3273
  version,
3266
3274
  mapWxtOptionsToRegisteredContentScript,
package/dist/cli.js CHANGED
@@ -860,13 +860,31 @@ function filterTruthy(array) {
860
860
  return array.filter((item) => !!item);
861
861
  }
862
862
 
863
+ // src/core/utils/strings.ts
864
+ function kebabCaseAlphanumeric(str) {
865
+ return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
866
+ }
867
+ function safeVarName(str) {
868
+ return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
869
+ }
870
+ function removeImportStatements(text) {
871
+ return text.replace(
872
+ /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
873
+ ""
874
+ );
875
+ }
876
+ function removeProjectImportStatements(text) {
877
+ const noImports = removeImportStatements(text);
878
+ return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
879
+
880
+ ${noImports}`;
881
+ }
882
+
863
883
  // src/core/builders/vite/index.ts
864
884
  async function createViteBuilder(wxtConfig, hooks, server) {
865
885
  const vite = await import("vite");
866
886
  const getBaseConfig = async () => {
867
- const config = await wxtConfig.vite({
868
- ...wxtConfig.env
869
- });
887
+ const config = await wxtConfig.vite(wxtConfig.env);
870
888
  config.root = wxtConfig.root;
871
889
  config.configFile = false;
872
890
  config.logLevel = "warn";
@@ -908,14 +926,22 @@ async function createViteBuilder(wxtConfig, hooks, server) {
908
926
  if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
909
927
  plugins.push(cssEntrypoints(entrypoint, wxtConfig));
910
928
  }
929
+ const iifeReturnValueName = safeVarName(entrypoint.name);
911
930
  const libMode = {
912
931
  mode: wxtConfig.mode,
913
932
  plugins,
933
+ esbuild: {
934
+ // Add a footer with the returned value so it can return values to `scripting.executeScript`
935
+ // Footer is added apart of esbuild to make sure it's not minified. It
936
+ // get's removed if added to `build.rollupOptions.output.footer`
937
+ // See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
938
+ footer: iifeReturnValueName + ";"
939
+ },
914
940
  build: {
915
941
  lib: {
916
942
  entry,
917
943
  formats: ["iife"],
918
- name: "_",
944
+ name: iifeReturnValueName,
919
945
  fileName: entrypoint.name
920
946
  },
921
947
  rollupOptions: {
@@ -2054,6 +2080,7 @@ function resolveZipConfig(root, mergedConfig) {
2054
2080
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
2055
2081
  sourcesRoot: root,
2056
2082
  includeSources: [],
2083
+ compressionLevel: 9,
2057
2084
  ...mergedConfig.zip,
2058
2085
  excludeSources: [
2059
2086
  "**/node_modules",
@@ -2202,25 +2229,6 @@ import createJITI from "jiti";
2202
2229
  import { createUnimport as createUnimport3 } from "unimport";
2203
2230
  import fs10 from "fs-extra";
2204
2231
  import { relative as relative5, resolve as resolve10 } from "node:path";
2205
-
2206
- // src/core/utils/strings.ts
2207
- function kebabCaseAlphanumeric(str) {
2208
- return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
2209
- }
2210
- function removeImportStatements(text) {
2211
- return text.replace(
2212
- /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
2213
- ""
2214
- );
2215
- }
2216
- function removeProjectImportStatements(text) {
2217
- const noImports = removeImportStatements(text);
2218
- return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
2219
-
2220
- ${noImports}`;
2221
- }
2222
-
2223
- // src/core/utils/building/import-entrypoint.ts
2224
2232
  import { transformSync } from "esbuild";
2225
2233
  import { fileURLToPath } from "node:url";
2226
2234
  async function importEntrypointFile(path10) {
@@ -2420,7 +2428,7 @@ function getChunkSortWeight(filename) {
2420
2428
  import pc4 from "picocolors";
2421
2429
 
2422
2430
  // package.json
2423
- var version = "0.17.12";
2431
+ var version = "0.17.13-alpha1";
2424
2432
 
2425
2433
  // src/core/utils/log/printHeader.ts
2426
2434
  import { consola as consola2 } from "consola";
@@ -3854,7 +3862,13 @@ async function zipDir(directory, outputPath, options) {
3854
3862
  }
3855
3863
  }
3856
3864
  await options?.additionalWork?.(archive);
3857
- const buffer = await archive.generateAsync({ type: "base64" });
3865
+ const buffer = await archive.generateAsync({
3866
+ type: "base64",
3867
+ ...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
3868
+ compression: "DEFLATE",
3869
+ compressionOptions: { level: wxt.config.zip.compressionLevel }
3870
+ }
3871
+ });
3858
3872
  await fs16.writeFile(outputPath, buffer, "base64");
3859
3873
  }
3860
3874
  async function downloadPrivatePackages() {
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ContentScriptContext } from './index-mYGv2dqk.js';
1
+ import { a as ContentScriptContext } from './index-Aan1uu3v.js';
2
2
  import 'webextension-polyfill';
3
3
 
4
4
  interface IntegratedContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
@@ -205,8 +205,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
205
205
  * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
206
206
  * manifest. This is the normal and most well known way of registering a content script.
207
207
  * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
208
- * responsible for using the scripting API to register the content script dynamically at
209
- * runtime.
208
+ * responsible for using the scripting API to register/execute the content script
209
+ * dynamically at runtime.
210
210
  *
211
211
  * @default "manifest"
212
212
  */
@@ -228,14 +228,22 @@ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptE
228
228
  interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
229
229
  /**
230
230
  * Main function executed when the content script is loaded.
231
+ *
232
+ * When running a content script with `browser.scripting.executeScript`,
233
+ * values returned from this function will be returned in the `executeScript`
234
+ * result as well. Otherwise returning a value does nothing.
231
235
  */
232
- main(ctx: ContentScriptContext): void | Promise<void>;
236
+ main(ctx: ContentScriptContext): any | Promise<any>;
233
237
  }
234
238
  interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
235
239
  /**
236
240
  * Main function executed when the content script is loaded.
241
+ *
242
+ * When running a content script with `browser.scripting.executeScript`,
243
+ * values returned from this function will be returned in the `executeScript`
244
+ * result as well. Otherwise returning a value does nothing.
237
245
  */
238
- main(): void | Promise<void>;
246
+ main(): any | Promise<any>;
239
247
  }
240
248
  type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
241
249
  interface BackgroundDefinition extends BackgroundEntrypointOptions {
@@ -247,8 +255,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
247
255
  interface UnlistedScriptDefinition extends BaseEntrypointOptions {
248
256
  /**
249
257
  * Main function executed when the unlisted script is ran.
258
+ *
259
+ * When running a content script with `browser.scripting.executeScript`,
260
+ * values returned from this function will be returned in the `executeScript`
261
+ * result as well. Otherwise returning a value does nothing.
250
262
  */
251
- main(): void | Promise<void>;
263
+ main(): any | Promise<any>;
252
264
  }
253
265
  /**
254
266
  * Either a single value or a map of different browsers to the value for that browser.
@@ -320,6 +320,14 @@ interface InlineConfig {
320
320
  * ["@scope/package-name@1.1.3", "package-name@^2"]
321
321
  */
322
322
  downloadPackages?: string[];
323
+ /**
324
+ * Compression level to use when zipping files.
325
+ *
326
+ * Levels: 0 (no compression) to 9 (maximum compression).
327
+ *
328
+ * @default 9
329
+ */
330
+ compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
323
331
  };
324
332
  /**
325
333
  * @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
@@ -647,8 +655,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
647
655
  * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
648
656
  * manifest. This is the normal and most well known way of registering a content script.
649
657
  * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
650
- * responsible for using the scripting API to register the content script dynamically at
651
- * runtime.
658
+ * responsible for using the scripting API to register/execute the content script
659
+ * dynamically at runtime.
652
660
  *
653
661
  * @default "manifest"
654
662
  */
@@ -753,14 +761,22 @@ type OnContentScriptStopped = (cb: () => void) => void;
753
761
  interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
754
762
  /**
755
763
  * Main function executed when the content script is loaded.
764
+ *
765
+ * When running a content script with `browser.scripting.executeScript`,
766
+ * values returned from this function will be returned in the `executeScript`
767
+ * result as well. Otherwise returning a value does nothing.
756
768
  */
757
- main(ctx: ContentScriptContext): void | Promise<void>;
769
+ main(ctx: ContentScriptContext): any | Promise<any>;
758
770
  }
759
771
  interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
760
772
  /**
761
773
  * Main function executed when the content script is loaded.
774
+ *
775
+ * When running a content script with `browser.scripting.executeScript`,
776
+ * values returned from this function will be returned in the `executeScript`
777
+ * result as well. Otherwise returning a value does nothing.
762
778
  */
763
- main(): void | Promise<void>;
779
+ main(): any | Promise<any>;
764
780
  }
765
781
  type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
766
782
  interface BackgroundDefinition extends BackgroundEntrypointOptions {
@@ -772,8 +788,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
772
788
  interface UnlistedScriptDefinition extends BaseEntrypointOptions {
773
789
  /**
774
790
  * Main function executed when the unlisted script is ran.
791
+ *
792
+ * When running a content script with `browser.scripting.executeScript`,
793
+ * values returned from this function will be returned in the `executeScript`
794
+ * result as well. Otherwise returning a value does nothing.
775
795
  */
776
- main(): void | Promise<void>;
796
+ main(): any | Promise<any>;
777
797
  }
778
798
  /**
779
799
  * Either a single value or a map of different browsers to the value for that browser.
@@ -1084,6 +1104,7 @@ interface ResolvedConfig {
1084
1104
  sourcesRoot: string;
1085
1105
  downloadedPackagesDir: string;
1086
1106
  downloadPackages: string[];
1107
+ compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
1087
1108
  };
1088
1109
  /**
1089
1110
  * @deprecated Use `build:manifestGenerated` hook instead.
@@ -320,6 +320,14 @@ interface InlineConfig {
320
320
  * ["@scope/package-name@1.1.3", "package-name@^2"]
321
321
  */
322
322
  downloadPackages?: string[];
323
+ /**
324
+ * Compression level to use when zipping files.
325
+ *
326
+ * Levels: 0 (no compression) to 9 (maximum compression).
327
+ *
328
+ * @default 9
329
+ */
330
+ compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
323
331
  };
324
332
  /**
325
333
  * @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
@@ -647,8 +655,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
647
655
  * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
648
656
  * manifest. This is the normal and most well known way of registering a content script.
649
657
  * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
650
- * responsible for using the scripting API to register the content script dynamically at
651
- * runtime.
658
+ * responsible for using the scripting API to register/execute the content script
659
+ * dynamically at runtime.
652
660
  *
653
661
  * @default "manifest"
654
662
  */
@@ -753,14 +761,22 @@ type OnContentScriptStopped = (cb: () => void) => void;
753
761
  interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
754
762
  /**
755
763
  * Main function executed when the content script is loaded.
764
+ *
765
+ * When running a content script with `browser.scripting.executeScript`,
766
+ * values returned from this function will be returned in the `executeScript`
767
+ * result as well. Otherwise returning a value does nothing.
756
768
  */
757
- main(ctx: ContentScriptContext): void | Promise<void>;
769
+ main(ctx: ContentScriptContext): any | Promise<any>;
758
770
  }
759
771
  interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
760
772
  /**
761
773
  * Main function executed when the content script is loaded.
774
+ *
775
+ * When running a content script with `browser.scripting.executeScript`,
776
+ * values returned from this function will be returned in the `executeScript`
777
+ * result as well. Otherwise returning a value does nothing.
762
778
  */
763
- main(): void | Promise<void>;
779
+ main(): any | Promise<any>;
764
780
  }
765
781
  type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
766
782
  interface BackgroundDefinition extends BackgroundEntrypointOptions {
@@ -772,8 +788,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
772
788
  interface UnlistedScriptDefinition extends BaseEntrypointOptions {
773
789
  /**
774
790
  * Main function executed when the unlisted script is ran.
791
+ *
792
+ * When running a content script with `browser.scripting.executeScript`,
793
+ * values returned from this function will be returned in the `executeScript`
794
+ * result as well. Otherwise returning a value does nothing.
775
795
  */
776
- main(): void | Promise<void>;
796
+ main(): any | Promise<any>;
777
797
  }
778
798
  /**
779
799
  * Either a single value or a map of different browsers to the value for that browser.
@@ -1084,6 +1104,7 @@ interface ResolvedConfig {
1084
1104
  sourcesRoot: string;
1085
1105
  downloadedPackagesDir: string;
1086
1106
  downloadPackages: string[];
1107
+ compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
1087
1108
  };
1088
1109
  /**
1089
1110
  * @deprecated Use `build:manifestGenerated` hook instead.
package/dist/index.cjs CHANGED
@@ -3274,13 +3274,31 @@ function toArray(a) {
3274
3274
  return Array.isArray(a) ? a : [a];
3275
3275
  }
3276
3276
 
3277
+ // src/core/utils/strings.ts
3278
+ function kebabCaseAlphanumeric(str) {
3279
+ return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
3280
+ }
3281
+ function safeVarName(str) {
3282
+ return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
3283
+ }
3284
+ function removeImportStatements(text) {
3285
+ return text.replace(
3286
+ /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
3287
+ ""
3288
+ );
3289
+ }
3290
+ function removeProjectImportStatements(text) {
3291
+ const noImports = removeImportStatements(text);
3292
+ return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
3293
+
3294
+ ${noImports}`;
3295
+ }
3296
+
3277
3297
  // src/core/builders/vite/index.ts
3278
3298
  async function createViteBuilder(wxtConfig, hooks, server) {
3279
3299
  const vite = await import("vite");
3280
3300
  const getBaseConfig = async () => {
3281
- const config = await wxtConfig.vite({
3282
- ...wxtConfig.env
3283
- });
3301
+ const config = await wxtConfig.vite(wxtConfig.env);
3284
3302
  config.root = wxtConfig.root;
3285
3303
  config.configFile = false;
3286
3304
  config.logLevel = "warn";
@@ -3322,14 +3340,22 @@ async function createViteBuilder(wxtConfig, hooks, server) {
3322
3340
  if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
3323
3341
  plugins.push(cssEntrypoints(entrypoint, wxtConfig));
3324
3342
  }
3343
+ const iifeReturnValueName = safeVarName(entrypoint.name);
3325
3344
  const libMode = {
3326
3345
  mode: wxtConfig.mode,
3327
3346
  plugins,
3347
+ esbuild: {
3348
+ // Add a footer with the returned value so it can return values to `scripting.executeScript`
3349
+ // Footer is added apart of esbuild to make sure it's not minified. It
3350
+ // get's removed if added to `build.rollupOptions.output.footer`
3351
+ // See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
3352
+ footer: iifeReturnValueName + ";"
3353
+ },
3328
3354
  build: {
3329
3355
  lib: {
3330
3356
  entry,
3331
3357
  formats: ["iife"],
3332
- name: "_",
3358
+ name: iifeReturnValueName,
3333
3359
  fileName: entrypoint.name
3334
3360
  },
3335
3361
  rollupOptions: {
@@ -4469,6 +4495,7 @@ function resolveZipConfig(root, mergedConfig) {
4469
4495
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
4470
4496
  sourcesRoot: root,
4471
4497
  includeSources: [],
4498
+ compressionLevel: 9,
4472
4499
  ...mergedConfig.zip,
4473
4500
  excludeSources: [
4474
4501
  "**/node_modules",
@@ -4617,25 +4644,6 @@ var import_jiti = __toESM(require("jiti"), 1);
4617
4644
  var import_unimport3 = require("unimport");
4618
4645
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
4619
4646
  var import_node_path13 = require("path");
4620
-
4621
- // src/core/utils/strings.ts
4622
- function kebabCaseAlphanumeric(str) {
4623
- return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
4624
- }
4625
- function removeImportStatements(text) {
4626
- return text.replace(
4627
- /(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
4628
- ""
4629
- );
4630
- }
4631
- function removeProjectImportStatements(text) {
4632
- const noImports = removeImportStatements(text);
4633
- return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
4634
-
4635
- ${noImports}`;
4636
- }
4637
-
4638
- // src/core/utils/building/import-entrypoint.ts
4639
4647
  var import_esbuild = require("esbuild");
4640
4648
  var import_node_url2 = require("url");
4641
4649
  var import_meta2 = {};
@@ -4836,7 +4844,7 @@ function getChunkSortWeight(filename) {
4836
4844
  var import_picocolors4 = __toESM(require("picocolors"), 1);
4837
4845
 
4838
4846
  // package.json
4839
- var version = "0.17.12";
4847
+ var version = "0.17.13-alpha1";
4840
4848
 
4841
4849
  // src/core/utils/log/printHeader.ts
4842
4850
  var import_consola2 = require("consola");
@@ -6276,7 +6284,13 @@ async function zipDir(directory, outputPath, options) {
6276
6284
  }
6277
6285
  }
6278
6286
  await options?.additionalWork?.(archive);
6279
- const buffer = await archive.generateAsync({ type: "base64" });
6287
+ const buffer = await archive.generateAsync({
6288
+ type: "base64",
6289
+ ...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
6290
+ compression: "DEFLATE",
6291
+ compressionOptions: { level: wxt.config.zip.compressionLevel }
6292
+ }
6293
+ });
6280
6294
  await import_fs_extra17.default.writeFile(outputPath, buffer, "base64");
6281
6295
  }
6282
6296
  async function downloadPrivatePackages() {
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-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';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-INepal5k.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-INepal5k.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.12";
68
+ var version = "0.17.13-alpha1";
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-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';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-INepal5k.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-INepal5k.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.12";
68
+ var version = "0.17.13-alpha1";
69
69
 
70
70
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  unnormalizePath,
20
20
  version,
21
21
  wxt
22
- } from "./chunk-C4ZVXF53.js";
22
+ } from "./chunk-YWGLK5GM.js";
23
23
  import "./chunk-5X3S6AWF.js";
24
24
  import "./chunk-VBXJIVYU.js";
25
25
 
@@ -641,7 +641,13 @@ async function zipDir(directory, outputPath, options) {
641
641
  }
642
642
  }
643
643
  await options?.additionalWork?.(archive);
644
- const buffer = await archive.generateAsync({ type: "base64" });
644
+ const buffer = await archive.generateAsync({
645
+ type: "base64",
646
+ ...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
647
+ compression: "DEFLATE",
648
+ compressionOptions: { level: wxt.config.zip.compressionLevel }
649
+ }
650
+ });
645
651
  await fs3.writeFile(outputPath, buffer, "base64");
646
652
  }
647
653
  async function downloadPrivatePackages() {
package/dist/sandbox.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-mYGv2dqk.js';
1
+ import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-Aan1uu3v.js';
2
2
  export * from '@webext-core/match-patterns';
3
3
  import 'webextension-polyfill';
4
4
 
package/dist/testing.cjs CHANGED
@@ -553,6 +553,7 @@ function resolveZipConfig(root, mergedConfig) {
553
553
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
554
554
  sourcesRoot: root,
555
555
  includeSources: [],
556
+ compressionLevel: 9,
556
557
  ...mergedConfig.zip,
557
558
  excludeSources: [
558
559
  "**/node_modules",
@@ -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-NHTTcok1.cjs';
3
+ import { I as InlineConfig } from './index-INepal5k.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-NHTTcok1.js';
3
+ import { I as InlineConfig } from './index-INepal5k.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-C4ZVXF53.js";
8
+ } from "./chunk-YWGLK5GM.js";
9
9
  import "./chunk-5X3S6AWF.js";
10
10
  import "./chunk-VBXJIVYU.js";
11
11
 
@@ -21,15 +21,20 @@ var logger = {
21
21
 
22
22
  // src/virtual/content-script-isolated-world-entrypoint.ts
23
23
  import { ContentScriptContext } from "wxt/client";
24
- (async () => {
24
+ var result = (async () => {
25
25
  try {
26
26
  const { main, ...options } = definition;
27
27
  const ctx = new ContentScriptContext(import.meta.env.ENTRYPOINT, options);
28
- await main(ctx);
28
+ return await main(ctx);
29
29
  } catch (err) {
30
30
  logger.error(
31
31
  `The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
32
32
  err
33
33
  );
34
+ throw err;
34
35
  }
35
36
  })();
37
+ var content_script_isolated_world_entrypoint_default = result;
38
+ export {
39
+ content_script_isolated_world_entrypoint_default as default
40
+ };
@@ -20,14 +20,19 @@ var logger = {
20
20
  };
21
21
 
22
22
  // src/virtual/content-script-main-world-entrypoint.ts
23
- (async () => {
23
+ var result = (async () => {
24
24
  try {
25
25
  const { main } = definition;
26
- await main();
26
+ return await main();
27
27
  } catch (err) {
28
28
  logger.error(
29
29
  `The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
30
30
  err
31
31
  );
32
+ throw err;
32
33
  }
33
34
  })();
35
+ var content_script_main_world_entrypoint_default = result;
36
+ export {
37
+ content_script_main_world_entrypoint_default as default
38
+ };
@@ -20,13 +20,18 @@ var logger = {
20
20
  };
21
21
 
22
22
  // src/virtual/unlisted-script-entrypoint.ts
23
- (async () => {
23
+ var result = (async () => {
24
24
  try {
25
- await definition.main();
25
+ return await definition.main();
26
26
  } catch (err) {
27
27
  logger.error(
28
28
  `The unlisted script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
29
29
  err
30
30
  );
31
+ throw err;
31
32
  }
32
33
  })();
34
+ var unlisted_script_entrypoint_default = result;
35
+ export {
36
+ unlisted_script_entrypoint_default as default
37
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.17.12",
4
+ "version": "0.17.13-alpha1",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -120,7 +120,7 @@
120
120
  "prompts": "^2.4.2",
121
121
  "publish-browser-extension": "^2.1.3",
122
122
  "unimport": "^3.4.0",
123
- "vite": "^5.1.3",
123
+ "vite": "^5.2.8",
124
124
  "web-ext-run": "^0.2.0",
125
125
  "webextension-polyfill": "^0.10.0"
126
126
  },