From 2d54a131b23e44d967270e4d54fd66fcb098e38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Tue, 14 Nov 2023 12:23:29 +0100 Subject: [PATCH] fix: add "use client" to non hook components like the Button (#2895) With that change we increase the number of affected files from 30 to 80. --- packages/dnb-eufemia/babel.config.js | 14 +++++++++++++- .../scripts/postbuild/__tests__/postbuild.test.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/dnb-eufemia/babel.config.js b/packages/dnb-eufemia/babel.config.js index be2a37a8e03..f392b5d8478 100644 --- a/packages/dnb-eufemia/babel.config.js +++ b/packages/dnb-eufemia/babel.config.js @@ -78,7 +78,19 @@ const productionPlugins = [ ] if (global.bundler !== 'rollup') { - productionPlugins.push('babel-plugin-transform-next-use-client') + productionPlugins.push([ + 'babel-plugin-transform-next-use-client', + { + customClientImports: [ + 'Context', + 'Provider', + 'useMedia', + 'useMediaQuery', + 'useEventEmitter', + 'useTheme', + ], + }, + ]) } if (typeof process.env.BABEL_ENV !== 'undefined') { diff --git a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts index 70d1fe92dce..5b65144283b 100644 --- a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts +++ b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts @@ -290,7 +290,7 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/accordion/Accordion.js` + `build${stage}/components/button/Button.js` ), 'utf-8' )