-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
explore perf issues using
whyDidYouRender
- Loading branch information
1 parent
6148443
commit c638315
Showing
9 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": ["next/babel","next/core-web-vitals"] | ||
} |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const path = require('path'); | ||
|
||
/** @typedef {Parameters<import('next').NextConfig['webpack']>[1]} WebpackConfigContext */ | ||
|
||
const injectionSource = path.join(__dirname, 'injection.ts'); | ||
|
||
/** | ||
* @param {import('webpack').Configuration} config | ||
* @param {WebpackConfigContext} context | ||
*/ | ||
module.exports = (config, context) => { | ||
// check if in dev or production first. only run in dev! | ||
if (process.env.NODE_ENV === 'development') { | ||
const originalEntry = config.entry; | ||
|
||
config.entry = async () => { | ||
const entries = await originalEntry(); | ||
|
||
if (entries['main-app'] && !entries['main-app'].includes(injectionSource)) { | ||
entries['main-app'].unshift(injectionSource); | ||
} | ||
return entries; | ||
}; | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
import whyDidYouRender from '@welldone-software/why-did-you-render'; | ||
|
||
// eslint-disable-next-line no-console -- Show information that `whyDidYouRender` has been applied to the website. | ||
console.debug('Applying whyDidYouRender, to help you locate unnecessary re-renders during development. See https://github.com/welldone-software/why-did-you-render'); | ||
|
||
// See https://github.com/welldone-software/why-did-you-render#options | ||
whyDidYouRender(React, { | ||
trackAllPureComponents: true, | ||
trackHooks: true, | ||
logOwnerReasons: true, | ||
collapseGroups: true, | ||
include: [/./], | ||
|
||
// This is for testing, remove it, if you don't want to log on different values | ||
logOnDifferentValues: true | ||
}); |
This file contains 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