From eb2fb1c96d9c58426c430773dd68d041343b6112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DUNGLER?= Date: Thu, 6 Jan 2022 09:33:29 +0100 Subject: [PATCH] fix(core): transpile more libs to es5 --- addons/interactions/src/Panel.tsx | 15 +++++++++------ lib/core-common/src/utils/es6Transpiler.ts | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/interactions/src/Panel.tsx b/addons/interactions/src/Panel.tsx index 722715504e8f..e290d5d453ba 100644 --- a/addons/interactions/src/Panel.tsx +++ b/addons/interactions/src/Panel.tsx @@ -121,12 +121,15 @@ export const Panel: React.FC = (props) => { const endRef = React.useRef(); React.useEffect(() => { - const observer = new global.window.IntersectionObserver( - ([end]: any) => setScrollTarget(end.isIntersecting ? undefined : end.target), - { root: global.window.document.querySelector('#panel-tab-content') } - ); - if (endRef.current) observer.observe(endRef.current); - return () => observer.disconnect(); + let observer: IntersectionObserver; + if (global.window.IntersectionObserver) { + observer = new global.window.IntersectionObserver( + ([end]: any) => setScrollTarget(end.isIntersecting ? undefined : end.target), + { root: global.window.document.querySelector('#panel-tab-content') } + ); + if (endRef.current) observer.observe(endRef.current); + } + return () => observer?.disconnect(); }, []); const emit = useChannel( diff --git a/lib/core-common/src/utils/es6Transpiler.ts b/lib/core-common/src/utils/es6Transpiler.ts index 5b6c45900656..b4b0748a9ce6 100644 --- a/lib/core-common/src/utils/es6Transpiler.ts +++ b/lib/core-common/src/utils/es6Transpiler.ts @@ -4,6 +4,7 @@ import { getStorybookBabelConfig } from './babel'; const { plugins } = getStorybookBabelConfig(); const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = [ + '@storybook[\\\\/]expect', '@storybook[\\\\/]node_logger', '@testing-library[\\\\/]dom', '@testing-library[\\\\/]user-event', @@ -22,14 +23,18 @@ const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = [ 'find-up', 'fs-extra', 'highlight.js', + 'jest-mock', 'json5', 'node-fetch', 'pkg-dir', 'prettier', 'pretty-format', + 'react-router', + 'react-router-dom', 'resolve-from', 'semver', 'slash', + 'strip-ansi', ].map((n) => new RegExp(`[\\\\/]node_modules[\\\\/]${n}`)); export const es6Transpiler: () => RuleSetRule = () => {