-
-
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
[RFC] Bundle plans #18447
Comments
@eps1lon Thanks for putting together this proposal.
This description might be confusing. Should we say that it compiled for production, to support the latest official features in the ECMAScript version (2019 as we are speaking)?
Will developers take the time to look into this concern? How much time do you think that this effort will take? Does Material-UI need to "lead the way"? I would propose the following We wait to ear more frustration on this matter from our users. As the pain grows, our incentive to prioritize this effort grows. Is it accurate that the developers that are facing this problem today, can solve it with the |
We can't support the latest official features of ES. Any JS will always work in later versions of ES. That's the most important feature of ES. That statement is more confusing than using "source files" as a mental model.
They should, yes. I'm not concerned with developers that do not consider their bundle size. No amount of work we're doing regarding bundle size will interest these developers but they are not the ones building production websites.
As a library we are the ones who should be concerned with these steps not app devs. It's our job to provide an infrastructure that make it easy to do the right thing. Could you explain what you mean by "we wait"? I didn't say that I want to implement this tomorrow. What and how we build these bundles is totally open and I'd like to hear from users. That is why I added the "discussion" label and requested commentes. I want to emphasize again what I wrote in the initial sentence of the "Why?":
See nextjs support, recent chrome dev summit, preset-modules release, default support of parcel of such features etc. |
@eps1lon It's fair. My concern is with "source files" that might suggest we publish the GitHub sources without any transpilation steps, while we do make our source ready to be consumed Maybe we should say that the
Yeah, they will probably note care until they find the UI slow on their latest $3,000 MacBook Pro 😁.
I think that it depends on the resources these developers have, and more specifically, the $ impact a 100ms win can have on the business of these developers. Can it recoup the cost of the software developer that works on it?
Yes! So, my main concern is about having the right timing. I think that these types of improvements are better pioneered by lower-level libraries, like Webpack, React or Next.js. I don't think at Material-UI, at its level, should be too much on the edge nor that we should invest too many resources on early exploration. I would propose that, unless there is a proven solution (already successfully deployed in the OSS world by a noticeable project) that have a good ROI, we stay attentive and wait for this event to happen. Nevertheless, it's great that you stay attentive :)! |
FYI, Create React App (CRA) transpiles I haven't used the |
Current Situation
We ship 3 bundles:
main
entry points to a bundle using CommonJS modules supporting legacy browsers[1]module
entry points to a bundle using ESModules supporting legacy browsers/es
contains the source filesProposal
Ship the following bundles that are coupled to their target environment and not to a generic preset:
As far as I know the current
main
entry isn't all that meaningful since it mixes module concerns with target environment concerns. We don't need to support ie11 with commonJS. If you target IE11 you have to use a bundler anyway since IE11 supports neither CommonJS nor ESModules.Why
The "modules and nomodules" pattern is gaining some traction and by mapping this directly to our bundle it's easier for users to decide which bundle to use.
With this change it's no longer required to transpile our files to get a "modules" bundle (an alias is easier than configuring the babel-loader).
Implementation details
Plenty of unanswered questions. I'd like to put the files next to each other leveraging
.(js|mjs)
extensions (mjs
for esmodules and.js
for commonjs). It's not as important whether bundlers support this (I guess any old bundler supports this one way or another with manual work) but whether they support this by default. The "modules" build would go into a separate folder.For v5 we might flip this default ("modules" by default, "nomodules" in
/legacy
). While I'm not a big fan of it popular bundle size pages are pressuring libraries to use the smallest bundle as the default.Adding this would make more sense after we switched to next 9 and reintroduced page size tracking. This way we can compare the bundles better.
The "nomodules" and "commonjs" bundles are not as important right now. Though I didn't check how a less transpiled bundle would affect ssr. The "nomodules" bundle is basically our
module
entry right now. The "modules" bundle can be shipped in a minor release.9Concerns
What are the drawbacks of publishing that much code to the registry? What services penalize that metric? CodeSandbox is definitely an issue here. We should find out if CSB users download the full package or only the parts needed.
Plan
[ ].node
extension with webpack 2,3,4[ ].node
extension with rollup[ ].node
extension with parcel 1,2/modules
folder in build transpiled with@babel/preset-modules
What about size tracking? A simple markdown table is less usable with this number of entries. A separate app might make sense. The data is available as json
No. They point to a specific version and SemVer has no ability to communicate different variants for versions
notes
[1] legacy browsers
ie 11
edge 14
firefox 52
chrome 49
safari 10
node 8
-- https://material-ui.com/getting-started/supported-platforms/#browser
Updates
.node
. Node will use.js
files while the "modules" build uses.mjs
. "nomodules" will go into/legacy
The text was updated successfully, but these errors were encountered: