Skip to content

Commit c57271d

Browse files
authored
Fix/remounting (codesandbox#577)
* Enable our old emmet mechanism as well * Find culprit of full remount on work * Fix remounting routes * Clean up diff * Fix route changes * Fix loading other sandboxes * Move load statement
1 parent 7650b58 commit c57271d

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"build": "yarn build:dependents && yarn build:prod",
88
"build:prod": "lerna run build --scope app --scope homepage --parallel && gulp",
99
"build:dependents": "lerna run build --ignore app --ignore homepage --parallel",
10-
"start": "lerna run start --parallel",
10+
"start": "lerna run build --scope codesandbox-browserfs --stream && lerna run start --parallel",
11+
"start:fast": "lerna run start --scope app --stream",
1112
"start:test": "lerna run start:test --scope app --stream",
1213
"start:dev_api": "lerna run start --parallel --ignore app & lerna run start:dev_api --scope app --stream",
1314
"test": "lerna run test --ignore codesandbox-browserfs",

packages/app/config/webpack.common.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const ESLINT_PLUGIN_VUE_INDEX = `module.exports = {
2525
.filter(filename => path.extname(filename) === '.js')
2626
.map(filename => {
2727
const ruleId = path.basename(filename, '.js');
28-
return ` "${ruleId}": require("eslint-plugin-vue/lib/rules/${
29-
filename
30-
}"),`;
28+
return ` "${ruleId}": require("eslint-plugin-vue/lib/rules/${filename}"),`;
3129
})
3230
.join('\n')}
3331
},
@@ -147,6 +145,15 @@ module.exports = {
147145
flags: 'g',
148146
},
149147
},
148+
// Remove dynamic require in jest circus
149+
{
150+
test: /format_node_assert_errors\.js/,
151+
loader: 'string-replace-loader',
152+
options: {
153+
search: `assert = require.call(null, 'assert');`,
154+
replace: `throw new Error('module assert not found')`,
155+
},
156+
},
150157
// JSON is not enabled by default in Webpack but both Node and Browserify
151158
// allow it implicitly so we also enable it.
152159
{

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class Project extends React.Component {
220220
<PropertyName>Forked From</PropertyName>
221221
<PropertyValue>
222222
<ConfirmLink
223-
enabled={store.editor.isAllModulesSynced}
223+
enabled={!store.editor.isAllModulesSynced}
224224
message="You have unsaved changes. Are you sure you want to navigate away?"
225225
to={sandboxUrl(sandbox.forkedFromSandbox)}
226226
>

packages/app/src/app/pages/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as React from 'react';
33
import { inject, observer } from 'mobx-react';
44
import Loadable from 'react-loadable';
5-
import { Route, Switch, Redirect, withRouter } from 'react-router-dom';
5+
import { Route, Switch, Redirect } from 'react-router-dom';
66

77
import _debug from 'app/utils/debug';
88
import Notifications from 'app/pages/common/Notifications';
@@ -68,6 +68,12 @@ class Routes extends React.Component<Props> {
6868
this.props.signals.appUnmounted();
6969
}
7070

71+
shouldComponentUpdate() {
72+
// Without this the app won't update on route changes, we've tried using
73+
// `withRouter`, but it caused the app to remount on every route change.
74+
return true;
75+
}
76+
7177
render() {
7278
return (
7379
<Container>
@@ -110,4 +116,4 @@ class Routes extends React.Component<Props> {
110116
}
111117
}
112118

113-
export default inject('signals', 'store')(withRouter(observer(Routes)));
119+
export default inject('signals', 'store')(observer(Routes));

0 commit comments

Comments
 (0)