Skip to content

Commit 3009b1e

Browse files
committed
fix(build): switch to UMD and externalize dependencies
- Change webpack library type from `module` to `umd` to resolve `styled-components` resolution issues in consumer plugins (fixes "Cannot read properties of undefined"). - Add `globalObject: 'this'` for better UMD compatibility across environments. - Externalize `react-icons`, `@tippyjs/react`, and `tippy.js` to reduce bundle size and prevent code duplication. - Move tippy packages from `dependencies` to `peerDependencies` in package.json.
1 parent 6c036c7 commit 3009b1e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
"@emotion/styled": "^11.14.1",
3535
"@mui/material": "^7.3.1",
3636
"@mui/styles": "^6.4.8",
37+
"@tippyjs/react": "^4.2.6",
3738
"prop-types": "^15.8.1",
3839
"react": ">=18.0.0",
3940
"react-dom": ">=18.0.0",
4041
"react-icons": "^5.5.0",
4142
"react-modal": ">=3.16.1",
42-
"styled-components": ">=5.3.0"
43+
"styled-components": ">=5.3.0",
44+
"tippy.js": "^6.3.7"
4345
},
4446
"devDependencies": {
4547
"@babel/cli": "^7.25.6",
@@ -85,8 +87,6 @@
8587
"@mui/icons-material": "^7.3.1",
8688
"@storybook/addon-a11y": "^9.1.5",
8789
"@storybook/addon-actions": "^9.0.8",
88-
"@tippyjs/react": "^4.2.6",
89-
"react-modal": ">=3.16.1",
90-
"tippy.js": "^6.3.7"
90+
"react-modal": ">=3.16.1"
9191
}
9292
}

webpack.config.babel.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ export default {
2121
path: path.resolve('./dist/components'),
2222
filename: '[name].js',
2323
library: {
24-
type: 'module',
24+
type: 'umd',
2525
},
26-
module: true,
27-
environment: { module: true },
28-
},
29-
experiments: {
30-
outputModule: true,
26+
globalObject: 'this',
3127
},
3228
externals: {
3329
react: 'react',
3430
'react-dom': 'react-dom',
3531
'styled-components': 'styled-components',
3632
'react-modal': 'react-modal',
33+
'react-icons': 'react-icons',
34+
'@tippyjs/react': '@tippyjs/react',
35+
'tippy.js': 'tippy.js',
3736
},
3837
resolve: {
3938
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],

0 commit comments

Comments
 (0)