@@ -111,6 +111,7 @@ def component_from_npm(
111111 resolve_imports_depth : int = ...,
112112 version : str = "latest" ,
113113 cdn : str = "https://esm.sh/v135" ,
114+ bundle : bool = ...,
114115 fallback : Any | None = ...,
115116 unmount_before_update : bool = ...,
116117 allow_children : bool = ...,
@@ -125,6 +126,7 @@ def component_from_npm(
125126 resolve_imports_depth : int = ...,
126127 version : str = "latest" ,
127128 cdn : str = "https://esm.sh/v135" ,
129+ bundle : bool = ...,
128130 fallback : Any | None = ...,
129131 unmount_before_update : bool = ...,
130132 allow_children : bool = ...,
@@ -138,6 +140,7 @@ def component_from_npm(
138140 resolve_imports_depth : int = 5 ,
139141 version : str = "latest" ,
140142 cdn : str = "https://esm.sh/v135" ,
143+ bundle : bool = True ,
141144 fallback : Any | None = None ,
142145 unmount_before_update : bool = False ,
143146 allow_children : bool = True ,
@@ -162,6 +165,13 @@ def component_from_npm(
162165 The version of the package to use. Defaults to "latest".
163166 cdn:
164167 The CDN to use. Defaults to "https://esm.sh".
168+ bundle:
169+ Whether to ask the CDN (e.g. esm.sh) to bundle the package's dependencies
170+ into a single module. Defaults to ``True`` for faster loads in the common
171+ case, but some packages (e.g. MUI v7) ship sub-paths that esm.sh's bundle
172+ mode fails to rewrite correctly. Set this to ``False`` to fall back to
173+ esm.sh's per-module resolution, which is slower but more robust to
174+ package-specific bundling quirks.
165175 fallback:
166176 What to temporarily display while the module is being loaded.
167177 unmount_before_update:
@@ -176,7 +186,10 @@ def component_from_npm(
176186
177187 if "esm.sh" in cdn :
178188 url += "&" if "?" in url else "?"
179- url += "external=react,react-dom,react/jsx-runtime&bundle&target=es2020"
189+ url += "external=react,react-dom,react/jsx-runtime"
190+ if bundle :
191+ url += "&bundle"
192+ url += "&target=es2020"
180193
181194 return component_from_url (
182195 url ,
0 commit comments