Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d7dec7d

Browse files
committed
feat: make dynamic import disabling more clear
1 parent 3b55983 commit d7dec7d

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

‎common/js/pages/Todos/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Loadable from 'react-loadable';
33
import { Loading } from 'components/common';
44
import { fetchTodos } from 'actions/todos';
55

6+
// NOTE: To turn off dynamic imports, import this container normally using:
7+
// import TodosContainer from 'containers/Todos';
68
const TodosContainer = Loadable({
79
loader: () => import('../../containers/Todos'),
810
loading: Loading

‎server/renderer/handler.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ export default function handleRender(req, res) {
103103
</Provider>
104104
);
105105

106-
if (!config.enableDynamicImports) {
107-
return component;
106+
if (config.enableDynamicImports) {
107+
return (
108+
<Loadable.Capture report={moduleName => modules.push(moduleName)}>
109+
{component}
110+
</Loadable.Capture>
111+
);
108112
}
109113

110-
return (
111-
<Loadable.Capture report={moduleName => modules.push(moduleName)}>
112-
{component}
113-
</Loadable.Capture>
114-
);
114+
return component;
115115
};
116116

117117
// Execute the render only after all promises have been resolved.

‎webpack/development.hot.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const entry = [
1818

1919
// Additional plugins
2020
let plugins = [
21+
...baseConfig.plugins,
2122
new webpack.HotModuleReplacementPlugin(),
2223
new webpack.NoEmitOnErrorsPlugin(),
2324
new webpack.NamedModulesPlugin()
@@ -31,9 +32,6 @@ if (!config.enableDynamicImports) {
3132
}));
3233
}
3334

34-
// Additional loaders
35-
const loaders = [];
36-
3735
const webpackConfig = {
3836
...baseConfig,
3937
devtool: 'eval',
@@ -44,18 +42,7 @@ const webpackConfig = {
4442
...baseConfig.entry.app
4543
]
4644
},
47-
plugins: [
48-
// don't use the first plugin (isomorphic plugin)
49-
...baseConfig.plugins,
50-
...plugins
51-
],
52-
module: {
53-
...baseConfig.module,
54-
rules: [
55-
...baseConfig.module.rules,
56-
...loaders
57-
]
58-
}
45+
plugins
5946
};
6047

6148
console.info('Firing up Webpack dev server...\n');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /