Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[babel-register] ignore packages directory when running from source (e…
Browse files Browse the repository at this point in the history
…lastic#26098)

When running the Kibana distributable packages are excluded from `babel-register` because they are installed in the node_modules directory. When running from source they are not ignored, which means that babel-register is doing more work than necessary because these files need to already be built. To fix this I've added an ignore rule that excludes all packages when we are running from source.
  • Loading branch information
Spencer committed Nov 23, 2018
1 parent 7d9f5a4 commit ae8b84b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/setup_node_env/babel_register/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var ignore = [
// https://github.com/elastic/kibana/issues/14800#issuecomment-366130268

// ignore paths matching `/node_modules/{a}/{b}`, unless `a`
// is `x-pack` and `b` is not `node_modules`
/\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/
// is `x-pack` or `b` is not `node_modules`
/\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/,
];

if (global.__BUILT_WITH_BABEL__) {
Expand All @@ -52,6 +52,13 @@ if (global.__BUILT_WITH_BABEL__) {
// building their server code at require-time since version 4.2
// TODO: the plugin install process could transpile plugin server code...
ignore.push(resolve(__dirname, '../../../src'));
} else {
ignore.push(
// ignore any path in the packages, unless it is in the package's
// root `src` directory, in any test or __tests__ directory, or it
// ends with .test.js, .test.ts, or .test.tsx
/\/packages\/(eslint-|kbn-)[^\/]+\/(?!src\/.*|(.+\/)?(test|__tests__)\/.+|.+\.test\.(js|ts|tsx)$)(.+$)/
);
}

// modifies all future calls to require() to automatically
Expand Down

0 comments on commit ae8b84b

Please sign in to comment.