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

Fix: resolve performance issue due to webpack stats #1391

Merged
merged 5 commits into from
Jul 31, 2023

Conversation

joeluong-sfcc
Copy link
Collaborator

Description

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • (change1)

How to Test-Drive This PR

  • (step1)

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@joeluong-sfcc joeluong-sfcc requested a review from a team as a code owner July 31, 2023 17:18
@@ -357,7 +357,7 @@ export const DevServerMixin = {
_getWebpackAsset(req, compilerName, fileName) {
if (req.app.__webpackReady()) {
const outputFileSystem = req.app.__devMiddleware.context.outputFileSystem
const jsonWebpackStats = req.app.__devMiddleware.context.stats.toJson()
const jsonWebpackStats = req.app.__devMiddleware.context.stats.toJson({preset: 'none', outputPath: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this change do? How does it impact people who aren't seeing excessive slowdowns? Is there anything we can test for to validate these changes work as expected? (Not blocking, just questions.)

Copy link
Contributor

Choose a reason for hiding this comment

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

@wjhsf what stats.toJson does is essentially getting the stats data in JSON format, and you have the option to selectively query the piece of data you want/need. If we don't pass in the option, by default, you'll get all of the data. Depending on the project, you may get a lot of data.

And so the conversion process to JSON may run slowly if there's a lot of data to generate.

In our function, we only need 1 piece of data outputPath. Hence, we now pass in the option {preset: 'none', outputPath: true}:

  1. start off with none which is no data at all
  2. and then add the outputPath

That option will not affect people who are not seeing the slowdowns. But will be beneficial to projects who have huge stats data.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious about the performance gain for this change for the OOTB retail react app. How much time are we saving in ballpark?

Copy link
Collaborator

Choose a reason for hiding this comment

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

btw, it would be nice to add a comment to explain the "why"

Copy link
Contributor

@vmarta vmarta left a comment

Choose a reason for hiding this comment

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

How about incrementing the patch version in this PR too? Although we can do that separately, I think this time we can do them altogether.

(NOTE: preview version of the patch first)

@joeluong-sfcc
Copy link
Collaborator Author

joeluong-sfcc commented Jul 31, 2023

How about incrementing the patch version in this PR too? Although we can do that separately, I think this time we can do them altogether.

(NOTE: preview version of the patch first)

@vmarta We're planning to do a preview patch release, and once the customer confirms that this issue has been resolved, we can do a full patch release. If I understand correctly, this PR will need to be merged in first and we'll have a separate PR for version bump

EDIT: re-read your comment, going to bump version in this PR

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.

None yet

5 participants