[babel-register] ignore packages directory when running from source (#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.
This commit is contained in:
Spencer 2018-11-22 18:14:14 -08:00 committed by GitHub
parent f981cdf4cc
commit 4b0893ac6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)([^\/]+\/[^\/]+)/,
];
@ -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