Build erroneously cleans XPack Node.js modules #44900
Labels
bug
Fixes for quality problems that affect the customer experience
Team:Operations
Team label for Operations Team
As a part of the build process, the task
CleanClientModulesOnDLLTask
cleans Node.js modules (by overwriting its files with empty ones) from the distribution that are not used on the server. It does so by building a dependency graph based on the server entry points, and adding those to a whitelist of Node.js modules that should not be cleaned.AFAICT, the code that builds this dependency graph expects a Node.js module to be available in the root node_modules. Any modules from the
x-pack
folder are ignored because they cannot be resolved from the cwd of the build process. This means that any module that is not hoisted, and located inx-pack/node_modules
will be wiped even if it is being used server-side. The result is that those modules will be empty when imported on the server.I ran into this when
io-ts
was no longer hoisted after upgrading:#44753 (comment)
Relevant files:
src/dev/build/tasks/nodejs_modules/clean_client_modules_on_dll_task.js
packages/kbn-babel-code-parser/src/strategies.js
packages/kbn-babel-code-parser/src/can_require.js
The text was updated successfully, but these errors were encountered: