diff --git a/package.json b/package.json index 58330721d71b5..30221795a6177 100644 --- a/package.json +++ b/package.json @@ -608,6 +608,7 @@ "@types/kbn__server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools/npm_module_types", "@types/kbn__server-route-repository": "link:bazel-bin/packages/kbn-server-route-repository/npm_module_types", "@types/kbn__std": "link:bazel-bin/packages/kbn-std/npm_module_types", + "@types/kbn__storybook": "link:bazel-bin/packages/kbn-storybook/npm_module_types", "@types/kbn__telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types", "@types/kbn__ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types", "@types/kbn__ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 433118934ef95..3b95f652f5bc5 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -124,6 +124,7 @@ filegroup( "//packages/kbn-server-http-tools:build_types", "//packages/kbn-server-route-repository:build_types", "//packages/kbn-std:build_types", + "//packages/kbn-storybook:build_types", "//packages/kbn-telemetry-tools:build_types", "//packages/kbn-ui-shared-deps-npm:build_types", "//packages/kbn-ui-shared-deps-src:build_types", diff --git a/packages/kbn-storybook/BUILD.bazel b/packages/kbn-storybook/BUILD.bazel index fc7599b058373..686de744b656f 100644 --- a/packages/kbn-storybook/BUILD.bazel +++ b/packages/kbn-storybook/BUILD.bazel @@ -1,9 +1,10 @@ -load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") -load("//src/dev/bazel:index.bzl", "jsts_transpiler") +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_BASE_NAME = "kbn-storybook" PKG_REQUIRE_NAME = "@kbn/storybook" +TYPES_PKG_REQUIRE_NAME = "@types/kbn__storybook" SOURCE_FILES = glob( [ @@ -64,7 +65,6 @@ TYPES_DEPS = [ "@npm//@storybook/node-logger", "@npm//@storybook/react", "@npm//@storybook/theming", - "@npm//@types/express", # necessary for storybook which is missing the types "@npm//@types/loader-utils", "@npm//@types/node", "@npm//@types/react", @@ -104,7 +104,7 @@ ts_project( js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, - deps = RUNTIME_DEPS + [":target_node", ":tsc_types"], + deps = RUNTIME_DEPS + [":target_node"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) @@ -123,3 +123,21 @@ filegroup( ], visibility = ["//visibility:public"], ) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = TYPES_PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [ + ":npm_module_types", + ], + visibility = ["//visibility:public"], +) + diff --git a/packages/kbn-storybook/package.json b/packages/kbn-storybook/package.json index ba03240262e9c..f24d926aa42a3 100644 --- a/packages/kbn-storybook/package.json +++ b/packages/kbn-storybook/package.json @@ -5,7 +5,6 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target_node/index.js", - "types": "./target_types/index.d.ts", "kibana": { "devOnly": true } diff --git a/packages/kbn-storybook/src/webpack.config.ts b/packages/kbn-storybook/src/webpack.config.ts index f79fc497d24ba..8d5818182b876 100644 --- a/packages/kbn-storybook/src/webpack.config.ts +++ b/packages/kbn-storybook/src/webpack.config.ts @@ -68,7 +68,7 @@ function isDesiredPreset(preset: Preset) { // Extend the Storybook Webpack config with some customizations /* eslint-disable import/no-default-export */ -export default function ({ config: storybookConfig }: { config: Configuration }) { +export default ({ config: storybookConfig }: { config: Configuration }) => { const config = { devServer: { stats, @@ -195,4 +195,4 @@ export default function ({ config: storybookConfig }: { config: Configuration }) }, config ); -} +}; diff --git a/yarn.lock b/yarn.lock index cdc04bef8b749..6e0e20d55a1b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6890,6 +6890,10 @@ version "0.0.0" uid "" +"@types/kbn__storybook@link:bazel-bin/packages/kbn-storybook/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__telemetry-tools@link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types": version "0.0.0" uid ""