mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
chore(NA): change build to compile typescript with babel for the oss code. chore(NA): change transpile typescript task to only transpile types for x-pack. refact(NA): common preset for babel 7
This commit is contained in:
parent
1a14a64fc4
commit
2707d538f5
5 changed files with 11 additions and 41 deletions
|
@ -19,15 +19,12 @@
|
|||
|
||||
module.exports = {
|
||||
presets: [
|
||||
require.resolve('@babel/preset-react'),
|
||||
require.resolve('@babel/preset-typescript'),
|
||||
require.resolve('@babel/preset-react')
|
||||
],
|
||||
plugins: [
|
||||
require.resolve('babel-plugin-add-module-exports'),
|
||||
// stage 3
|
||||
require.resolve('@babel/plugin-proposal-async-generator-functions'),
|
||||
require.resolve('@babel/plugin-proposal-export-default-from'),
|
||||
require.resolve('@babel/plugin-proposal-object-rest-spread'),
|
||||
require.resolve('@babel/plugin-transform-modules-commonjs'),
|
||||
|
||||
// the class properties proposal was merged with the private fields proposal
|
||||
|
|
|
@ -47,7 +47,7 @@ import {
|
|||
RemovePackageJsonDepsTask,
|
||||
RemoveWorkspacesTask,
|
||||
TranspileBabelTask,
|
||||
TranspileTypescriptTask,
|
||||
TranspileTypescriptTypesTask,
|
||||
TranspileScssTask,
|
||||
UpdateLicenseFileTask,
|
||||
VerifyEnvTask,
|
||||
|
@ -110,18 +110,18 @@ export async function buildDistributables(options) {
|
|||
await run(CreateEmptyDirsAndFilesTask);
|
||||
await run(CreateReadmeTask);
|
||||
await run(TranspileBabelTask);
|
||||
await run(TranspileTypescriptTask);
|
||||
await run(TranspileTypescriptTypesTask);
|
||||
await run(BuildPackagesTask);
|
||||
await run(CreatePackageJsonTask);
|
||||
await run(InstallDependenciesTask);
|
||||
await run(RemoveWorkspacesTask);
|
||||
await run(CleanTypescriptTask);
|
||||
await run(CleanPackagesTask);
|
||||
await run(CreateNoticeFileTask);
|
||||
await run(UpdateLicenseFileTask);
|
||||
await run(RemovePackageJsonDepsTask);
|
||||
await run(TranspileScssTask);
|
||||
await run(OptimizeBuildTask);
|
||||
await run(CleanTypescriptTask);
|
||||
await run(CleanClientModulesOnDLLTask);
|
||||
await run(CleanExtraFilesFromModulesTask);
|
||||
await run(CleanEmptyFoldersTask);
|
||||
|
|
|
@ -33,7 +33,7 @@ export * from './notice_file_task';
|
|||
export * from './optimize_task';
|
||||
export * from './os_packages';
|
||||
export * from './transpile_babel_task';
|
||||
export * from './transpile_typescript_task';
|
||||
export * from './transpile_typescript_types_task';
|
||||
export * from './transpile_scss_task';
|
||||
export * from './verify_env_task';
|
||||
export * from './write_sha_sums_task';
|
||||
|
|
|
@ -29,7 +29,8 @@ export const TranspileBabelTask = {
|
|||
await createPromiseFromStreams([
|
||||
vfs.src(
|
||||
[
|
||||
'**/*.js',
|
||||
'**/*.{js,ts,tsx}',
|
||||
'!**/*.d.ts',
|
||||
'!packages/**',
|
||||
'!**/public/**',
|
||||
'!**/node_modules/**',
|
||||
|
|
|
@ -17,48 +17,20 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { exec, write } from '../lib';
|
||||
import { exec } from '../lib';
|
||||
import { Project } from '../../typescript';
|
||||
|
||||
export const TranspileTypescriptTask = {
|
||||
description: 'Transpiling sources with typescript compiler',
|
||||
export const TranspileTypescriptTypesTask = {
|
||||
description: 'Transpiling types with typescript compiler',
|
||||
|
||||
async run(config, log, build) {
|
||||
// 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'));
|
||||
|
||||
// these projects are built in the build folder
|
||||
const defaultProject = new Project(build.resolvePath('tsconfig.json'));
|
||||
const browserProject = new Project(build.resolvePath('tsconfig.browser.json'));
|
||||
|
||||
// update the default config to exclude **/public/**/* files
|
||||
await write(defaultProject.tsConfigPath, JSON.stringify({
|
||||
...defaultProject.config,
|
||||
exclude: [
|
||||
...defaultProject.config.exclude,
|
||||
'src/**/public/**/*'
|
||||
]
|
||||
}));
|
||||
|
||||
// update the browser config file to include **/public/**/* files
|
||||
await write(browserProject.tsConfigPath, JSON.stringify({
|
||||
...browserProject.config,
|
||||
include: [
|
||||
...browserProject.config.include,
|
||||
'src/**/public/**/*',
|
||||
'typings/**/*'
|
||||
]
|
||||
}));
|
||||
|
||||
const projects = [
|
||||
typesProjectRepo.tsConfigPath,
|
||||
typesProjectBuild.tsConfigPath,
|
||||
// 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.
|
||||
browserProject.tsConfigPath,
|
||||
defaultProject.tsConfigPath,
|
||||
typesProjectBuild.tsConfigPath
|
||||
];
|
||||
|
||||
// compile each typescript config file
|
Loading…
Add table
Add a link
Reference in a new issue