From e6fbc620e8de793f4bd5fd5bf5719144e3dfe509 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 22 Jul 2024 12:47:30 +0200 Subject: [PATCH] fix(browser): don't bundle `afterEach` cleanup hooks in node entrypoint (#6192) --- packages/browser/rollup.config.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/browser/rollup.config.js b/packages/browser/rollup.config.js index 64987eb9cb74..f846fb865e0b 100644 --- a/packages/browser/rollup.config.js +++ b/packages/browser/rollup.config.js @@ -43,7 +43,22 @@ export default () => format: 'esm', }, external, - plugins, + plugins: [ + { + name: 'no-side-effects', + async resolveId(id, importer) { + // Clipboard injects "afterEach" callbacks + // We mark it as having no side effects to prevent it from being included in the bundle + if (id.includes('dataTransfer/Clipboard')) { + return { + ...await this.resolve(id, importer), + moduleSideEffects: false, + } + } + }, + }, + ...plugins, + ], }, { input: './src/client/tester/context.ts',