diff --git a/src/dev/build/build_distributables.js b/src/dev/build/build_distributables.js index acbbddcce8e72..5a9f149736de5 100644 --- a/src/dev/build/build_distributables.js +++ b/src/dev/build/build_distributables.js @@ -49,7 +49,6 @@ import { RemoveWorkspacesTask, TranspileBabelTask, TranspileScssTask, - TypecheckTypescriptTask, UpdateLicenseFileTask, VerifyEnvTask, VerifyExistingNodeBuildsTask, @@ -108,7 +107,6 @@ export async function buildDistributables(options) { * run platform-generic build tasks */ await run(CopySourceTask); - await run(TypecheckTypescriptTask); await run(CreateEmptyDirsAndFilesTask); await run(CreateReadmeTask); await run(TranspileBabelTask); diff --git a/src/dev/build/tasks/index.js b/src/dev/build/tasks/index.js index c471a7aafe118..35c07c9187317 100644 --- a/src/dev/build/tasks/index.js +++ b/src/dev/build/tasks/index.js @@ -33,7 +33,6 @@ export * from './notice_file_task'; export * from './optimize_task'; export * from './os_packages'; export * from './transpile_babel_task'; -export * from './typecheck_typescript_task'; export * from './transpile_scss_task'; export * from './verify_env_task'; export * from './write_sha_sums_task'; diff --git a/src/dev/build/tasks/typecheck_typescript_task.js b/src/dev/build/tasks/typecheck_typescript_task.js deleted file mode 100644 index c8354c0941508..0000000000000 --- a/src/dev/build/tasks/typecheck_typescript_task.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 { exec, write } from '../lib'; -import { Project } from '../../typescript'; - -export const TypecheckTypescriptTask = { - description: 'Typechecking sources with typescript compiler', - - async run(config, log, build) { - // these projects are built in the build folder - const defaultProjectBuild = new Project(build.resolvePath('tsconfig.json')); - const browserProjectBuild = new Project(build.resolvePath('tsconfig.browser.json')); - - // update the default config to exclude **/public/**/* files - await write(defaultProjectBuild.tsConfigPath, JSON.stringify({ - ...defaultProjectBuild.config, - exclude: [ - ...defaultProjectBuild.config.exclude, - 'src/**/public/**/*' - ] - })); - - // update the browser config file to include **/public/**/* files - await write(browserProjectBuild.tsConfigPath, JSON.stringify({ - ...browserProjectBuild.config, - include: [ - ...browserProjectBuild.config.include, - 'src/**/public/**/*', - 'typings/**/*', - 'target/types/**/*' - ] - })); - - // the types project is built inside the repo so x-pack can use it for it's in-repo build. - const typesProjectRepo = new Project(config.resolveFromRepo('tsconfig.types.json')); - const typesProjectBuild = new Project(build.resolvePath('tsconfig.types.json')); - - // update types config to include src/core/public/index.ts - // unlike `include`, specifying the `files` configuration property - // will include files regardless of any exclusion rules - await write(typesProjectBuild.tsConfigPath, JSON.stringify({ - ...typesProjectBuild.config, - files: [ - ...(typesProjectBuild.config.files || []), - 'src/core/public/index.ts' - ] - })); - - const typeProjects = [ - typesProjectRepo.tsConfigPath, - typesProjectBuild.tsConfigPath, - ]; - - const buildProjects = [ - // Browser needs to be compiled before server code so that any shared code - // is compiled to the lowest common denominator (server's CommonJS format) - // which can be supported by both environments. - browserProjectBuild.tsConfigPath, - defaultProjectBuild.tsConfigPath, - ]; - - // Build all typescript project types and then build the project with --noEmit to check for type errors - await Promise.all(typeProjects.map((tsConfigPath) => { - log.info(`Building types for: ${tsConfigPath}`); - return exec( - log, - require.resolve('typescript/bin/tsc'), - [ - '--pretty', 'true', - '--project', tsConfigPath, - ], - { - cwd: build.resolvePath(), - } - ); - })); - - await Promise.all(buildProjects.map((tsConfigPath) => { - log.info(`Type checking: ${tsConfigPath}`); - return exec( - log, - require.resolve('typescript/bin/tsc'), - [ - '--noEmit', 'true', - '--pretty', 'true', - '--project', tsConfigPath, - ], - { - cwd: build.resolvePath(), - } - ); - })); - } -};