kibana/src/dev/build/tasks/optimize_task.js
Tiago Costa ce9176093b
chore(NA): teardown dynamic dll plugin (#72096) (#72248)
* chore(NA): teardown dynamic dll plugin

* chore(NA): remove missing ts-ignore

* chore(NA): remove last mentions to the DLL machinery

* chore(NA): update notice file

* prevent duplication and searching target/public

* remove changes to es-ui code to unblock pr

* add node internals override for legacy tests bundle

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
# Conflicts:
#	src/dev/notice/generate_notice_from_source.ts
#	src/optimize/base_optimizer.js
2020-07-17 13:51:29 +01:00

52 lines
1.9 KiB
JavaScript

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { deleteAll, copyAll, exec } from '../lib';
import { getNodeDownloadInfo } from './nodejs';
export const OptimizeBuildTask = {
description: 'Running optimizer',
async run(config, log, build) {
const tempNodeInstallDir = build.resolvePath('node');
const platform = config.getPlatformForThisOs();
// copy extracted node for this platform into the build temporarily
log.debug('Temporarily installing node.js for', platform.getNodeArch());
const { extractDir } = getNodeDownloadInfo(config, platform);
await copyAll(extractDir, tempNodeInstallDir);
const kibanaScript = platform.isWindows() ? '.\\bin\\kibana.bat' : './bin/kibana';
const kibanaArgs = ['--env.name=production', '--logging.json=false', '--optimize'];
log.info('Running bin/kibana to trigger the optimizer');
await exec(log, kibanaScript, kibanaArgs, {
cwd: build.resolvePath('.'),
env: {
KBN_CACHE_LOADER_WRITABLE: 'true',
NODE_OPTIONS: '--max-old-space-size=4096',
},
});
// clean up temporary node install
await deleteAll([tempNodeInstallDir], log);
},
};