Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read coreApp assets directly from package #144492

Merged

Conversation

TinaHeiligers
Copy link
Contributor

@TinaHeiligers TinaHeiligers commented Nov 2, 2022

Handles the follow-up work from #144075
Part of #134112

In #144075, we had to leave duplicates of the assets declared in coreApp within src/core/server/core_app because these assets were imported or referenced directly elsewhere.

This PR removes these duplicates and exposes the assets directly from the package.

References updated:

  • canvas shareable_runtime

The changes involved:

  • moving the assets folder out of the package src folder with corresponding updates to the Bazel build file
  • updating the references to these assets, and
  • changes to dev build scripts, including moving the ReplaceFavicon build task to after empty directories are created (thanks @mistic!).

@TinaHeiligers TinaHeiligers added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Nov 2, 2022
Comment on lines +34 to 44
ASSETS = glob(["assets/**/*"])

filegroup(
name = "assets",
srcs = ASSETS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
":assets"
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what does that do exactly?

But I think I spotted the problem:

This PR moved the assets from {package}/src/assets to {package}/assets. However you did not change the path in the route registered to serve them:

private registerStaticDirs(core: InternalCoreSetup | InternalCorePreboot) {
core.http.registerStaticDir('/ui/{path*}', Path.resolve(__dirname, './assets'));

Changing the Path.resolve(__dirname, './assets') to target the correct folder should hopefully do the trick.

core.http.registerStaticDir('/ui/{path*}', Path.resolve(__dirname, './assets'));
core.http.registerStaticDir(
'/ui/{path*}',
fromRoot('node_modules/@kbn/core-apps-server-internal/assets')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to load these assets from their location post-build.

await run(Tasks.CreateEmptyDirsAndFiles);
await run(Tasks.CreateReadme);
await run(Tasks.BuildBazelPackages);
await run(Tasks.ReplaceFavicon);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build process expects an empty directory into which to replace the distributable versions of favicons with their source. At least, that's how I understand the flow here.

@@ -33,7 +33,6 @@ export const CopySource: Task = {
'!src/**/mocks.{js,ts}',
'!src/cli*/dev.js',
'!src/plugins/telemetry/schema/**',
'!src/core/server/core_app/assets/favicons/favicon.distribution.{ico,png,svg}',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files moved and the path doesn't exist anymore.

@@ -6,7 +6,7 @@
*/

export * from './api';
import '@kbn/core/server/core_app/assets/legacy_light_theme.css';
import '@kbn/core-apps-server-internal/assets/legacy_light_theme.css';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates path to assets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind if we add the ci:build-canvas-shareable-runtime label to test this?

Copy link
Contributor Author

@TinaHeiligers TinaHeiligers Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind. I've added the label, and kicked off another run.
@jbudz FMI, what does that label setup and run given that the label needs to be added explicitly? The only reference I can find is here and I'm interpreting that to mean we don't build the canvas shareable runtime by default. Is that correct?

Copy link
Contributor Author

@TinaHeiligers TinaHeiligers Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbudz after adding the flag, the ci run fails on "canvas shareable runtime" for "total size" is 192390 over the configured limit of 8200000". commit:9471f5c
The only thing this PR does in the canvas shareable_runtime module is to update the location from which the legacy_light_theme stylesheet is read.
From what I can see, the theme itself is 100Kb and the minimized version is sitting at 79Kb, and don't appear to have changed in size from what's in main right now.

Is there anything I need to do here? Should we be updating the limit?

Copy link
Member

@jbudz jbudz Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The runtime isn't built in PR's anymore by default because it adds 3-4 minutes to build times and doesn't have any tests. The webpack config doesn't change too often so we were okay with the tradeoff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limit looks like it's something for ops to triage, that's about expected.

@TinaHeiligers TinaHeiligers marked this pull request as ready for review November 3, 2022 18:16
@TinaHeiligers TinaHeiligers requested review from a team as code owners November 3, 2022 18:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code only review - import change LGTM 👍

@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 58 64 +6
osquery 108 113 +5
securitySolution 440 446 +6
total +19

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 66 72 +6
osquery 109 115 +6
securitySolution 517 523 +6
total +20

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TinaHeiligers TinaHeiligers merged commit b5ee95d into elastic:main Nov 4, 2022
@TinaHeiligers TinaHeiligers deleted the kbn-read-core-app-assets-from-package branch November 4, 2022 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants