Skip to content

Commit

Permalink
[babel-register] ignore packages directory when running from source (#…
Browse files Browse the repository at this point in the history
…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 authored Nov 23, 2018
1 parent f981cdf commit 4b0893a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/setup_node_env/babel_register/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var ignore = [
/\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/,

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

Expand All @@ -56,6 +56,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 4b0893a

Please sign in to comment.