-
Notifications
You must be signed in to change notification settings - Fork 31
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
NO_JIRA: Extract and optimise JS Loaders #178
Conversation
xalechez
commented
Nov 14, 2023
•
edited
Loading
edited
- Extracted loaders that are identical for CSR and SSR
- Removed the second round of babel-loader
- Made TS Checker optional for react-scripts build
- Made Backpack regexes optional for styles
d1741f2
to
2ea7648
Compare
const paths = require('../config/paths'); | ||
const appPackageJson = require(paths.appPackageJson); | ||
const bpkReactScriptsConfig = appPackageJson['backpack-react-scripts'] || {}; | ||
const cssModulesEnabled = bpkReactScriptsConfig.cssModules !== false; | ||
const noBackpackStylePrefixes = | ||
bpkReactScriptsConfig.danger_noBackpackStylePrefixes !== false; |
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.
Early tests show that we can live without these. Now I'd like to do more tests under this flag
const skipProductionTypeCheck = | ||
bpkReactScriptsConfig.skipProductionTypeCheck || false; | ||
|
||
const useTsChecker = ( |
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.
Skipping TS Checker plugin results in around 20-30% build time reduction as early tests show. tsc can do the same job better and faster. I've made a new flag that is totally opt-in for consumers and keep type checking during development
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.
Used this plugin to measure loaders and plugins speed
@@ -0,0 +1,69 @@ | |||
'use strict'; |
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.
This code is identical in two configs. Extracting helps to avoid undesired mismatch
@@ -0,0 +1,103 @@ | |||
'use strict'; |
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.
This code is identical in two configs. Extracting helps to avoid undesired mismatch
return [ | ||
// Process application JS with Babel. | ||
// The preset includes JSX, Flow, TypeScript, and some ESnext features. | ||
{ |
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've removed the second round of Babel which was unnecessary
require('../backpack-addons/amdExcludes'), // #backpack-addons amdExcludes | ||
// "url" loader works like "file" loader except that it embeds assets | ||
// smaller than specified limit in bytes as data URLs to avoid requests. | ||
// A missing `test` is equivalent to a match. | ||
{ |
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.
This code was extracted
loader: require.resolve('@svgr/webpack'), | ||
options: { | ||
prettier: false, | ||
svgoConfig: { |
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.
Addressed comments from #177