Paul Gschwendtner 96b6a16a65 refactor: add explicit types for createBuilder exports
This is necessary as with the new compilation, leveraging pnpm-linked
first party dependencies, there are cases **during migration** where
multiple locations of the same package exist. e.g.

- `@angular_devkit/architect/node_modules/@angular-devkit/core` (pnpm package output)
- `@angular_devkit/core` (plain js sources)

This is fine, and there is no risk of wrong types, and this should only
occur during migration anyway, but it causes a few type issues as
TypeScript is unable to emit proper types for inference. This is okay,
as we'd likely even want to make use of `isolatedDeclarations` at some
point, but we just add explicit types right now.

(also making `Builder` type more type safe, checking assignability
properly).
2025-01-15 19:20:40 +01:00

126 lines
3.4 KiB
Python

# Copyright Google Inc. All Rights Reserved.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
ts_json_schema(
name = "webpack_schema",
src = "src/builders/webpack/schema.json",
)
ts_json_schema(
name = "webpack_dev_server_schema",
src = "src/builders/webpack-dev-server/schema.json",
)
RUNTIME_ASSETS = [
"builders.json",
"package.json",
"src/builders/webpack-dev-server/schema.json",
"src/builders/webpack/schema.json",
]
ts_project(
name = "build_webpack",
srcs = glob(
include = ["src/**/*.ts"],
exclude = [
"src/test-utils.ts",
"**/*_spec.ts",
],
) + [
"index.ts",
"//packages/angular_devkit/build_webpack:src/builders/webpack-dev-server/schema.ts",
"//packages/angular_devkit/build_webpack:src/builders/webpack/schema.ts",
],
data = RUNTIME_ASSETS,
module_name = "@angular-devkit/build-webpack",
deps = [
"//:node_modules/@types/node",
"//:node_modules/rxjs",
"//:node_modules/webpack",
"//:node_modules/webpack-dev-server",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/core:core_rjs",
],
)
ts_project(
name = "build_webpack_test_lib",
testonly = True,
srcs = glob(
include = [
"src/**/*_spec.ts",
],
),
data = glob(
include = [
"test/**/*",
],
),
deps = [
":build_webpack_rjs",
"//:node_modules/@types/jasmine",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/architect/node:node_rjs",
"//packages/angular_devkit/architect/testing:testing_rjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
"//packages/ngtools/webpack:webpack_rjs",
],
)
jasmine_node_test(
name = "build_webpack_test",
srcs = [":build_webpack_test_lib"],
data = [
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-browser-dynamic",
"//:node_modules/tslib",
"//:node_modules/zone.js",
],
)
genrule(
name = "license",
srcs = ["//:LICENSE"],
outs = ["LICENSE"],
cmd = "cp $(execpath //:LICENSE) $@",
)
npm_package(
name = "pkg",
pkg_deps = [
"//packages/angular_devkit/architect:package.json",
],
tags = ["release-package"],
deps = RUNTIME_ASSETS + [
":README.md",
":build_webpack_rjs",
":license",
],
)
api_golden_test_npm_package(
name = "build_webpack_api",
data = [
":npm_package",
"//goldens:public-api",
],
golden_dir = "angular_cli/goldens/public-api/angular_devkit/build_webpack",
npm_package = "angular_cli/packages/angular_devkit/build_webpack/npm_package",
)