-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESM][core] Add exports
to the package.json
#26254
Comments
This would be useful applied to both the 4.x branch and the upcoming 5.x too. |
4.x only receives critical updates. And since there's some possible breakage with regards to file extension usage we probably can't even apply it to 4.x. So 5.x is the safer target for now. |
This makes me think of a past exploration I had to modernize our CDN /examples. See skypackjs/skypack-cdn#118. |
While I don't really buy in the motivation raised in the issue's description. The CDN like builder use case seems niche (you can prototype with codesandbox and build with vite/next.js, why a CDN?). Looking closer, it seems to prevent private paths to be imported. See:
This sounds really interesting. We have been struggling in the past with developers that import too deep and have a broken page. |
exports
to package.json
exports
to package.jsonexports
to the package.json
Ok, finally got our app updated to MUI 5.0.0-beta.2 - would the core MUI team still be receptive to have |
Nothing has changed about that. Be aware that a |
It seems that @mui are not a viable option for prototyping UIs in Framer. 18 months to pick your toes about what surely cannot be a big deal looks bad. |
@jollytoad Is this a limitation of JSPM? I guess you could use https://esm.sh/ instead, e.g. https://codepen.io/oliviertassinari/pen/VwBjrvP?editors=1010 import React from "https://esm.sh/react@18"
import { Button } from "https://esm.sh/@mui/material"
import { createRoot } from "https://esm.sh/react-dom@18/client"
const App = () => {
return (
<div>
<h1>Hello React! ⚛️</h1>
<p>Merry Xmas 🎄</p>
<Button variant="contained">
Hello
</Button>
</div>
)
}
const root = createRoot(document.getElementById("root"))
root.render(<App />)
@thepian It seems to work for me, following https://www.framer.com/developers/guides/using-external-code/: import { Button } from "https://esm.sh/@mui/material?external=react"
export default function Test(props) {
return <Button variant="contained">Hello</Button>
} https://month-induce-864585.framer.app/ Off-topic, it would be good to revamp https://github.com/mui/material-ui/tree/master/examples/cdn, using UMD files feels outdated with today's frontend infrastructure. |
I'm no longer working on a project with MUI or JSPM any more. Maybe @guybedford could elaborate on using JSPM over ESM? |
Note for JSPM support, the exports overrides created by @jollytoad are still running at https://github.com/jspm/overrides/blob/main/overrides.json#L486. They may need updating for the latest material-ui which may be the issue here. |
@guybedford Is there a way JSPM could make the need for an |
@oliviertassinari JSPM is an optimizing CDN - and package optimization involves combining multiple modules into one. When that optimization is done, you want to combine together modules which are private that aren't going to be publicly imported, like |
exports
to the package.jsonexports
to the package.json
Using an export map might play more nicely with Next.js...I just debugged this issue: Basically they seem to have recently added this Webpack alias when static rendering:
But, unfortunately, they also have Next's config defaults seem pretty messed up to me (I remember seeing somewhere someone asked them to reverse to |
Summary 💡
An exports property in the package.json of @material-ui/icons (and other packages), to aid discovery of the officially exported modules.
To support CDNs such as https://jspm.org/
Examples 🌈
Motivation 🔦
I want to consume material-ui via the JSPM CDN, but due to a lack of exports, it has to work out for itself what modules should be exported, and some icons are missing.
The text was updated successfully, but these errors were encountered: