-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[docs] Remove old workarounds #20587
[docs] Remove old workarounds #20587
Conversation
Details of bundle changes.Comparing: fe687bf...b83ebae Details of page changes
|
Having a quick look at the JavaScript runtime, I would expect at least a 10% reduction of the runtime by sharing the HTML output of prism between the client and server side :) |
} | ||
|
||
// Reuse store on the client-side | ||
if (!global.__INIT_REDUX_STORE__) { |
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.
Note for context.
The incentive for the global was to account for cases where Next.js doesn't bundle redux into the share JavaScript bundle. In the past, I had multiple cases where we would get a new instance of redux per page. I don't know if it's still a concern today.
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.
How would we get multiple instances? There's only a single store.
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.
Basically, Next.js/webpack would fail to identify Redux as a module that needs to be put into the shared bundle. In some cases, we had:
- shared_bundle.js
- page_a.js contains
docs/src/modules/redux/initRedux.js
- page_b.js contains
docs/src/modules/redux/initRedux.js
(duplicate)
the JavaScript reference doesn't match, we end-up with two Redux store loading when transitioning from page a to page b, page b has no prior knowledge of the store of page a.
I imagine it can be reproduced in dev mode, where we only build one page at the time.
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.
Even if this were the case: What is the problem? These are pure functions (ignoring devtools). We can call them how often we want.
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.
And again: Every page could have its own module. We would still use the same store across pages since AppWrapper stays mounted.
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.
It was causing an issue with the states that aren't persisted. For instance, if we store the dark theme into redux or the color of the page, we would lose it with the first page transition.
As long as we don't notice a behavior in this order, I think it's safe to move forward.
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.
To illustrate: You're seeing the flamegraph of the commit after we navigated from / to /components/box. "ne" is the AppWrapper component that got updated. It didn't "render for the first time" i.e. mount. What mounted was the page (the big yellow bar):
The store wasn't re-created. That only happens when AppWrapper mounts which happens once.
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.
👌
b858c59
to
e262548
Compare
@@ -23,9 +24,6 @@ function create(initialState) { | |||
// redux-logger needs this feature | |||
Object.hasOwnProperty('assign') | |||
) { | |||
// eslint-disable-next-line global-require | |||
const createLogger = require('redux-logger').createLogger; |
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.
Webpack is clever enough to remove redux-logger
from prod bundles (at least the bundle size didn't show that so it's either bundled anyway or working as expected). One less global require :)
Should get this in regardless of the "markdown at build time" effort in case "markdown at build time" needs to be reverted later. |
Nice, let's try it out :) |
Removes some older workarounds that are no longer needed and make the code needlessly complicate in their current state.
markdownLocation
prop (it seems to be unused)