From 3fb6e1430cca671b91f7baf1608ee922dca07e6b Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 3 Jul 2024 16:09:17 +0200 Subject: [PATCH] Hide module level directive warnings --- packages/snaps-storybook/src/preset.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/snaps-storybook/src/preset.ts b/packages/snaps-storybook/src/preset.ts index 92fadf5305..5d12ff13c2 100644 --- a/packages/snaps-storybook/src/preset.ts +++ b/packages/snaps-storybook/src/preset.ts @@ -137,6 +137,19 @@ export const previewHead: PresetProperty<'previewHead'> = (head = '') => ` export const viteFinal: ViteFinal = (config) => { return { ...config, + build: { + ...config.build, + rollupOptions: { + ...config.build?.rollupOptions, + onwarn: (warning, warn) => { + if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { + return; + } + + warn(warning); + }, + }, + }, plugins: [ ...(config.plugins as PluginOption[]), nodePolyfills({