Skip to content

Commit 1e98210

Browse files
committed
add suppressWarnings config option
1 parent 2cc2385 commit 1e98210

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

packages/wxt/src/core/resolve-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export async function resolveConfig(
226226
userConfigMetadata: userConfigMetadata ?? {},
227227
alias,
228228
experimental: defu(mergedConfig.experimental, {}),
229+
suppressWarnings: mergedConfig.suppressWarnings ?? {},
229230
dev: {
230231
server: devServerConfig,
231232
reloadCommand,

packages/wxt/src/core/utils/manifest.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ export async function generateManifest(
121121
// Warn if building for Firefox without data_collection_permissions
122122
if (
123123
wxt.config.browser === 'firefox' &&
124-
!userManifest.browser_specific_settings?.gecko?.data_collection_permissions
124+
!userManifest.browser_specific_settings?.gecko
125+
?.data_collection_permissions &&
126+
!wxt.config.suppressWarnings?.firefoxDataCollection
125127
) {
126128
wxt.logger.warn(
127-
'Firefox requires explicit data collection permissions. Consider adding `data_collection_permissions` to your manifest config.\n' +
128-
'For more details, see: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/\n',
129+
'Firefox requires `data_collection_permissions` for new extensions from November 3, 2025. Existing extensions are exempt for now.\n' +
130+
'For more details, see: https://extensionworkshop.com/documentation/develop/firefox-builtin-data-consent/\n' +
131+
'To suppress this warning, add `firefoxDataCollection: true` to `suppressWarnings` in your wxt config.\n',
129132
);
130133
}
131134

packages/wxt/src/core/utils/testing/fake-objects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export const fakeResolvedConfig = fakeObjectCreator<ResolvedConfig>(() => {
305305
hooks: {},
306306
vite: () => ({}),
307307
plugins: [],
308+
suppressWarnings: {},
308309
};
309310
});
310311

packages/wxt/src/types.ts

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ export interface InlineConfig {
131131
* object or promise.
132132
*/
133133
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
134+
/**
135+
* Suppress specific warnings during the build process.
136+
*
137+
* @example
138+
* ```ts
139+
* export default defineConfig({
140+
* suppressWarnings: {
141+
* firefoxDataCollection: true,
142+
* },
143+
* })
144+
* ```
145+
*/
146+
suppressWarnings?: { firefoxDataCollection?: boolean } & Record<
147+
string,
148+
boolean
149+
>;
134150
/**
135151
* Configure browser startup. Options set here can be overridden in a `web-ext.config.ts` file.
136152
*/
@@ -462,7 +478,8 @@ export interface BuildStepOutput {
462478
}
463479

464480
export interface WxtDevServer
465-
extends Omit<WxtBuilderServer, 'listen' | 'close'>, ServerInfo {
481+
extends Omit<WxtBuilderServer, 'listen' | 'close'>,
482+
ServerInfo {
466483
/**
467484
* Stores the current build output of the server.
468485
*/
@@ -566,7 +583,8 @@ export interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
566583
type?: PerBrowserOption<'module'>;
567584
}
568585

569-
export interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
586+
export interface BaseContentScriptEntrypointOptions
587+
extends BaseEntrypointOptions {
570588
matches?: PerBrowserOption<NonNullable<ManifestContentScript['matches']>>;
571589
/**
572590
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -633,14 +651,16 @@ export interface BaseContentScriptEntrypointOptions extends BaseEntrypointOption
633651
registration?: PerBrowserOption<'manifest' | 'runtime'>;
634652
}
635653

636-
export interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
654+
export interface MainWorldContentScriptEntrypointOptions
655+
extends BaseContentScriptEntrypointOptions {
637656
/**
638657
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
639658
*/
640659
world: 'MAIN';
641660
}
642661

643-
export interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
662+
export interface IsolatedWorldContentScriptEntrypointOptions
663+
extends BaseContentScriptEntrypointOptions {
644664
/**
645665
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
646666
* @default "ISOLATED"
@@ -776,7 +796,8 @@ export type EntrypointGroup = Entrypoint | Entrypoint[];
776796

777797
export type OnContentScriptStopped = (cb: () => void) => void;
778798

779-
export interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
799+
export interface IsolatedWorldContentScriptDefinition
800+
extends IsolatedWorldContentScriptEntrypointOptions {
780801
/**
781802
* Main function executed when the content script is loaded.
782803
*
@@ -787,7 +808,8 @@ export interface IsolatedWorldContentScriptDefinition extends IsolatedWorldConte
787808
main(ctx: ContentScriptContext): any | Promise<any>;
788809
}
789810

790-
export interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
811+
export interface MainWorldContentScriptDefinition
812+
extends MainWorldContentScriptEntrypointOptions {
791813
/**
792814
* Main function executed when the content script is loaded.
793815
*
@@ -1393,6 +1415,13 @@ export interface ResolvedConfig {
13931415
*/
13941416
alias: Record<string, string>;
13951417
experimental: {};
1418+
/**
1419+
* List of warning identifiers to suppress during the build process.
1420+
*/
1421+
suppressWarnings: { firefoxDataCollection?: boolean } & Record<
1422+
string,
1423+
boolean
1424+
>;
13961425
dev: {
13971426
/** Only defined during dev command */
13981427
server?: {
@@ -1576,9 +1605,8 @@ export interface WxtModule<TOptions extends WxtModuleOptions> {
15761605
setup?: WxtModuleSetup<TOptions>;
15771606
}
15781607

1579-
export interface WxtModuleWithMetadata<
1580-
TOptions extends WxtModuleOptions,
1581-
> extends WxtModule<TOptions> {
1608+
export interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions>
1609+
extends WxtModule<TOptions> {
15821610
type: 'local' | 'node_module';
15831611
id: string;
15841612
}

0 commit comments

Comments
 (0)