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

Build erroneously cleans XPack Node.js modules #44900

Closed
dgieselaar opened this issue Sep 5, 2019 · 1 comment · Fixed by #47091
Closed

Build erroneously cleans XPack Node.js modules #44900

dgieselaar opened this issue Sep 5, 2019 · 1 comment · Fixed by #47091
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team

Comments

@dgieselaar
Copy link
Member

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 in x-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
@dgieselaar dgieselaar added the Team:Operations Team label for Operations Team label Sep 5, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations

@dgieselaar dgieselaar added the bug Fixes for quality problems that affect the customer experience label Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants