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(v2): fix hot reload sometimes not working due to altered modules #1370

Merged
merged 1 commit into from
Apr 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/docusaurus/lib/client/exports/ComponentCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import registry from '@generated/registry';

function ComponentCreator(path) {
const modules = routesAsyncModules[path];
const originalModules = modules;
const optsModules = [];
const optsWebpack = [];
const mappedModules = {};
Expand Down Expand Up @@ -63,8 +62,8 @@ function ComponentCreator(path) {
modules: optsModules,
webpack: () => optsWebpack,
render: (loaded, props) => {
// Transform back loaded modules back into the original structure.
const loadedModules = originalModules;
// clone the original object since we don't want to alter the original.
const loadedModules = JSON.parse(JSON.stringify(modules));
Copy link
Contributor

@yangshun yangshun Apr 18, 2019

Choose a reason for hiding this comment

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

Interesting. I thought I was using _.cloneDeep here. If we import just the function it's fine:

import cloneDeep from 'lodash/cloneDeep`; // It's ok, just cloneDeep is imported
// vs
import _ from 'lodash`; // Not ok, the entire lodash is imported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sry I removed it before because bundle size is still very big. Few KBs saved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Object.keys(loaded).forEach(key => {
let val = loadedModules;
const keyPath = key.split('.');
Expand Down