Commit 911869f9 authored by Clement Ho's avatar Clement Ho Committed by Jacob Schatz

Webpack auto include for EE imports

parent 3f38fb7a
......@@ -62,11 +62,6 @@ var Dispatcher;
case 'projects:blame:show':
shortcut_handler = true;
break;
case 'projects:edit':
import(/* webpackChunkName: "ee_projects_edit" */ 'ee/pages/projects/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:tree:show':
import(/* webpackChunkName: "ee_projects_edit" */ 'ee/pages/projects/tree/show')
.then(callDefault)
......
......@@ -29,13 +29,19 @@ var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ap
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 chunkPath = path.replace(/\/index\.js$/, '');
if (!dispatcherChunks.includes('./' + chunkPath)) {
let chunkName = chunkPath.replace(/\//g, '.');
autoEntries[chunkName] = './' + path;
function generateAutoEntries(path, prefix = '.') {
const chunkPath = path.replace(/\/index\.js$/, '');
if (!dispatcherChunks.includes(`${prefix}/${chunkPath}`)) {
const chunkName = chunkPath.replace(/\//g, '.');
autoEntries[chunkName] = `${prefix}/${path}`;
}
});
}
pageEntries.forEach(( path ) => generateAutoEntries(path));
// add and replace any ce entries with ee entries
const eePageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'ee/app/assets/javascripts') });
eePageEntries.forEach(( path ) => generateAutoEntries(path, 'ee'));
// report our auto-generated bundle count
var autoEntriesCount = Object.keys(autoEntries).length;
......
import '~/pages/projects/blame/show/index';
import initBlob from '../../shared/init_blob';
export default () => initBlob();
import '~/pages/projects/blob/show/index';
import initBlob from '../../shared/init_blob';
export default () => initBlob();
export default initBlob;
......@@ -5,11 +5,11 @@ import UserCallout from '~/user_callout';
import groupsSelect from '~/groups_select';
import ApproversSelect from 'ee/approvers_select';
export default () => {
document.addEventListener('DOMContentLoaded', () => {
new UsersSelect();
groupsSelect();
new UserCallout({ className: 'js-service-desk-callout' });
new UserCallout({ className: 'js-mr-approval-callout' });
new ApproversSelect();
};
});
import '~/pages/projects/merge_requests/creations/new/index';
import UserCallout from '~/user_callout';
import initForm from '../../shared/init_form';
......
import '~/pages/projects/merge_requests/edit/index';
import initForm from '../shared/init_form';
export default () => initForm();
import '~/pages/projects/milestones/show/index';
import UserCallout from '~/user_callout';
export default () => new UserCallout();
import '~/pages/projects/settings/repository/show/index';
import UsersSelect from '~/users_select';
import UserCallout from '~/user_callout';
......
import '~/pages/projects/show/index';
import initGeoInfoModal from '../../../init_geo_info_modal';
export default () => initGeoInfoModal();
import '~/pages/search/show/index';
import UserCallout from '~/user_callout';
export default () => new UserCallout();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment