-
-
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
[code-infra] Babel plugin to fully resolve imported paths #43294
Conversation
Netlify deploy previewhttps://deploy-preview-43294--material-ui.netlify.app/ Bundle size report |
Have been testing this locally from csbci published packages and can't seem to break it |
The implementation looks good, but could you place the plugin somewhere we can package and distribute with npm (internal-scripts, perhaps)? |
Done. Added a edit: added it to csbci as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -0,0 +1,30 @@ | |||
{ | |||
"name": "@mui/internal-babel-plugin-resolve-imports", | |||
"version": "1.0.16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unusual initial version ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 I copied the package.json
of @mui/internal-scripts
and didn't give it any further thought.
Working on #43264 I found that we can make rollup work quite well for us to resolve modules, except that they inline interop helpers that we can't seem to dedupe the way we can in babel.
This PR solves the problem differently with a custom babel plugin that can resolve module imports to their actual emitted file.
This PR changes imports in the build output from
to
It resolves those imports to the full filename with extension.
See https://nodejs.org/docs/v20.16.0/api/esm.html#mandatory-file-extensions
This doesn't update imports for the icons package, as these modules are pre-baked in the repository. We can run
pnpm --filter @mui/icons-material build:lib
to update the icons as part of this PR or separately.I'm also adding some type checking to the babel.config.js
Corresponding PR on X
Noticed this problem while testing out the changes.