Skip to content

Commit

Permalink
Add core-only bundle loading strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Apr 7, 2020
1 parent 802322b commit 3f17e0a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/legacy/ui/ui_bundles/ui_bundles_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ export class UiBundlesController {
this._postLoaders = [];
this._bundles = [];

// create a bundle for core-only with no modules
this.add({
id: 'core',
modules: [],
template: appEntryTemplate,
});

// create a bundle for each uiApp
for (const uiApp of uiApps) {
this.add({
Expand Down
23 changes: 23 additions & 0 deletions src/legacy/ui/ui_render/bootstrap/template.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
});
}

if ('{{appId}}' === 'core') {
return load({
deps: [
{{#each sharedJsDepFilenames}}
'{{../regularBundlePath}}/kbn-ui-shared-deps/{{this}}',
{{/each}}
],
urls: [
{
deps: [
'{{regularBundlePath}}/kbn-ui-shared-deps/{{sharedJsFilename}}',
],
urls: [
'{{regularBundlePath}}/core/core.plugin.js',
{{#each styleSheetPaths}}
'{{this}}',
{{/each}}
]
}
]
});
}

load({
deps: [
{{#each sharedJsDepFilenames}}
Expand Down
8 changes: 7 additions & 1 deletion src/optimize/bundles_route/bundles_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { isAbsolute, extname } from 'path';
import { isAbsolute, extname, resolve, join } from 'path';
import LruCache from 'lru-cache';
import * as UiSharedDeps from '@kbn/ui-shared-deps';
import { createDynamicAssetResponse } from './dynamic_asset_response';
Expand Down Expand Up @@ -85,6 +85,12 @@ export function createBundlesRoute({
fileHashCache
)
),
buildRouteForBundles(
`${basePublicPath}/bundles/core/`,
`/bundles/core/`,
resolve(__dirname, join('..', '..', 'core', 'public', 'target', 'public')),
fileHashCache
),
buildRouteForBundles(
`${basePublicPath}/bundles/`,
'/bundles/',
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/graph/public/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
import '../../../../webpackShims/ace';
// required for i18nIdDirective
import 'angular-sanitize';
// required for ngRoute
import 'angular-route';
// type imports
import {
AppMountContext,
Expand Down

0 comments on commit 3f17e0a

Please sign in to comment.