prevent dynamic chunks from being duplicated by the dispatcher until it is completely refactored

This commit is contained in:
Mike Greiling 2018-02-01 17:23:03 -06:00
parent dd75c337e5
commit 8ebe2f7ae6
No known key found for this signature in database
GPG Key ID: 0303DF507FA67596
2 changed files with 16 additions and 5 deletions

View File

@ -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;

View File

@ -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: {