Skip to content

Commit 92ee74e

Browse files
authored
Perf improvements to react dev experience (#9825)
* Perf improvements to react dev experience * More changes * Comments For #9791 PR #9804 resulted in a very poor dev experience. This addresses that issue.
1 parent a8e9982 commit 92ee74e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

build/webpack/webpack.datascience-ui.config.builder.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function getEntry(isNotebook) {
3636

3737
function getPlugins(isNotebook) {
3838
const plugins = [];
39-
plugins.push(...common.getDefaultPlugins(isNotebook ? 'notebook' : 'viewers'));
39+
if (isProdBuild) {
40+
plugins.push(...common.getDefaultPlugins(isNotebook ? 'notebook' : 'viewers'));
41+
}
4042

4143
if (isNotebook) {
4244
plugins.push(
@@ -57,13 +59,15 @@ function getPlugins(isNotebook) {
5759
})
5860
);
5961
} else {
62+
const definePlugin = new webpack.DefinePlugin({
63+
'process.env': {
64+
NODE_ENV: JSON.stringify('production')
65+
}
66+
});
67+
6068
plugins.push(
69+
...(isProdBuild ? [definePlugin] : []),
6170
...[
62-
new webpack.DefinePlugin({
63-
'process.env': {
64-
NODE_ENV: JSON.stringify('production')
65-
}
66-
}),
6771
new HtmlWebpackPlugin({
6872
template: 'src/datascience-ui/plot/index.html',
6973
indexUrl: `${constants.ExtensionRootDir}/out/1`,
@@ -84,7 +88,9 @@ function getPlugins(isNotebook) {
8488
}
8589

8690
function buildConfiguration(isNotebook) {
91+
// Folder inside `datascience-ui` that will be created and where the files will be dumped.
8792
const bundleFolder = isNotebook ? 'notebook' : 'viewers';
93+
8894
return {
8995
context: constants.ExtensionRootDir,
9096
entry: getEntry(isNotebook),
@@ -96,8 +102,9 @@ function buildConfiguration(isNotebook) {
96102
mode: 'development', // Leave as is, we'll need to see stack traces when there are errors.
97103
devtool: 'source-map',
98104
optimization: {
99-
minimize: true,
100-
minimizer: [new TerserPlugin({ sourceMap: true })],
105+
minimize: isProdBuild,
106+
minimizer: isProdBuild ? [new TerserPlugin({ sourceMap: true })] : [],
107+
moduleIds: 'hashed', // (doesn't re-generate bundles unnecessarily) https://webpack.js.org/configuration/optimization/#optimizationmoduleids.
101108
splitChunks: {
102109
chunks: 'all',
103110
cacheGroups: {

0 commit comments

Comments
 (0)