chore(NA): moving @kbn/i18n into bazel (#99390)

* chore(NA): moving @kbn/i18n into bazel

* chore(NA): include javascript locales.js files

* chore(NA): remove build scripts

* chore(NA): remove node types on browser

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2021-05-14 21:12:20 +01:00 committed by GitHub
parent b2d36b863b
commit 7124719d5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 184 additions and 105 deletions

View file

@ -79,6 +79,7 @@ yarn kbn watch-bazel
- @kbn/eslint-import-resolver-kibana
- @kbn/eslint-plugin-eslint
- @kbn/expect
- @kbn/i18n
- @kbn/legacy-logging
- @kbn/logging
- @kbn/securitysolution-constants

View file

@ -129,7 +129,7 @@
"@kbn/config": "link:bazel-bin/packages/kbn-config/npm_module",
"@kbn/config-schema": "link:bazel-bin/packages/kbn-config-schema/npm_module",
"@kbn/crypto": "link:bazel-bin/packages/kbn-crypto/npm_module",
"@kbn/i18n": "link:packages/kbn-i18n",
"@kbn/i18n": "link:bazel-bin/packages/kbn-i18n/npm_module",
"@kbn/interpreter": "link:packages/kbn-interpreter",
"@kbn/io-ts-utils": "link:packages/kbn-io-ts-utils",
"@kbn/legacy-logging": "link:bazel-bin/packages/kbn-legacy-logging/npm_module",

View file

@ -21,6 +21,7 @@ filegroup(
"//packages/kbn-eslint-import-resolver-kibana:build",
"//packages/kbn-eslint-plugin-eslint:build",
"//packages/kbn-expect:build",
"//packages/kbn-i18n:build",
"//packages/kbn-legacy-logging:build",
"//packages/kbn-logging:build",
"//packages/kbn-plugin-generator:build",

View file

@ -0,0 +1,154 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
PKG_BASE_NAME = "kbn-i18n"
PKG_REQUIRE_NAME = "@kbn/i18n"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
"src/core/locales.js",
"types/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/__fixtures__/**",
"**/__snapshots__/**",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"angular/package.json",
"react/package.json",
"package.json",
"GUIDELINE.md",
"README.md"
]
SRC_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-dev-utils",
"@npm//@babel/core",
"@npm//babel-loader",
"@npm//del",
"@npm//getopts",
"@npm//intl-format-cache",
"@npm//intl-messageformat",
"@npm//intl-relativeformat",
"@npm//prop-types",
"@npm//react",
"@npm//react-intl",
"@npm//supports-color",
]
TYPES_DEPS = [
"@npm//typescript",
"@npm//@types/angular",
"@npm//@types/intl-relativeformat",
"@npm//@types/jest",
"@npm//@types/prop-types",
"@npm//@types/react",
"@npm//@types/react-intl",
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_config(
name = "tsconfig_browser",
src = "tsconfig.browser.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.browser.json",
],
)
ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
allow_js = True,
declaration = True,
declaration_dir = "types",
declaration_map = True,
incremental = True,
out_dir = "node",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)
ts_project(
name = "tsc_browser",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
allow_js = True,
declaration = False,
incremental = True,
out_dir = "web",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig_browser",
)
filegroup(
name = "tsc_types",
srcs = [":tsc"],
output_group = "types",
)
filegroup(
name = "target_files",
srcs = [
":tsc",
":tsc_browser",
":tsc_types",
],
)
pkg_npm(
name = "target",
deps = [
":target_files",
],
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":target"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -5,10 +5,5 @@
"types": "./target/types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true,
"scripts": {
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --source-maps",
"kbn:watch": "node scripts/build --watch --source-maps"
}
"private": true
}

View file

@ -1,85 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
const { resolve } = require('path');
const del = require('del');
const supportsColor = require('supports-color');
const { run, withProcRunner } = require('@kbn/dev-utils');
const ROOT_DIR = resolve(__dirname, '..');
const BUILD_DIR = resolve(ROOT_DIR, 'target');
const padRight = (width, str) =>
str.length >= width ? str : `${str}${' '.repeat(width - str.length)}`;
run(
async ({ log, flags }) => {
await withProcRunner(log, async (proc) => {
log.info('Deleting old output');
await del(BUILD_DIR);
const cwd = ROOT_DIR;
const env = { ...process.env };
if (supportsColor.stdout) {
env.FORCE_COLOR = 'true';
}
log.info(`Starting babel and typescript${flags.watch ? ' in watch mode' : ''}`);
await Promise.all([
...['web', 'node'].map((subTask) =>
proc.run(padRight(10, `babel:${subTask}`), {
cmd: 'babel',
args: [
'src',
'--config-file',
require.resolve('../babel.config.js'),
'--out-dir',
resolve(BUILD_DIR, subTask),
'--extensions',
'.ts,.js,.tsx',
...(flags.watch ? ['--watch'] : ['--quiet']),
...(!flags['source-maps'] || !!process.env.CODE_COVERAGE
? []
: ['--source-maps', 'inline']),
],
wait: true,
env: {
...env,
BABEL_ENV: subTask,
},
cwd,
})
),
proc.run(padRight(10, 'tsc'), {
cmd: 'tsc',
args: [
...(flags.watch ? ['--watch', '--preserveWatchOutput', 'true'] : []),
...(flags['source-maps'] ? ['--declarationMap', 'true'] : []),
],
wait: true,
env,
cwd,
}),
]);
log.success('Complete');
});
},
{
description: 'Simple build tool for @kbn/i18n package',
flags: {
boolean: ['watch', 'source-maps'],
help: `
--watch Run in watch mode
--source-maps Include sourcemaps
`,
},
}
);

View file

@ -0,0 +1,21 @@
{
"extends": "../../tsconfig.browser.json",
"compilerOptions": {
"allowJs": true,
"incremental": true,
"outDir": "./target/web",
"declaration": false,
"isolatedModules": true,
"sourceMap": true,
"sourceRoot": "../../../../../packages/kbn-i18n/src"
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"types/intl_format_cache.d.ts",
"types/intl_relativeformat.d.ts"
],
"exclude": [
"**/__fixtures__/**/*"
]
}

View file

@ -1,9 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"allowJs": true,
"incremental": true,
"declarationDir": "./target/types",
"outDir": "./target/node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,

View file

@ -8,8 +8,5 @@
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --dev",
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@kbn/i18n": "link:../kbn-i18n"
}
}

View file

@ -9,8 +9,5 @@
"build": "node ./scripts/build.js",
"kbn:bootstrap": "yarn build --dev",
"build:antlr4ts": "../../node_modules/antlr4ts-cli/antlr4ts ./src/painless/antlr/painless_lexer.g4 ./src/painless/antlr/painless_parser.g4 && node ./scripts/fix_generated_antlr.js"
},
"dependencies": {
"@kbn/i18n": "link:../kbn-i18n"
}
}

View file

@ -14,7 +14,6 @@
"devOnly": true
},
"dependencies": {
"@kbn/i18n": "link:../kbn-i18n",
"@kbn/optimizer": "link:../kbn-optimizer"
}
}

View file

@ -9,7 +9,6 @@
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@kbn/i18n": "link:../kbn-i18n",
"@kbn/monaco": "link:../kbn-monaco"
}
}

View file

@ -32,7 +32,6 @@
"@kbn/test": "link:../packages/kbn-test"
},
"dependencies": {
"@kbn/i18n": "link:../packages/kbn-i18n",
"@kbn/interpreter": "link:../packages/kbn-interpreter",
"@kbn/ui-framework": "link:../packages/kbn-ui-framework"
}

View file

@ -2658,7 +2658,7 @@
version "0.0.0"
uid ""
"@kbn/i18n@link:packages/kbn-i18n":
"@kbn/i18n@link:bazel-bin/packages/kbn-i18n/npm_module":
version "0.0.0"
uid ""