wxt 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -31,7 +31,7 @@ interface InlineConfig {
31
31
  /**
32
32
  * > Only available when using the JS API. Not available in `wxt.config.ts` files
33
33
  *
34
- * Path to `"wxt.config.ts"` file or false to disable config file discovery.
34
+ * Path to `wxt.config.ts` file or `false` to disable config file discovery.
35
35
  *
36
36
  * @default "wxt.config.ts"
37
37
  */
@@ -56,9 +56,19 @@ interface InlineConfig {
56
56
  */
57
57
  mode?: string;
58
58
  /**
59
- * Customize auto-import options.
59
+ * Customize auto-import options. Set to `false` to disable auto-imports.
60
+ *
61
+ * For example, to add a directory to auto-import from, you can use:
62
+ *
63
+ * ```ts
64
+ * export default defineConfig({
65
+ * imports: {
66
+ * dirs: ["some-directory"]
67
+ * }
68
+ * })
69
+ * ```
60
70
  */
61
- imports?: Partial<UnimportOptions>;
71
+ imports?: Partial<UnimportOptions> | false;
62
72
  /**
63
73
  * Explicitly set a browser to build for. This will override the default browser for each command,
64
74
  * and can be overridden by the command line `--browser` option.
@@ -80,7 +90,9 @@ interface InlineConfig {
80
90
  */
81
91
  logger?: Logger;
82
92
  /**
83
- * Custom Vite options.
93
+ * Custom Vite options, see <https://vitejs.dev/config/shared-options.html>.
94
+ *
95
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config.
84
96
  */
85
97
  vite?: Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
86
98
  /**
@@ -88,10 +100,6 @@ interface InlineConfig {
88
100
  * object or promise.
89
101
  */
90
102
  manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
91
- /**
92
- * Custom server options.
93
- */
94
- server?: WxtDevServer;
95
103
  /**
96
104
  * Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
97
105
  */
@@ -205,7 +213,7 @@ interface WxtDevServer extends vite.ViteDevServer {
205
213
  */
206
214
  reloadContentScript: (contentScript: Omit<Scripting.RegisteredContentScript, 'id'>) => void;
207
215
  }
208
- type TargetBrowser = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera';
216
+ type TargetBrowser = string;
209
217
  type TargetManifestVersion = 2 | 3;
210
218
  type UserConfig = Omit<InlineConfig, 'configFile'>;
211
219
  interface Logger {
@@ -218,6 +226,10 @@ interface Logger {
218
226
  success(...args: any[]): void;
219
227
  level: LogLevel;
220
228
  }
229
+ interface BaseEntrypointOptions {
230
+ include?: TargetBrowser[];
231
+ exclude?: TargetBrowser[];
232
+ }
221
233
  interface BaseEntrypoint {
222
234
  /**
223
235
  * The entrypoint's name. This is the filename or dirname without the type suffix.
@@ -245,6 +257,7 @@ interface BaseEntrypoint {
245
257
  * subdirectory of it.
246
258
  */
247
259
  outputDir: string;
260
+ options: BaseEntrypointOptions;
248
261
  }
249
262
  interface GenericEntrypoint extends BaseEntrypoint {
250
263
  type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
@@ -254,11 +267,11 @@ interface BackgroundEntrypoint extends BaseEntrypoint {
254
267
  options: {
255
268
  persistent?: boolean;
256
269
  type?: 'module';
257
- };
270
+ } & BaseEntrypointOptions;
258
271
  }
259
272
  interface ContentScriptEntrypoint extends BaseEntrypoint {
260
273
  type: 'content-script';
261
- options: Omit<ContentScriptDefinition, 'main'>;
274
+ options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
262
275
  }
263
276
  interface PopupEntrypoint extends BaseEntrypoint {
264
277
  type: 'popup';
@@ -269,7 +282,7 @@ interface PopupEntrypoint extends BaseEntrypoint {
269
282
  mv2Key?: 'browser_action' | 'page_action';
270
283
  defaultIcon?: Record<string, string>;
271
284
  defaultTitle?: string;
272
- };
285
+ } & BaseEntrypointOptions;
273
286
  }
274
287
  interface OptionsEntrypoint extends BaseEntrypoint {
275
288
  type: 'options';
@@ -277,11 +290,11 @@ interface OptionsEntrypoint extends BaseEntrypoint {
277
290
  openInTab?: boolean;
278
291
  browserStyle?: boolean;
279
292
  chromeStyle?: boolean;
280
- };
293
+ } & BaseEntrypointOptions;
281
294
  }
282
295
  type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
283
296
  type OnContentScriptStopped = (cb: () => void) => void;
284
- interface ContentScriptDefinition {
297
+ interface ContentScriptDefinition extends ExcludableEntrypoint {
285
298
  matches: Manifest.ContentScript['matches'];
286
299
  /**
287
300
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -328,10 +341,26 @@ interface ContentScriptDefinition {
328
341
  */
329
342
  main(): void | Promise<void>;
330
343
  }
331
- interface BackgroundScriptDefintition {
344
+ interface BackgroundScriptDefintition extends ExcludableEntrypoint {
332
345
  type?: 'module';
333
346
  main(): void;
334
347
  }
348
+ interface ExcludableEntrypoint {
349
+ /**
350
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
351
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
352
+ *
353
+ * @default undefined
354
+ */
355
+ include?: TargetBrowser[];
356
+ /**
357
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
358
+ * must choose one of the two options.
359
+ *
360
+ * @default undefined
361
+ */
362
+ exclude?: TargetBrowser[];
363
+ }
335
364
  /**
336
365
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
337
366
  * here, they are configured inline.
@@ -364,25 +393,11 @@ interface ExtensionRunnerConfig {
364
393
  openDevtools?: boolean;
365
394
  /**
366
395
  * List of browser names and the binary that should be used to open the browser.
396
+ *
397
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
398
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
367
399
  */
368
- binaries?: {
369
- /**
370
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
371
- */
372
- chrome?: string;
373
- /**
374
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
375
- */
376
- edge?: string;
377
- /**
378
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
379
- */
380
- opera?: string;
381
- /**
382
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
383
- */
384
- firefox?: 'firefox' | 'beta' | 'nightly' | 'deved' | 'firefoxdeveloperedition' | string;
385
- };
400
+ binaries?: Record<string, string>;
386
401
  /**
387
402
  * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
388
403
  */
@@ -418,7 +433,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
418
433
  */
419
434
  declare function clean(root?: string): Promise<void>;
420
435
 
421
- var version = "0.4.1";
436
+ var version = "0.5.1";
422
437
 
423
438
  declare function defineConfig(config: UserConfig): UserConfig;
424
439
 
@@ -434,4 +449,4 @@ declare function build(config: InlineConfig): Promise<BuildOutput>;
434
449
  */
435
450
  declare function createServer(config?: InlineConfig): Promise<WxtDevServer>;
436
451
 
437
- export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, clean, createServer, defineConfig, defineRunnerConfig, version };
452
+ export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BaseEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExcludableEntrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, clean, createServer, defineConfig, defineRunnerConfig, version };
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ interface InlineConfig {
31
31
  /**
32
32
  * > Only available when using the JS API. Not available in `wxt.config.ts` files
33
33
  *
34
- * Path to `"wxt.config.ts"` file or false to disable config file discovery.
34
+ * Path to `wxt.config.ts` file or `false` to disable config file discovery.
35
35
  *
36
36
  * @default "wxt.config.ts"
37
37
  */
@@ -56,9 +56,19 @@ interface InlineConfig {
56
56
  */
57
57
  mode?: string;
58
58
  /**
59
- * Customize auto-import options.
59
+ * Customize auto-import options. Set to `false` to disable auto-imports.
60
+ *
61
+ * For example, to add a directory to auto-import from, you can use:
62
+ *
63
+ * ```ts
64
+ * export default defineConfig({
65
+ * imports: {
66
+ * dirs: ["some-directory"]
67
+ * }
68
+ * })
69
+ * ```
60
70
  */
61
- imports?: Partial<UnimportOptions>;
71
+ imports?: Partial<UnimportOptions> | false;
62
72
  /**
63
73
  * Explicitly set a browser to build for. This will override the default browser for each command,
64
74
  * and can be overridden by the command line `--browser` option.
@@ -80,7 +90,9 @@ interface InlineConfig {
80
90
  */
81
91
  logger?: Logger;
82
92
  /**
83
- * Custom Vite options.
93
+ * Custom Vite options, see <https://vitejs.dev/config/shared-options.html>.
94
+ *
95
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config.
84
96
  */
85
97
  vite?: Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
86
98
  /**
@@ -88,10 +100,6 @@ interface InlineConfig {
88
100
  * object or promise.
89
101
  */
90
102
  manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
91
- /**
92
- * Custom server options.
93
- */
94
- server?: WxtDevServer;
95
103
  /**
96
104
  * Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
97
105
  */
@@ -205,7 +213,7 @@ interface WxtDevServer extends vite.ViteDevServer {
205
213
  */
206
214
  reloadContentScript: (contentScript: Omit<Scripting.RegisteredContentScript, 'id'>) => void;
207
215
  }
208
- type TargetBrowser = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera';
216
+ type TargetBrowser = string;
209
217
  type TargetManifestVersion = 2 | 3;
210
218
  type UserConfig = Omit<InlineConfig, 'configFile'>;
211
219
  interface Logger {
@@ -218,6 +226,10 @@ interface Logger {
218
226
  success(...args: any[]): void;
219
227
  level: LogLevel;
220
228
  }
229
+ interface BaseEntrypointOptions {
230
+ include?: TargetBrowser[];
231
+ exclude?: TargetBrowser[];
232
+ }
221
233
  interface BaseEntrypoint {
222
234
  /**
223
235
  * The entrypoint's name. This is the filename or dirname without the type suffix.
@@ -245,6 +257,7 @@ interface BaseEntrypoint {
245
257
  * subdirectory of it.
246
258
  */
247
259
  outputDir: string;
260
+ options: BaseEntrypointOptions;
248
261
  }
249
262
  interface GenericEntrypoint extends BaseEntrypoint {
250
263
  type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
@@ -254,11 +267,11 @@ interface BackgroundEntrypoint extends BaseEntrypoint {
254
267
  options: {
255
268
  persistent?: boolean;
256
269
  type?: 'module';
257
- };
270
+ } & BaseEntrypointOptions;
258
271
  }
259
272
  interface ContentScriptEntrypoint extends BaseEntrypoint {
260
273
  type: 'content-script';
261
- options: Omit<ContentScriptDefinition, 'main'>;
274
+ options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
262
275
  }
263
276
  interface PopupEntrypoint extends BaseEntrypoint {
264
277
  type: 'popup';
@@ -269,7 +282,7 @@ interface PopupEntrypoint extends BaseEntrypoint {
269
282
  mv2Key?: 'browser_action' | 'page_action';
270
283
  defaultIcon?: Record<string, string>;
271
284
  defaultTitle?: string;
272
- };
285
+ } & BaseEntrypointOptions;
273
286
  }
274
287
  interface OptionsEntrypoint extends BaseEntrypoint {
275
288
  type: 'options';
@@ -277,11 +290,11 @@ interface OptionsEntrypoint extends BaseEntrypoint {
277
290
  openInTab?: boolean;
278
291
  browserStyle?: boolean;
279
292
  chromeStyle?: boolean;
280
- };
293
+ } & BaseEntrypointOptions;
281
294
  }
282
295
  type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
283
296
  type OnContentScriptStopped = (cb: () => void) => void;
284
- interface ContentScriptDefinition {
297
+ interface ContentScriptDefinition extends ExcludableEntrypoint {
285
298
  matches: Manifest.ContentScript['matches'];
286
299
  /**
287
300
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -328,10 +341,26 @@ interface ContentScriptDefinition {
328
341
  */
329
342
  main(): void | Promise<void>;
330
343
  }
331
- interface BackgroundScriptDefintition {
344
+ interface BackgroundScriptDefintition extends ExcludableEntrypoint {
332
345
  type?: 'module';
333
346
  main(): void;
334
347
  }
348
+ interface ExcludableEntrypoint {
349
+ /**
350
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
351
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
352
+ *
353
+ * @default undefined
354
+ */
355
+ include?: TargetBrowser[];
356
+ /**
357
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
358
+ * must choose one of the two options.
359
+ *
360
+ * @default undefined
361
+ */
362
+ exclude?: TargetBrowser[];
363
+ }
335
364
  /**
336
365
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
337
366
  * here, they are configured inline.
@@ -364,25 +393,11 @@ interface ExtensionRunnerConfig {
364
393
  openDevtools?: boolean;
365
394
  /**
366
395
  * List of browser names and the binary that should be used to open the browser.
396
+ *
397
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
398
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
367
399
  */
368
- binaries?: {
369
- /**
370
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
371
- */
372
- chrome?: string;
373
- /**
374
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
375
- */
376
- edge?: string;
377
- /**
378
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
379
- */
380
- opera?: string;
381
- /**
382
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
383
- */
384
- firefox?: 'firefox' | 'beta' | 'nightly' | 'deved' | 'firefoxdeveloperedition' | string;
385
- };
400
+ binaries?: Record<string, string>;
386
401
  /**
387
402
  * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
388
403
  */
@@ -418,7 +433,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
418
433
  */
419
434
  declare function clean(root?: string): Promise<void>;
420
435
 
421
- var version = "0.4.1";
436
+ var version = "0.5.1";
422
437
 
423
438
  declare function defineConfig(config: UserConfig): UserConfig;
424
439
 
@@ -434,4 +449,4 @@ declare function build(config: InlineConfig): Promise<BuildOutput>;
434
449
  */
435
450
  declare function createServer(config?: InlineConfig): Promise<WxtDevServer>;
436
451
 
437
- export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, clean, createServer, defineConfig, defineRunnerConfig, version };
452
+ export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BaseEntrypointOptions, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExcludableEntrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, clean, createServer, defineConfig, defineRunnerConfig, version };