build immutable bundles for new platform plugins#53976
build immutable bundles for new platform plugins#53976spalger merged 134 commits intoelastic:masterfrom
Conversation
374f3b1 to
0dc7d68
Compare
dd74deb to
7c5be03
Compare
joshdover
left a comment
There was a problem hiding this comment.
LGTM - thanks for refactoring this for readability.
I haven't reviewed all 12,000 lines 😬 but I don't have any fundamental issues with how it works and I'm able to follow along. This is going to lay a great foundation for even further improvements going forward!
tylersmalley
left a comment
There was a problem hiding this comment.
LGTM - looking forward to this shaving more off the production builds as plugins move over to the new platform. As of right now, this is reducing our HTTP assets on load from 134 to 128 (still crazy high).
Development looks good as well.
One thing which needs a follow-up is that the building of 3rd party plugins was removed in #55281 (comment) so could not be tested as part of this PR.
|
7.x/7.7: 9f94c39 |
💔 Build FailedTest FailuresKibana Pipeline / kibana-intake-agent / Jest Integration Tests.packages/kbn-plugin-generator/integration_tests.running the plugin-generator via 'node scripts/generate_plugin.js plugin-name' with default config then running with es instance 'yarn start' should result in the spec plugin being initialized on kibana's stdoutStandard OutStack TraceHistory
To update your PR or re-run it, just comment with: |
Creates a decoupled optimizer that can build new platform plugins so that they can be distributed as static assets, created at build time, loaded independently in the browser, and never rebuilt in the distributable. See the
@kbn/optimizerreadme for some more details on the new optimizer.styles
.scssfiles can now be imported directly from JS/TS module. node-sass is used to build the linked file as if it was built using node-sass directly (using node-sass module resolution, not webpack's). An import for thesrc/legacy/ui/public/styles/_styling_constants.scssfile is automatically injected at the beginning of each.scssfile imported by a JS/TS module so that users can access the styling constants without explicitly pulling in the styles (as requested by design). The styles required by a module are a part of the JS bundle (both light and dark mode variants) and are injected into the page when the module is loaded based on the theme selected for the current page. Light/dark mode variants are built the same way they used to be, by replacingeui_colors_lightwitheui_colors_darkwhen it's found in any imported path. A page reload is still required to switch themes.changes made to plugins
uiExports.styleSheetPaths(ie src/plugins/expressions/public/index.ts)performance
A primary performance goal of the new optimizer is to build everything as quickly as possible, it does this by running webpack compilers in parallel. This can cause the CPU usage to spike for a bit while the initial build completes. Most people I've talked to prefer that to longer build times, but if you prefer not pegging your CPU you can lower the maximum number of workers using the
KBN_OPTIMIZER_MAX_WORKERSenvironment variable. Setting it to 1 will make the new build take a while, but will cause the least amount of load on your system.caching
When the files in a bundle haven't changed since the last time it was built, the webpack compiler for that bundle will not be started and instead a watcher will be created to watch the files for changes. Checkout the caching section of the readme
Dev Docs
Plugins that have been migrated to the "new platform" are built with a new system into their own
target/publicdirectory. To build third-party plugin's with this new system either pass--plugin-pathtonode scripts/build_new_platform_pluginsor use the@kbn/optimizerpackage in the Kibana repo to build your plugin as described in the readme for that package.