[code-infra] Babel plugin to fully resolve imported paths#43294
Merged
[code-infra] Babel plugin to fully resolve imported paths#43294
Conversation
Netlify deploy previewhttps://deploy-preview-43294--material-ui.netlify.app/ Bundle size report |
This was referenced Aug 16, 2024
Member
Author
|
Have been testing this locally from csbci published packages and can't seem to break it |
Member
|
The implementation looks good, but could you place the plugin somewhere we can package and distribute with npm (internal-scripts, perhaps)? |
Member
Author
|
Done. Added a edit: added it to csbci as well |
2 tasks
michaldudak
approved these changes
Aug 22, 2024
| @@ -0,0 +1,30 @@ | |||
| { | |||
| "name": "@mui/internal-babel-plugin-resolve-imports", | |||
| "version": "1.0.16", | |||
Member
There was a problem hiding this comment.
That's unusual initial version ;)
Member
Author
There was a problem hiding this comment.
😄 I copied the package.json of @mui/internal-scripts and didn't give it any further thought.
This was referenced Sep 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:libto 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.