Skip to content
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

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Conversation

xalechez
Copy link

@xalechez xalechez commented Nov 14, 2023

  • 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

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;
Copy link
Author

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 = (
Copy link
Author

@xalechez xalechez Nov 15, 2023

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

Copy link
Author

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';
Copy link
Author

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';
Copy link
Author

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.
{
Copy link
Author

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.
{
Copy link
Author

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: {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments from #177

@xalechez xalechez merged commit 6802d89 into fork_cra5 Nov 15, 2023
2 checks passed
@xalechez xalechez deleted the extract-js-loaders branch November 30, 2023 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants