Skip to content

Commit

Permalink
bypass bundler import for loading inert polyfill (#2145)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank99 authored Jul 16, 2024
1 parent e469f6a commit 774e584
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-candles-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

Fixed an issue where the `Overlay` component was causing bundler warnings about a non-analyzable expression used in a dependency.
10 changes: 7 additions & 3 deletions packages/itwinui-react/src/core/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { Box, polymorphic } from '../../utils/index.js';
import { Box, isUnitTest, polymorphic } from '../../utils/index.js';
import type { PolymorphicForwardRefComponent } from '../../utils/index.js';

type OverlayComponentProps = {
Expand Down Expand Up @@ -112,8 +112,12 @@ const useInertPolyfill = () => {

React.useEffect(() => {
(async () => {
if (!HTMLElement.prototype.hasOwnProperty('inert') && !loaded.current) {
await import(/* webpackIgnore: true */ /* @vite-ignore */ modulePath);
if (
!HTMLElement.prototype.hasOwnProperty('inert') &&
!loaded.current &&
!isUnitTest
) {
await new Function('url', 'return import(url)')(modulePath);
loaded.current = true;
}
})();
Expand Down

0 comments on commit 774e584

Please sign in to comment.