mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Relative cache loader (#36131)
* chore(NA): first efforts to enable cache-loader relative paths and disable babel-register cache. chore(NA): allow to use cache-loader results everywhere as a persistent cache. * chore(NA): last change to support cache loader across envs. * fix(NA): cache-loader config generator function scope. * refact(NA): static cache config for dll compiler. * chore(NA): support for force writable cache flag. use built assets for cache on distributable. * chore(NA): update cache-loader to last version. fix(NA): logic bug with force writable cache flag. * chore(NA): move optimize cache to built_assets. * chore(NA): relative paths for sourcemap configurations. * chore(NA): remove redudant check for process.env var. * refact(NA): simplify double negated expression. * chore(NA): remove webpack prefix from devtoolModuleFilenameTemplate. * chore(NA): rename cache write force flag to KBN_CACHE_LOADER_WRITABLE. * chore(NA): readd babel register cache. * chore(NA): change .cache to .ui_bundles_cache * chore(NA): change .ui_bundles_cache to cache/ui_bundles * chore(NA): update gitignore with .babel_register_cache.json * chore(NA): rollback devtool module filename template to asbolute resource path. * chore(NA): apply cache-loader patch.
This commit is contained in:
parent
b78aba3298
commit
162e13dbdf
9 changed files with 55 additions and 27 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -31,7 +31,7 @@ webpackstats.json
|
|||
!/config/kibana.yml
|
||||
coverage
|
||||
selenium
|
||||
.babelcache.json
|
||||
.babel_register_cache.json
|
||||
.webpack.babelcache
|
||||
*.swp
|
||||
*.swo
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
"bluebird": "3.5.5",
|
||||
"boom": "^7.2.0",
|
||||
"brace": "0.11.1",
|
||||
"cache-loader": "1.2.2",
|
||||
"cache-loader": "^3.0.1",
|
||||
"chalk": "^2.4.1",
|
||||
"color": "1.0.3",
|
||||
"commander": "2.20.0",
|
||||
|
|
|
@ -26,7 +26,7 @@ export const CreateEmptyDirsAndFilesTask = {
|
|||
await Promise.all([
|
||||
mkdirp(build.resolvePath('plugins')),
|
||||
mkdirp(build.resolvePath('data')),
|
||||
write(build.resolvePath('optimize/.babelcache.json'), '{}'),
|
||||
write(build.resolvePath('optimize/.babel_register_cache.json'), '{}'),
|
||||
]);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -48,6 +48,7 @@ export const OptimizeBuildTask = {
|
|||
cwd: build.resolvePath('.'),
|
||||
env: {
|
||||
FORCE_DLL_CREATION: 'true',
|
||||
KBN_CACHE_LOADER_WRITABLE: 'true',
|
||||
NODE_OPTIONS: '--max-old-space-size=2048'
|
||||
},
|
||||
});
|
||||
|
|
|
@ -26,6 +26,8 @@ import del from 'del';
|
|||
import { makeRe } from 'minimatch';
|
||||
import mkdirp from 'mkdirp';
|
||||
|
||||
import { IS_KIBANA_DISTRIBUTABLE } from '../../utils';
|
||||
|
||||
import { UiBundle } from './ui_bundle';
|
||||
import { appEntryTemplate } from './app_entry_template';
|
||||
|
||||
|
@ -168,7 +170,11 @@ export class UiBundlesController {
|
|||
}
|
||||
|
||||
getCacheDirectory(...subPath) {
|
||||
return this.resolvePath('../.cache', this.hashBundleEntries(), ...subPath);
|
||||
return this.resolvePath(
|
||||
'../../built_assets/.cache/ui_bundles',
|
||||
!IS_KIBANA_DISTRIBUTABLE ? this.hashBundleEntries() : '',
|
||||
...subPath
|
||||
);
|
||||
}
|
||||
|
||||
getDescription() {
|
||||
|
|
|
@ -212,15 +212,13 @@ export default class BaseOptimizer {
|
|||
* of Kibana and just make compressing and extracting it more difficult.
|
||||
*/
|
||||
const maybeAddCacheLoader = (cacheName, loaders) => {
|
||||
if (IS_KIBANA_DISTRIBUTABLE) {
|
||||
return loaders;
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
loader: 'cache-loader',
|
||||
options: {
|
||||
cacheDirectory: this.uiBundles.getCacheDirectory(cacheName)
|
||||
cacheContext: fromRoot('.'),
|
||||
cacheDirectory: this.uiBundles.getCacheDirectory(cacheName),
|
||||
readOnly: process.env.KBN_CACHE_LOADER_WRITABLE ? false : IS_KIBANA_DISTRIBUTABLE
|
||||
}
|
||||
},
|
||||
...loaders
|
||||
|
|
|
@ -95,19 +95,13 @@ function generateDLL(config) {
|
|||
// Self calling function with the equivalent logic
|
||||
// from maybeAddCacheLoader one from base optimizer
|
||||
use: ((babelLoaderCacheDirPath, loaders) => {
|
||||
// Only deactivate cache-loader and thread-loader on
|
||||
// distributable. It is valid when running from source
|
||||
// both with dev or prod bundles or even when running
|
||||
// kibana for dev only.
|
||||
if (IS_KIBANA_DISTRIBUTABLE) {
|
||||
return loaders;
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
loader: 'cache-loader',
|
||||
options: {
|
||||
cacheDirectory: babelLoaderCacheDirPath
|
||||
cacheContext: fromRoot('.'),
|
||||
cacheDirectory: babelLoaderCacheDirPath,
|
||||
readOnly: process.env.KBN_CACHE_LOADER_WRITABLE ? false : IS_KIBANA_DISTRIBUTABLE
|
||||
}
|
||||
},
|
||||
...loaders
|
||||
|
|
|
@ -22,7 +22,7 @@ var resolve = require('path').resolve;
|
|||
// this must happen before `require('@babel/register')` and can't be changed
|
||||
// once the module has been loaded
|
||||
if (!process.env.BABEL_CACHE_PATH) {
|
||||
process.env.BABEL_CACHE_PATH = resolve(__dirname, '../../../optimize/.babelcache.json');
|
||||
process.env.BABEL_CACHE_PATH = resolve(__dirname, '../../../optimize/.babel_register_cache.json');
|
||||
}
|
||||
|
||||
// paths that @babel/register should ignore
|
||||
|
|
45
yarn.lock
45
yarn.lock
|
@ -7150,6 +7150,11 @@ buffer-indexof@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c"
|
||||
integrity sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==
|
||||
|
||||
buffer-json@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/buffer-json/-/buffer-json-2.0.0.tgz#f73e13b1e42f196fe2fd67d001c7d7107edd7c23"
|
||||
integrity sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==
|
||||
|
||||
buffer-xor@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9"
|
||||
|
@ -7311,15 +7316,17 @@ cache-base@^1.0.1:
|
|||
union-value "^1.0.0"
|
||||
unset-value "^1.0.0"
|
||||
|
||||
cache-loader@1.2.2:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/cache-loader/-/cache-loader-1.2.2.tgz#6d5c38ded959a09cc5d58190ab5af6f73bd353f5"
|
||||
integrity sha512-rsGh4SIYyB9glU+d0OcHwiXHXBoUgDhHZaQ1KAbiXqfz1CDPxtTboh1gPbJ0q2qdO8a9lfcjgC5CJ2Ms32y5bw==
|
||||
cache-loader@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/cache-loader/-/cache-loader-3.0.1.tgz#cee6cf4b3cdc7c610905b26bad6c2fc439c821af"
|
||||
integrity sha512-HzJIvGiGqYsFUrMjAJNDbVZoG7qQA+vy9AIoKs7s9DscNfki0I589mf2w6/tW+kkFH3zyiknoWV5Jdynu6b/zw==
|
||||
dependencies:
|
||||
loader-utils "^1.1.0"
|
||||
buffer-json "^2.0.0"
|
||||
find-cache-dir "^2.1.0"
|
||||
loader-utils "^1.2.3"
|
||||
mkdirp "^0.5.1"
|
||||
neo-async "^2.5.0"
|
||||
schema-utils "^0.4.2"
|
||||
neo-async "^2.6.1"
|
||||
schema-utils "^1.0.0"
|
||||
|
||||
cacheable-request@^2.1.1:
|
||||
version "2.1.4"
|
||||
|
@ -12109,6 +12116,15 @@ find-cache-dir@^2.0.0:
|
|||
make-dir "^1.0.0"
|
||||
pkg-dir "^3.0.0"
|
||||
|
||||
find-cache-dir@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7"
|
||||
integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==
|
||||
dependencies:
|
||||
commondir "^1.0.1"
|
||||
make-dir "^2.0.0"
|
||||
pkg-dir "^3.0.0"
|
||||
|
||||
find-index@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4"
|
||||
|
@ -17942,6 +17958,14 @@ make-dir@^1.0.0, make-dir@^1.3.0:
|
|||
dependencies:
|
||||
pify "^3.0.0"
|
||||
|
||||
make-dir@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
|
||||
integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==
|
||||
dependencies:
|
||||
pify "^4.0.1"
|
||||
semver "^5.6.0"
|
||||
|
||||
make-error@^1.3.5:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
|
||||
|
@ -18885,6 +18909,11 @@ neo-async@^2.6.0:
|
|||
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835"
|
||||
integrity sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==
|
||||
|
||||
neo-async@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
|
||||
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==
|
||||
|
||||
nested-error-stacks@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-1.0.2.tgz#19f619591519f096769a5ba9a86e6eeec823c3cf"
|
||||
|
@ -23775,7 +23804,7 @@ schema-utils@^0.3.0:
|
|||
dependencies:
|
||||
ajv "^5.0.0"
|
||||
|
||||
schema-utils@^0.4.0, schema-utils@^0.4.2, schema-utils@^0.4.4, schema-utils@^0.4.5:
|
||||
schema-utils@^0.4.0, schema-utils@^0.4.4, schema-utils@^0.4.5:
|
||||
version "0.4.7"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
||||
integrity sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue