[8.16] chore(NA): upgrade to webpack 5 (#191106)#211152
Merged
mistic merged 12 commits intoelastic:8.16from Feb 19, 2025
Merged
[8.16] chore(NA): upgrade to webpack 5 (#191106)#211152mistic merged 12 commits intoelastic:8.16from
mistic merged 12 commits intoelastic:8.16from
Conversation
### Summary - Closes elastic#89741 This PR contains the resulting work of a massive effort that ports our on top bundler abstraction (called @kbn/optimizer) from Webpack v4 into Webpack v5. It's essential in terms of long term maintenance since v4 was not receiving updates any longer but will also unblock some new features that could be beneficial for our future DevEx endeavours. Next you can find a small list of all the accomplished tasks on this journey. ### Completed Tasks - [x] Upgrade dependencies to match the ones on webpack v5 - [x] Fix null-loader usages - [x] Fix raw-loader usages - [x] Fix file-loader usages - [x] Fix url-loader usages - [x] Fix `@kbn/optimizer-webpack-helpers` to support webpack v5 - [x] Adopt previous webpack v4 polyfill-all strategy with node-polyfill-webpack-plugin - [x] Fix theme-loader on @kbn/optimizer - [x] Migrate configurations and ad-hoc loader options on all webpack configs from v4 to v5 - [x] Fix @kbn/test jest resolver for file-loader cases - [x] Migrate public-path loader on UiSharedDeps - [x] Fix all usages of webpack-merge - [x] Migrate BundleRemoteModule - [x] Migrate BundleRemotesPlugin - [x] Correctly migrate PopulateBundleCachePlugin - [x] Correctly migrate BundleMetricsPlugin - [x] Check if the profiling plugins still work (--profile flag) - [x] Recover if possible the previous webpack v4 cacheGroup chunks rename to something like `data.plugin.chunk.0.js` - [x] Run `/ci` and make sure we get our first green CI, otherwise work on the errors until we do - [x] Profile and solve bottlenecks until we get a cold build performance similar to the one we had on webpack v4 (`node scripts/build_kibana_platform_plugins --no-cache`). - [x] OpenSSL Legacy Warnings: try to remove `--openssl-legacy-provider ` flags - [x] Add Webpack to Renovate config - [x] Explore removing `NodePolyfillPlugin` ([here](https://www.npmjs.com/package/node-polyfill-webpack-plugin)) and add each polyfill needed individually per each webpack config to check if we get smaller bundles. If we do it's better to go with the case by case need approach instead of deploying a bunch of polyfills with NodePolyfillPlugin. As another alternative, create a custom smaller plugin with only the union of all needed polyfills. - [x] Evaluate if we want to touch the resolutions on mainFields and conditionNames - [x] Understand why `@import 'src/core/public/mixins'` does not work anymore (not a problem, we should use relative paths anyway but we want to track why it changed from v4 to v5) - [x] BUG: Child compilers are having errors hidden and/or changed from error to warning - [x] Fix license check for [Artistic-2.0](https://spdx.org/licenses/Artistic-2.0.html) is the license for [domain-browser](https://github.com/bevry/domain-browser?tab=License-1-ov-file). This package is a dependency of [NodePolyfillPlugin](https://www.npmjs.com/package/node-polyfill-webpack-plugin). Artistic 2.0 license is [classified as yellow](https://github.com/elastic/open-source/blob/main/elastic-product-policy.md#yellow-list) and should only be used for dev dependencies. - [x] Make sure `resourceQuery: { not: /raw/ }` is not necessary on other webpack configs like storybook one - [x] Find what is being wrongly removed by usedExports optimization; hint: I believe it is identifying a lot of exports inside the sync entry of plugins as unused exports and removing them. Then `__kbnBootstrap__` can't be found - [x] Rebalance @kbn/optimizer pickMaxWorkerCount - [x] Re-open the issue to fix sass-warnings [elastic#190345](elastic#190345) or downgrade sass-loader to v10 - [x] Remove previous esm no parse rules - [x] Confirm esm support is working - [x] Confirm console override is needed - [x] Confirm react prod builds on ui shared deps for distributable - [x] Remove customization for [xyflow](https://github.com/xyflow/xyflow) from webpack configs - [x] Clean all the code - [x] Make sure collected metrics from stats are still aligned with what we were collecting before; also verify if the modules used for optimizer caches etc are well generated (@kbn/node-libs-browser) - [x] Fix watch performance --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Brad White <brad.white@elastic.co> (cherry picked from commit 203bc28) # Conflicts: # .github/CODEOWNERS # package.json # packages/kbn-eslint-plugin-imports/src/rules/no_group_crossing_imports.ts # packages/kbn-monaco/BUILD.bazel # packages/kbn-node-libs-browser-webpack-plugin/jest.config.js # packages/kbn-optimizer/limits.yml # packages/kbn-optimizer/src/worker/theme_loader.ts # packages/kbn-optimizer/src/worker/webpack.config.ts # packages/kbn-plugin-helpers/src/integration_tests/build.test.ts # packages/kbn-storybook/src/webpack.config.ts # packages/kbn-ui-shared-deps-npm/BUILD.bazel # packages/kbn-ui-shared-deps-npm/webpack.config.js # packages/kbn-ui-shared-deps-src/src/definitions.js # renovate.json # src/platform/packages/private/kbn-ui-shared-deps-src/BUILD.bazel # src/platform/plugins/shared/discover/.storybook/discover.webpack.ts # src/platform/plugins/shared/discover/.storybook/main.ts # src/plugins/discover/.storybook/discover.webpack.ts # src/plugins/discover/.storybook/main.js # src/plugins/discover/.storybook/main.ts # tsconfig.base.json # x-pack/platform/plugins/shared/fleet/package.json # x-pack/platform/plugins/shared/osquery/package.json # x-pack/plugins/canvas/shareable_runtime/webpack.config.js # x-pack/plugins/canvas/storybook/canvas_webpack.ts # x-pack/plugins/security_solution/package.json # x-pack/solutions/observability/plugins/apm/ftr_e2e/package.json # x-pack/solutions/observability/plugins/profiling/e2e/package.json # x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/.storybook/main.ts # x-pack/test/security_solution_cypress/package.json # yarn.lock
39 tasks
Contributor
|
Pinging @elastic/fleet (Team:Fleet) |
Contributor
|
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
Contributor
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --update --no-serverless'
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --update --no-serverless'
…to backport/8.16/pr-191106
46482ff to
7e91722
Compare
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Public APIs missing comments
Any counts in public APIs
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
ESLint disabled line counts
miscellaneous assets size
Total ESLint disabled count
History |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.16:Questions ?
Please refer to the Backport tool documentation