Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit aa31be6

Browse files
fix: use cjs interop to properly bundle makeup-js packages inside vite (#421)
* fix: use cjs interop to properly bundle makeup-js packages inside vite * Only interop default imports of makeup
1 parent d77874d commit aa31be6

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

.changeset/metal-monkeys-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ebay/ui-core-react": patch
3+
---
4+
5+
fix: use cjs interop to properly bundle makeup-js packages inside vite

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@
125125
"ts-jest": "^29.1.1",
126126
"ts-loader": "^8.0.7",
127127
"typescript": "4",
128-
"vite": "^5.4.7"
128+
"vite": "^5.4.7",
129+
"vite-plugin-cjs-interop": "^2.1.6"
129130
},
130131
"resolutions": {
131132
"@storybook/addon-actions": "~7.5.3",

vite.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
33
import { defineConfig } from "vite";
44
import { nodeExternals } from "rollup-plugin-node-externals";
55
import typescript from "@rollup/plugin-typescript";
6+
import { cjsInterop } from "vite-plugin-cjs-interop"
67

78
// find directories in src that starts with 'ebay-'
89
let componentEntries = fs
@@ -17,6 +18,18 @@ let componentEntries = fs
1718
});
1819

1920
export default defineConfig({
21+
plugins: [
22+
// This plugin will automatically unwrap the default export from CJS dependencies that are specified in the list.
23+
// https://github.com/eBay/ebayui-core-react/issues/420
24+
cjsInterop({
25+
// By default this plugin is only for SSR vite build, here we are in library mode, so we enable "client"
26+
client: true,
27+
dependencies: [
28+
'makeup-expander',
29+
'makeup-typeahead',
30+
]
31+
})
32+
],
2033
build: {
2134
lib: {
2235
entry: componentEntries,

yarn.lock

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4187,6 +4187,11 @@ acorn-globals@^7.0.0:
41874187
acorn "^8.1.0"
41884188
acorn-walk "^8.0.2"
41894189

4190+
acorn-import-assertions@^1.9.0:
4191+
version "1.9.0"
4192+
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac"
4193+
integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==
4194+
41904195
acorn-jsx@^5.3.1, acorn-jsx@^5.3.2:
41914196
version "5.3.2"
41924197
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
@@ -4209,7 +4214,7 @@ acorn@^7.4.0, acorn@^7.4.1:
42094214
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
42104215
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
42114216

4212-
acorn@^8.1.0, acorn@^8.11.0, acorn@^8.8.1:
4217+
acorn@^8.1.0, acorn@^8.11.0, acorn@^8.14.0, acorn@^8.8.1:
42134218
version "8.14.0"
42144219
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0"
42154220
integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==
@@ -6294,6 +6299,13 @@ estree-walker@^2.0.2:
62946299
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
62956300
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
62966301

6302+
estree-walker@^3.0.3:
6303+
version "3.0.3"
6304+
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-3.0.3.tgz#67c3e549ec402a487b4fc193d1953a524752340d"
6305+
integrity sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==
6306+
dependencies:
6307+
"@types/estree" "^1.0.0"
6308+
62976309
esutils@^2.0.2:
62986310
version "2.0.3"
62996311
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
@@ -8460,6 +8472,13 @@ magic-string@^0.30.0:
84608472
dependencies:
84618473
"@jridgewell/sourcemap-codec" "^1.5.0"
84628474

8475+
magic-string@^0.30.14:
8476+
version "0.30.17"
8477+
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.17.tgz#450a449673d2460e5bbcfba9a61916a1714c7453"
8478+
integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==
8479+
dependencies:
8480+
"@jridgewell/sourcemap-codec" "^1.5.0"
8481+
84638482
make-dir@^2.0.0, make-dir@^2.1.0:
84648483
version "2.1.0"
84658484
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
@@ -8690,6 +8709,13 @@ min-indent@^1.0.0, min-indent@^1.0.1:
86908709
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
86918710
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
86928711

8712+
minimatch@^10.0.1:
8713+
version "10.0.1"
8714+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b"
8715+
integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
8716+
dependencies:
8717+
brace-expansion "^2.0.1"
8718+
86938719
minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
86948720
version "3.1.2"
86958721
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@@ -11155,6 +11181,17 @@ vary@~1.1.2:
1115511181
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
1115611182
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==
1115711183

11184+
vite-plugin-cjs-interop@^2.1.6:
11185+
version "2.1.6"
11186+
resolved "https://registry.yarnpkg.com/vite-plugin-cjs-interop/-/vite-plugin-cjs-interop-2.1.6.tgz#fdf4939b6482d5736ef210c3d47b4732043b198d"
11187+
integrity sha512-K27lK88coT8GWEu5jMQb6LXSXaAfNnfSHl1DN06C43++SZ6DmoJh0fLluRfhLgT3Qd+lAmjrS5uA5xJTzmFjiA==
11188+
dependencies:
11189+
acorn "^8.14.0"
11190+
acorn-import-assertions "^1.9.0"
11191+
estree-walker "^3.0.3"
11192+
magic-string "^0.30.14"
11193+
minimatch "^10.0.1"
11194+
1115811195
vite@^5.4.7:
1115911196
version "5.4.12"
1116011197
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.12.tgz#627d12ff06de3942557dfe8632fd712a12a072c7"

0 commit comments

Comments
 (0)