summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-02-01 17:23:03 -0600
committerMike Greiling <mike@pixelcog.com>2018-02-01 20:50:16 -0600
commit8ebe2f7ae6872ff8553fb0f3482df209270c874b (patch)
tree252552d7e3596b2da40bb3ce645ce6d542ad761d
parentdd75c337e5ee036fca8188d5b7adbf6e7725570f (diff)
downloadgitlab-ce-8ebe2f7ae6872ff8553fb0f3482df209270c874b.tar.gz
prevent dynamic chunks from being duplicated by the dispatcher until it is completely refactored
-rw-r--r--app/assets/javascripts/dispatcher.js6
-rw-r--r--config/webpack.config.js15
2 files changed, 16 insertions, 5 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index 262ed3783fb..5cd66f7f544 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -56,7 +56,7 @@ import SearchAutocomplete from './search_autocomplete';
break;
case 'projects:boards:show':
case 'projects:boards:index':
- import('./pages/projects/boards/index')
+ import('./pages/projects/boards')
.then(callDefault)
.catch(fail);
shortcut_handler = true;
@@ -363,7 +363,7 @@ import SearchAutocomplete from './search_autocomplete';
.catch(fail);
break;
case 'projects:project_members:index':
- import('./pages/projects/project_members/')
+ import('./pages/projects/project_members')
.then(callDefault)
.catch(fail);
break;
@@ -605,7 +605,7 @@ import SearchAutocomplete from './search_autocomplete';
}
break;
case 'profiles':
- import('./pages/profiles/index/')
+ import('./pages/profiles/index')
.then(callDefault)
.catch(fail);
break;
diff --git a/config/webpack.config.js b/config/webpack.config.js
index ed064be690c..7f3fe551a03 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -25,11 +25,22 @@ var NO_COMPRESSION = process.env.NO_COMPRESSION;
var autoEntries = {};
var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') });
+// filter out entries currently imported dynamically in dispatcher.js
+var dispatcher = fs.readFileSync(path.join(ROOT_PATH, 'app/assets/javascripts/dispatcher.js')).toString();
+var dispatcherChunks = dispatcher.match(/(?!import\('.\/)pages\/[^']+/g);
+
pageEntries.forEach(( path ) => {
- let chunkName = path.replace(/\/index\.js$/, '').replace(/\//g, '.');
- autoEntries[chunkName] = './' + path;
+ let chunkPath = path.replace(/\/index\.js$/, '');
+ if (!dispatcherChunks.includes(chunkPath)) {
+ let chunkName = chunkPath.replace(/\//g, '.');
+ autoEntries[chunkName] = './' + path;
+ }
});
+// report our auto-generated bundle count
+var autoEntriesCount = Object.keys(autoEntries).length;
+console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`);
+
var config = {
// because sqljs requires fs.
node: {