Typescript pulling all MUI files - super slow compilation
See original GitHub issue- This is a v1.x issue (v0.x is no longer maintained).
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
TSC should compile in about 3-8 seconds.
Current Behavior
TSC takes over 1 minute to compile, because it’s pulling the entire library, with over half a million types.
running tsc --extendedDiagnostics --listFiles --noEmit
and it goes on…
If I remove the MUI folder (resulting in lots of errors of course)
Context
I’m only using 10 components in the entire app, all imported like this:
import CircularProgress from '@material-ui/core/CircularProgress/CircularProgress';
It should only import the relevant files and types.
My tsconfig:
{
"compilerOptions": {
"baseUrl": "./src",
"outDir": "build/dist",
"target": "es5",
"lib": ["es6", "es7", "dom"],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"rootDir": "./src",
"noEmitOnError": false,
"isolatedModules": true,
"strictPropertyInitialization": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noErrorTruncation": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"diagnostics": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true
},
"include": [
"src/**/*"
],
"exclude": [
"dist",
"build",
"node_modules",
"src/**/__tests__"
],
"defaultSeverity": "warning"
}
My @types folder:
Any ideas why this happens?
Thank you for your help!!!
Your Environment
Tech | Version |
---|---|
Material-UI | v1.2.2 |
React | latest |
browser | |
etc |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Typescript pulling all MUI files - super slow compilation #11916
I'm only using 10 components in the entire app, all imported like this: import CircularProgress from '@material-ui/core/CircularProgress/ ...
Read more >Typescript compiling very slowly - Stack Overflow
I was wondering if splitting the index.d.ts file into smaller files would help? It would be really helpful is someone could please provide...
Read more >Minimizing bundle size - Material UI - MUI
Size snapshots are taken on every commit for every package and critical parts of ... we can inspect detailed bundle size changes on...
Read more >Build strongly typed polymorphic components with React and ...
In this detailed (and explanatory) guide, I'll discuss how to build strongly typed polymorphic React components with TypeScript.
Read more >Build is extremely slow at the end - Netlify Support Forums
My guess is that pulling many small files in parallel is just somehow faster than pulling one monolith of a cache. Our cache...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@manpreetnarang instead of
Do this:
@Pajn Actually while we definitely do (did? we should be publishing a fix on nightlies tonight) have a perf problem, there’s an issue in MUI that is causing us to do more work than we should need to for a given deep import, too (which is why the file count goes up so much with a single component import)! Specifically, you have imports like this one:
That import references the root
index.d.ts
- your rootindex.d.ts
imports all components (to reexport them), causing us to load every type definition in MUI (we won’t typecheck them unless requested, but we will load them all from disk and parse them, which has a cost). If you moved your utilitity types likeStandardProps
into a separate file from the rootindex.d.ts
and did a direct import of them, it would cut down on the fileset loaded for a given component fairly significantly.