-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SharedUX][PoC] Move to a package architecture #127419
Closed
clintandrewhall
wants to merge
12
commits into
elastic:main
from
clintandrewhall:sharedux/package-architecture
+1,205
−258
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dd7c1ad
[SharedUX][PoC] Move to a package architecture
clintandrewhall 9105cf0
Updating
clintandrewhall 3acbbe9
Merge branch 'main' into sharedux/package-architecture
kibanamachine 757a6c5
Fix ts
clintandrewhall 0892e62
Merge branch 'main' into sharedux/package-architecture
kibanamachine 956a651
Fix rename
clintandrewhall 8c1b0bd
Add external type
clintandrewhall 5b9777e
Rename packages
clintandrewhall 0810159
Tweak BAZEL and service
clintandrewhall 42f3b33
i18n
clintandrewhall 3253b55
Merge branch 'main' into sharedux/package-architecture
kibanamachine 2222605
i18n snapshots
clintandrewhall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
load("@npm//@bazel/typescript:index.bzl", "ts_config") | ||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library") | ||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") | ||
|
||
PKG_DIRNAME = "kbn-shared-ux-components" | ||
PKG_REQUIRE_NAME = "@kbn/shared-ux-components" | ||
|
||
SOURCE_FILES = glob( | ||
[ | ||
"src/**/*.ts", | ||
"src/**/*.tsx", | ||
"src/**/*.scss", | ||
], | ||
exclude = [ | ||
"**/*.test.*", | ||
], | ||
) | ||
|
||
SRCS = SOURCE_FILES | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = SRCS, | ||
) | ||
|
||
NPM_MODULE_EXTRA_FILES = [ | ||
"package.json", | ||
] | ||
|
||
# In this array place runtime dependencies, including other packages and NPM packages | ||
# which must be available for this code to run. | ||
# | ||
# To reference other packages use: | ||
# "//repo/relative/path/to/package" | ||
# eg. "//packages/kbn-utils" | ||
# | ||
# To reference a NPM package use: | ||
# "@npm//name-of-package" | ||
# eg. "@npm//lodash" | ||
RUNTIME_DEPS = [ | ||
"//packages/kbn-i18n", | ||
"//packages/kbn-i18n-react", | ||
"//packages/kbn-shared-ux-services", | ||
"//packages/kbn-shared-ux-storybook", | ||
"//packages/kbn-shared-ux-utility", | ||
"@npm//react", | ||
"@npm//@elastic/eui", | ||
"@npm//@emotion/react", | ||
"@npm//@emotion/css", | ||
"@npm//classnames", | ||
"@npm//@storybook/addon-actions", | ||
] | ||
|
||
# In this array place dependencies necessary to build the types, which will include the | ||
# :npm_module_types target of other packages and packages from NPM, including @types/* | ||
# packages. | ||
# | ||
# To reference the types for another package use: | ||
# "//repo/relative/path/to/package:npm_module_types" | ||
# eg. "//packages/kbn-utils:npm_module_types" | ||
# | ||
# References to NPM packages work the same as RUNTIME_DEPS | ||
TYPES_DEPS = [ | ||
"//packages/kbn-i18n:npm_module_types", | ||
"//packages/kbn-i18n-react:npm_module_types", | ||
"//packages/kbn-shared-ux-services:npm_module_types", | ||
"//packages/kbn-shared-ux-storybook:npm_module_types", | ||
"//packages/kbn-shared-ux-utility:npm_module_types", | ||
"@npm//@types/node", | ||
"@npm//@types/jest", | ||
"@npm//@types/react", | ||
"@npm//@elastic/eui", | ||
"@npm//@emotion/react", | ||
"@npm//@emotion/css", | ||
"@npm//@storybook/addon-actions", | ||
"@npm//@types/classnames", | ||
] | ||
|
||
jsts_transpiler( | ||
name = "target_node", | ||
srcs = SRCS, | ||
build_pkg_name = package_name(), | ||
) | ||
|
||
jsts_transpiler( | ||
name = "target_web", | ||
srcs = SRCS, | ||
build_pkg_name = package_name(), | ||
web = True, | ||
additional_args = [ | ||
"--copy-files", | ||
"--quiet" | ||
], | ||
) | ||
|
||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
deps = [ | ||
"//:tsconfig.base.json", | ||
"//:tsconfig.bazel.json", | ||
], | ||
) | ||
|
||
ts_project( | ||
name = "tsc_types", | ||
args = ['--pretty'], | ||
srcs = SRCS, | ||
deps = TYPES_DEPS, | ||
declaration = True, | ||
emit_declaration_only = True, | ||
out_dir = "target_types", | ||
root_dir = "src", | ||
tsconfig = ":tsconfig", | ||
) | ||
|
||
js_library( | ||
name = PKG_DIRNAME, | ||
srcs = NPM_MODULE_EXTRA_FILES, | ||
deps = RUNTIME_DEPS + [":target_node", ":target_web"], | ||
package_name = PKG_REQUIRE_NAME, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
pkg_npm( | ||
name = "npm_module", | ||
deps = [":" + PKG_DIRNAME], | ||
) | ||
|
||
filegroup( | ||
name = "build", | ||
srcs = [":npm_module"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
pkg_npm_types( | ||
name = "npm_module_types", | ||
srcs = SRCS, | ||
deps = [":tsc_types"], | ||
package_name = PKG_REQUIRE_NAME, | ||
tsconfig = ":tsconfig", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
filegroup( | ||
name = "build_types", | ||
srcs = [":npm_module_types"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @kbn/shared-ux-components | ||
|
||
Empty package generated by @kbn/generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../..', | ||
roots: ['<rootDir>/packages/kbn-shared-ux-components'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@kbn/shared-ux-components", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "./target_node/index.js", | ||
"browser": "./target_web/index.js", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...pshots__/documentation_link.test.tsx.snap → ...pshots__/documentation_link.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s__/exit_full_screen_button.test.tsx.snap → ...s__/exit_full_screen_button.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're in the process of migrating to packages, having a
types
package is a pretty standard deal. We should really work on getting one for common types, at least the ones fromdata
anddata_view
plugins. We made all this effort to migrate to typescript, only to be taking a step back now. Is this on your radar as well @spalger ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that would accomplish more than colocating the types today. Technically, Bazel already builds a separate types "package"... and I'd be worried about keeping types too far from the relevant code.
At the same time, I'd be interested in creating a
@kbn/shared-ux-types
package for common and public types. I'd just want to keep it curated to truly universal/common types, rather than default to putting all types there.It's a good point. Let's think on it a bit, see what we'd propose to put in a
types
package to see if there'd be value in it. @spalger @stacey-gammon I'd be curious on your input here, as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion is to stick to our '"organize by domain" philosophy and co-locate types with the thing they are describing (meaning
DataView
types should be next toDataView
implementation stuff).Am I understanding the issue here is that packages can't depend on plugins and thats why this had to change from a type to
unknown
?I think we will eventually be able to solve this when each plugin is a package, and there is no separate
packages
directory at all (#112886)cc @mistic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I feel like shared-ux is just a little ahead of the curve here. The DataView plugin will eventually be a package and
@kbn/shared-ux*
will be able to import theDataView
type from it, a@kbn/data-views-types
package, or something similar but co-located with the data views implementation stuff.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree +++