Skip to content

Commit

Permalink
chore(NA): moving @kbn/monaco into bazel (#100709) (#100808)
Browse files Browse the repository at this point in the history
* chore(NA): moving @kbn/monaco into bazel

* chore(NA): update register globals definitions

* chore(NA): remove build script

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com>
  • Loading branch information
kibanamachine and mistic authored May 27, 2021
1 parent 64017d6 commit 72e000f
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 72 deletions.
8 changes: 5 additions & 3 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ yarn kbn watch-bazel
- @kbn/i18n
- @kbn/legacy-logging
- @kbn/logging
- @kbn/mapbox-gl
- @kbn/monaco
- @kbn/securitysolution-es-utils
- kbn/securitysolution-io-ts-alerting-types
- kbn/securitysolution-io-ts-list-types
- kbn/securitysolution-io-ts-types
- @kbn/securitysolution-io-ts-alerting-types
- @kbn/securitysolution-io-ts-list-types
- @kbn/securitysolution-io-ts-types
- @kbn/securitysolution-io-ts-utils
- @kbn/securitysolution-list-api
- @kbn/securitysolution-list-constants
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"@kbn/io-ts-utils": "link:packages/kbn-io-ts-utils",
"@kbn/legacy-logging": "link:bazel-bin/packages/kbn-legacy-logging/npm_module",
"@kbn/logging": "link:bazel-bin/packages/kbn-logging/npm_module",
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/monaco": "link:bazel-bin/packages/kbn-monaco/npm_module",
"@kbn/securitysolution-list-constants": "link:bazel-bin/packages/kbn-securitysolution-list-constants/npm_module",
"@kbn/securitysolution-es-utils": "link:bazel-bin/packages/kbn-securitysolution-es-utils/npm_module",
"@kbn/securitysolution-io-ts-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-types/npm_module",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ filegroup(
"//packages/kbn-legacy-logging:build",
"//packages/kbn-logging:build",
"//packages/kbn-mapbox-gl:build",
"//packages/kbn-monaco:build",
"//packages/kbn-plugin-generator:build",
"//packages/kbn-securitysolution-list-constants:build",
"//packages/kbn-securitysolution-io-ts-types:build",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-babel-preset/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DEPS = [
"@npm//@babel/preset-typescript",
"@npm//babel-plugin-add-module-exports",
"@npm//babel-plugin-styled-components",
"@npm//babel-plugin-transform-react-remove-prop-types",
]

js_library(
Expand Down
108 changes: 108 additions & 0 deletions packages/kbn-monaco/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")

PKG_BASE_NAME = "kbn-monaco"
PKG_REQUIRE_NAME = "@kbn/monaco"

SOURCE_FILES = glob(
[
"src/**/*",
],
exclude = [
"**/*.test.*",
"**/README.md",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md"
]

SRC_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"@npm//antlr4ts",
"@npm//babel-loader",
"@npm//monaco-editor",
"@npm//raw-loader",
"@npm//regenerator-runtime",
]

TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS

webpack(
name = "target_web",
data = DEPS + [
":src",
":webpack.config.js",
],
output_dir = True,
args = [
"--config",
"$(location webpack.config.js)",
"--output-path",
"$(@D)",
"--env.prod",
"--display=minimal"
],
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)

ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_dir = "target_types",
declaration_map = True,
incremental = True,
out_dir = "target_node",
source_map = True,
root_dir = ".",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":target_web", ":tsc"],
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"],
)
6 changes: 2 additions & 4 deletions packages/kbn-monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"name": "@kbn/monaco",
"version": "1.0.0",
"private": true,
"main": "./target/index.js",
"types": "./target/index.d.ts",
"main": "target_node/src/index.js",
"types": "target_types/src/index.d.ts",
"license": "SSPL-1.0 OR Elastic License 2.0",
"scripts": {
"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"
}
}
53 changes: 0 additions & 53 deletions packages/kbn-monaco/scripts/build.js

This file was deleted.

6 changes: 3 additions & 3 deletions packages/kbn-monaco/src/register_globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { PainlessLang } from './painless';
import { EsqlLang } from './esql';
import { monaco } from './monaco_imports';
// @ts-ignore
import xJsonWorkerSrc from '!!raw-loader!../target/public/xjson.editor.worker.js';
import xJsonWorkerSrc from '!!raw-loader!../../target_web/xjson.editor.worker.js';
// @ts-ignore
import defaultWorkerSrc from '!!raw-loader!../target/public/default.editor.worker.js';
import defaultWorkerSrc from '!!raw-loader!../../target_web/default.editor.worker.js';
// @ts-ignore
import painlessWorkerSrc from '!!raw-loader!../target/public/painless.editor.worker.js';
import painlessWorkerSrc from '!!raw-loader!../../target_web/painless.editor.worker.js';

/**
* Register languages and lexer rules
Expand Down
8 changes: 5 additions & 3 deletions packages/kbn-monaco/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"outDir": "./target",
"incremental": true,
"declarationDir": "./target_types",
"outDir": "./target_node",
"declaration": true,
"declarationMap": true,
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-monaco/src",
"types": [
Expand All @@ -13,6 +15,6 @@
]
},
"include": [
"src/**/*"
"src/**/*",
]
}
2 changes: 1 addition & 1 deletion packages/kbn-monaco/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const createLangWorkerConfig = (lang) => {
mode: 'production',
entry,
output: {
path: path.resolve(__dirname, 'target/public'),
path: path.resolve(__dirname, 'target_web'),
filename: `${lang}.editor.worker.js`,
},
resolve: {
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build --dev",
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@kbn/monaco": "link:../kbn-monaco"
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2682,7 +2682,7 @@
version "0.0.0"
uid ""

"@kbn/monaco@link:packages/kbn-monaco":
"@kbn/monaco@link:bazel-bin/packages/kbn-monaco/npm_module":
version "0.0.0"
uid ""

Expand Down

0 comments on commit 72e000f

Please sign in to comment.