From 74c830a425cdee5bc22615be748df77730b28241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Thu, 9 Nov 2023 20:23:39 +0100 Subject: [PATCH] fix: remove nullish operator to support Storybook v6 --- packages/dnb-eufemia/babel.config.js | 1 + packages/dnb-eufemia/package.json | 1 + .../scripts/postbuild/__tests__/postbuild.test.ts | 11 +++++++++++ yarn.lock | 13 +++++++++++++ 4 files changed, 26 insertions(+) diff --git a/packages/dnb-eufemia/babel.config.js b/packages/dnb-eufemia/babel.config.js index 898707facb3..6da23a4ae7b 100644 --- a/packages/dnb-eufemia/babel.config.js +++ b/packages/dnb-eufemia/babel.config.js @@ -99,6 +99,7 @@ const config = { '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining', + '@babel/plugin-transform-nullish-coalescing-operator', ], sourceMaps: true, comments: false, diff --git a/packages/dnb-eufemia/package.json b/packages/dnb-eufemia/package.json index 0ce8f85b442..468f1fe28a1 100644 --- a/packages/dnb-eufemia/package.json +++ b/packages/dnb-eufemia/package.json @@ -145,6 +145,7 @@ "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-syntax-typescript": "7.22.5", "@babel/plugin-transform-modules-commonjs": "7.22.5", + "@babel/plugin-transform-nullish-coalescing-operator": "7.23.3", "@babel/plugin-transform-react-constant-elements": "7.22.5", "@babel/plugin-transform-runtime": "7.22.5", "@babel/preset-env": "7.22.5", diff --git a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts index d2d12bf58a9..b382cc4b8c4 100644 --- a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts +++ b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts @@ -274,6 +274,17 @@ describe('babel build', () => { path.resolve(packpath.self(), `build${stage}/components/Input.js`) ) ).toBe(true) + + { + const content = fs.readFileSync( + path.resolve( + packpath.self(), + `build${stage}/components/card/Card.js` + ), + 'utf-8' + ) + expect(content).not.toContain('??') + } }) }) diff --git a/yarn.lock b/yarn.lock index d5971f63c77..dda828258b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1985,6 +1985,18 @@ __metadata: languageName: node linkType: hard +"@babel/plugin-transform-nullish-coalescing-operator@npm:7.23.3": + version: 7.23.3 + resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.23.3" + dependencies: + "@babel/helper-plugin-utils": "npm:^7.22.5" + "@babel/plugin-syntax-nullish-coalescing-operator": "npm:^7.8.3" + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: ea844a12a3ae5647d6d2ae0685fde48ae53e724ef9ce5d9fbf36e8f1ff0107f76a5349ef34c2a06984b3836c001748caf9701afb172bd7ba71a5dff79e16b434 + languageName: node + linkType: hard + "@babel/plugin-transform-nullish-coalescing-operator@npm:^7.22.11": version: 7.22.11 resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.22.11" @@ -2995,6 +3007,7 @@ __metadata: "@babel/plugin-syntax-dynamic-import": "npm:7.8.3" "@babel/plugin-syntax-typescript": "npm:7.22.5" "@babel/plugin-transform-modules-commonjs": "npm:7.22.5" + "@babel/plugin-transform-nullish-coalescing-operator": "npm:7.23.3" "@babel/plugin-transform-react-constant-elements": "npm:7.22.5" "@babel/plugin-transform-runtime": "npm:7.22.5" "@babel/preset-env": "npm:7.22.5"