Skip to content

Commit

Permalink
Avoid transpiled files end up into the repo when building (#32069)
Browse files Browse the repository at this point in the history
* fix(na): avoid transpiled files endup on repo when building xpack.

* docs(NA): added todo in order to remove added code when we run the upgrade to babel@7.

* fix(NA): include missing files from the x-pack build.
  • Loading branch information
mistic authored Mar 1, 2019
1 parent 2efe09a commit 9ca411c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 26 additions & 1 deletion x-pack/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,45 @@
* you may not use this file except in compliance with the Elastic License.
*/

import del from 'del';
import { resolve } from 'path';
import { writeFileSync } from 'fs';
import pluginHelpers from '@kbn/plugin-helpers';
import { ToolingLog } from '@kbn/dev-utils';
import { generateNoticeFromSource } from '../../src/dev';

async function moveFiles(gulp, src, dest) {
return new Promise((resolve, reject) => {
gulp.src(src)
.pipe(gulp.dest(dest))
.on('finish', resolve)
.on('error', reject);
});
}

export default (gulp, { buildTarget }) => {
gulp.task('build', ['clean', 'report', 'prepare:build'], async () => {
const buildRoot = resolve(buildTarget, 'kibana/x-pack');
await pluginHelpers.run('build', {
skipArchive: true,
buildDestination: buildTarget,
});

const buildRoot = resolve(buildTarget, 'kibana/x-pack');
// NOTE: In order to prevent ending up with transpiled js files
// in the repository, we have set the outDir on x-pack tsconfig file
// to be the same as the intermediateBuildDirectory defined on the package.json
// As result of it, we need to move the transpiled js files for the correct folder
// and in the end deleting the generated outDir from the intermediateBuildDirectory.
//
//# TODO: This might be able to go away with the upgrade to babel 7
await moveFiles(
gulp,
resolve(buildRoot, 'x-pack/build/plugin/kibana/x-pack/**/!(*.test).js'),
buildRoot
);
await del(resolve(buildRoot, 'x-pack'));
//#

const log = new ToolingLog({
level: 'info',
writeTo: process.stdout
Expand Down
1 change: 1 addition & 0 deletions x-pack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test/**/*"
],
"compilerOptions": {
"outDir": ".",
"paths": {
"ui/*": [
"src/legacy/ui/public/*"
Expand Down

0 comments on commit 9ca411c

Please sign in to comment.