From fdea3ad4d29a70f5bac9b69ee4438156dd2c1b83 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 20 Mar 2025 11:00:43 +0000 Subject: [PATCH 1/4] build: migrate theming tests to `rules_js` Migrates the theming tests to `rules_js`. This also requires us to bring in the Jasmine ruleset, and fix some issues with the test tsconfig. --- .../npm_translate_lock_MzA5NzUwNzMx | 6 ++--- WORKSPACE | 11 ++++++++ package.json | 6 +++-- pnpm-lock.yaml | 6 +++++ src/BUILD.bazel | 12 ++++++++- src/bazel-tsconfig-test.json | 2 +- ...st.conf.js => circular-deps-test.conf.cjs} | 0 src/material/core/theming/tests/BUILD.bazel | 27 ++++++++++--------- .../core/theming/tests/m3-theme.spec.ts | 2 +- .../tests/theming-definition-api.spec.ts | 2 +- .../tests/theming-inspection-api.spec.ts | 2 +- .../theming/tests/theming-mixin-api.spec.ts | 4 +-- .../theming-typography-hierarchy.spec.ts | 2 +- src/package.json | 3 +++ tools/defaults.bzl | 6 +++-- tools/defaults2.bzl | 24 +++++++++++++++++ yarn.lock | 4 +-- 17 files changed, 89 insertions(+), 30 deletions(-) rename src/{circular-deps-test.conf.js => circular-deps-test.conf.cjs} (100%) create mode 100644 src/package.json diff --git a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx index 20f2de9a0d03..ac510797bf17 100755 --- a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx +++ b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx @@ -2,7 +2,7 @@ # Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml"). # This file should be checked into version control along with the pnpm-lock.yaml file. .npmrc=-2023857461 -package.json=-2113674231 -pnpm-lock.yaml=409413002 +package.json=-370577278 +pnpm-lock.yaml=997015112 pnpm-workspace.yaml=1711114604 -yarn.lock=1593491870 +yarn.lock=-987404687 diff --git a/WORKSPACE b/WORKSPACE index b5cd77f94fcb..c1f34c5866e9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -209,6 +209,17 @@ http_archive( url = "https://github.com/aspect-build/rules_rollup/releases/download/v2.0.0/rules_rollup-v2.0.0.tar.gz", ) +http_archive( + name = "aspect_rules_jasmine", + sha256 = "0d2f9c977842685895020cac721d8cc4f1b37aae15af46128cf619741dc61529", + strip_prefix = "rules_jasmine-2.0.0", + url = "https://github.com/aspect-build/rules_jasmine/releases/download/v2.0.0/rules_jasmine-v2.0.0.tar.gz", +) + +load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependencies") + +rules_jasmine_dependencies() + load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( diff --git a/package.json b/package.json index 4f545cbac13e..6e1b2c4843fc 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "tslint": "tslint -c tslint.json --project ./tsconfig.json", "stylelint": "stylelint \"src/**/*.+(css|scss)\" --config .stylelintrc.json", "resync-caretaker-app": "ts-node --project scripts/tsconfig.json scripts/caretaking/resync-caretaker-app-prs.ts", - "ts-circular-deps:check": "yarn -s ng-dev ts-circular-deps check --config ./src/circular-deps-test.conf.js", - "ts-circular-deps:approve": "yarn -s ng-dev ts-circular-deps approve --config ./src/circular-deps-test.conf.js", + "ts-circular-deps:check": "yarn -s ng-dev ts-circular-deps check --config ./src/circular-deps-test.conf.cjs", + "ts-circular-deps:approve": "yarn -s ng-dev ts-circular-deps approve --config ./src/circular-deps-test.conf.cjs", "merge": "yarn -s ng-dev pr merge", "approve-api": "node ./scripts/approve-api-golden.js", "approve-size-tests": "node ./scripts/approve-size-golden.js", @@ -134,6 +134,7 @@ "inquirer": "^8.2.0", "jasmine": "^4.1.0", "jasmine-core": "^4.1.0", + "jasmine-reporters": "^2.5.2", "jsonc-parser": "^3.0.0", "kagekiri": "^1.4.1", "karma": "^6.3.12", @@ -164,6 +165,7 @@ "semver": "^7.3.5", "send": "^0.17.2", "shelljs": "^0.8.5", + "source-map-support": "^0.5.21", "stylelint": "^14.14.0", "terser": "^5.10.0", "ts-node": "^10.9.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f184ad02a82f..30715704d51b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -248,6 +248,9 @@ importers: jasmine-core: specifier: ^4.1.0 version: 4.6.1 + jasmine-reporters: + specifier: ^2.5.2 + version: 2.5.2 jsonc-parser: specifier: ^3.0.0 version: 3.3.1 @@ -338,6 +341,9 @@ importers: shelljs: specifier: ^0.8.5 version: 0.8.5 + source-map-support: + specifier: ^0.5.21 + version: 0.5.21 stylelint: specifier: ^14.14.0 version: 14.16.1 diff --git a/src/BUILD.bazel b/src/BUILD.bazel index d6fdcdd2993c..b324cc433b24 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -1,5 +1,6 @@ load("@npm//@bazel/concatjs:index.bzl", "ts_config") load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config") +load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS") load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS") load("//tools/dgeni:index.bzl", "dgeni_api_docs") @@ -24,7 +25,16 @@ exports_files([ ts_config( name = "tsconfig-test", src = "bazel-tsconfig-test.json", - deps = ["bazel-tsconfig-build.json"], + deps = [ + "bazel-tsconfig-build.json", + "//:node_modules/@types/jasmine", + "//:node_modules/@types/node", + ], +) + +copy_to_bin( + name = "package_json", + srcs = ["package.json"], ) dgeni_api_docs( diff --git a/src/bazel-tsconfig-test.json b/src/bazel-tsconfig-test.json index 123be220a9b5..c0977fd9d7c9 100644 --- a/src/bazel-tsconfig-test.json +++ b/src/bazel-tsconfig-test.json @@ -5,7 +5,7 @@ "extends": "./bazel-tsconfig-build.json", "compilerOptions": { "importHelpers": true, - "types": ["jasmine"] + "types": ["jasmine", "node"] }, "bazelOptions": { "suppressTsconfigOverrideWarnings": true diff --git a/src/circular-deps-test.conf.js b/src/circular-deps-test.conf.cjs similarity index 100% rename from src/circular-deps-test.conf.js rename to src/circular-deps-test.conf.cjs diff --git a/src/material/core/theming/tests/BUILD.bazel b/src/material/core/theming/tests/BUILD.bazel index 3d5f466d8f1d..3e236dba3cd3 100644 --- a/src/material/core/theming/tests/BUILD.bazel +++ b/src/material/core/theming/tests/BUILD.bazel @@ -1,4 +1,5 @@ -load("//tools:defaults.bzl", "jasmine_node_test", "sass_binary", "ts_library") +load("//tools:defaults.bzl", "sass_binary") +load("//tools:defaults2.bzl", "jasmine_test", "ts_project") load("@bazel_skylib//rules:build_test.bzl", "build_test") package(default_visibility = ["//visibility:public"]) @@ -52,29 +53,29 @@ build_test( ], ) -ts_library( +ts_project( name = "unit_test_lib", testonly = True, srcs = glob([ "*.spec.ts", ]), - # TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`. - devmode_module = "commonjs", deps = [ - "//tools/postcss", - "//tools/sass:sass_lib", - "@npm//@bazel/runfiles", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//postcss", - "@npm//sass", + "//:node_modules/@bazel/runfiles", + "//:node_modules/postcss", + "//:node_modules/sass", + "//tools/postcss:postcss_rjs", + "//tools/sass:sass_lib_rjs", ], ) -jasmine_node_test( +jasmine_test( name = "unit_tests", - srcs = [":unit_test_lib"], data = [ + ":unit_test_lib_rjs", + "//src/material:sass_lib", + "//src/material-experimental:sass_lib", + ], + no_copy_to_bin = [ "//src/material:sass_lib", "//src/material-experimental:sass_lib", ], diff --git a/src/material/core/theming/tests/m3-theme.spec.ts b/src/material/core/theming/tests/m3-theme.spec.ts index fac03197a185..9729ac11daab 100644 --- a/src/material/core/theming/tests/m3-theme.spec.ts +++ b/src/material/core/theming/tests/m3-theme.spec.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import {parse} from 'postcss'; import {compileString} from 'sass'; -import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; +import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer.js'; // Note: For Windows compatibility, we need to resolve the directory paths through runfiles // which are guaranteed to reside in the source tree. diff --git a/src/material/core/theming/tests/theming-definition-api.spec.ts b/src/material/core/theming/tests/theming-definition-api.spec.ts index 626bf632d5e1..29c3a71b197b 100644 --- a/src/material/core/theming/tests/theming-definition-api.spec.ts +++ b/src/material/core/theming/tests/theming-definition-api.spec.ts @@ -3,7 +3,7 @@ import {compileString} from 'sass'; import {runfiles} from '@bazel/runfiles'; import * as path from 'path'; -import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; +import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer.js'; // Note: For Windows compatibility, we need to resolve the directory paths through runfiles // which are guaranteed to reside in the source tree. diff --git a/src/material/core/theming/tests/theming-inspection-api.spec.ts b/src/material/core/theming/tests/theming-inspection-api.spec.ts index 19c2372e3a9c..0da3e6853a0c 100644 --- a/src/material/core/theming/tests/theming-inspection-api.spec.ts +++ b/src/material/core/theming/tests/theming-inspection-api.spec.ts @@ -2,7 +2,7 @@ import {compileString} from 'sass'; import {runfiles} from '@bazel/runfiles'; import * as path from 'path'; -import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; +import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer.js'; // Note: For Windows compatibility, we need to resolve the directory paths through runfiles // which are guaranteed to reside in the source tree. diff --git a/src/material/core/theming/tests/theming-mixin-api.spec.ts b/src/material/core/theming/tests/theming-mixin-api.spec.ts index e10957624a7c..2ddcef420450 100644 --- a/src/material/core/theming/tests/theming-mixin-api.spec.ts +++ b/src/material/core/theming/tests/theming-mixin-api.spec.ts @@ -3,8 +3,8 @@ import {compileString} from 'sass'; import {runfiles} from '@bazel/runfiles'; import * as path from 'path'; -import {compareNodes} from '../../../../../tools/postcss/compare-nodes'; -import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; +import {compareNodes} from '../../../../../tools/postcss/compare-nodes.js'; +import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer.js'; // Note: For Windows compatibility, we need to resolve the directory paths through runfiles // which are guaranteed to reside in the source tree. diff --git a/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts b/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts index 3d2edd2b4907..abb408dda078 100644 --- a/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts +++ b/src/material/core/theming/tests/theming-typography-hierarchy.spec.ts @@ -2,7 +2,7 @@ import {compileString} from 'sass'; import {runfiles} from '@bazel/runfiles'; import * as path from 'path'; -import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; +import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer.js'; // Note: For Windows compatibility, we need to resolve the directory paths through runfiles // which are guaranteed to reside in the source tree. diff --git a/src/package.json b/src/package.json new file mode 100644 index 000000000000..3dbc1ca591c0 --- /dev/null +++ b/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/tools/defaults.bzl b/tools/defaults.bzl index b8b7a1d15baf..e8707662d57c 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -107,7 +107,8 @@ def ts_library( **kwargs ) - if module_name and not testonly: + # TODO(devversion): Partner with ISE team to support `rules_js` here. + if False and module_name and not testonly: _make_tsec_test(kwargs["name"]) def ng_module( @@ -147,7 +148,8 @@ def ng_module( **kwargs ) - if module_name and not testonly: + # TODO(devversion): Partner with ISE team to support `rules_js` here. + if False and module_name and not testonly: _make_tsec_test(kwargs["name"]) def ng_package(name, srcs = [], deps = [], externals = PKG_EXTERNALS, readme_md = None, visibility = None, **kwargs): diff --git a/tools/defaults2.bzl b/tools/defaults2.bzl index fbc5410b5134..30438f639922 100644 --- a/tools/defaults2.bzl +++ b/tools/defaults2.bzl @@ -1,3 +1,4 @@ +load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test") load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project") load("//tools/bazel:module_name.bzl", "compute_module_name") @@ -10,5 +11,28 @@ def ts_project( name, source_map = source_map, module_name = compute_module_name(testonly), + testonly = testonly, + **kwargs + ) + +def jasmine_test(data = [], args = [], **kwargs): + # Create relative path to root, from current package dir. Necessary as + # we change the `chdir` below to the package directory. + relative_to_root = "/".join([".."] * len(native.package_name().split("/"))) + + _jasmine_test( + node_modules = "//:node_modules", + chdir = native.package_name(), + args = [ + "--require=%s/node_modules/source-map-support/register.js" % relative_to_root, + "**/*spec.js", + "**/*spec.mjs", + "**/*spec.cjs", + ] + args, + data = data + [ + "//:node_modules/source-map-support", + # Needed to ensure code is recognized as ESM. + "//src:package_json", + ], **kwargs ) diff --git a/yarn.lock b/yarn.lock index 72dfbf33ccd6..732a8ba38a04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9514,7 +9514,7 @@ jasmine-core@~2.8.0: resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" integrity sha512-SNkOkS+/jMZvLhuSx1fjhcNWUC/KG6oVyFUGkSBEr9n1axSNduWU8GlI7suaHXr4yxjet6KjrUZxUTE5WzzWwQ== -jasmine-reporters@~2.5.0: +jasmine-reporters@^2.5.2, jasmine-reporters@~2.5.0: version "2.5.2" resolved "https://registry.yarnpkg.com/jasmine-reporters/-/jasmine-reporters-2.5.2.tgz#b5dfa1d9c40b8020c5225e0e1e2b9953d66a4d69" integrity sha512-qdewRUuFOSiWhiyWZX8Yx3YNQ9JG51ntBEO4ekLQRpktxFTwUHy24a86zD/Oi2BRTKksEdfWQZcQFqzjqIkPig== @@ -13557,7 +13557,7 @@ source-map-resolve@^0.6.0: atob "^2.1.2" decode-uri-component "^0.2.0" -source-map-support@0.5.21, source-map-support@^0.5.5, source-map-support@~0.5.20: +source-map-support@0.5.21, source-map-support@^0.5.21, source-map-support@^0.5.5, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== From 13f48fab27895223af5b3934d64558ea73cecf2d Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 20 Mar 2025 16:04:08 +0000 Subject: [PATCH 2/4] build: migrate more targets to `ts_project` This commit migrates more targets from `ts_library` to `ts_project`. --- .bazelrc | 2 +- integration/size-test/BUILD.bazel | 16 ++++++------- src/BUILD.bazel | 4 ++-- src/cdk-experimental/BUILD.bazel | 7 +++--- src/cdk-experimental/ui-patterns/BUILD.bazel | 10 ++++---- .../behaviors/event-manager/BUILD.bazel | 6 ++--- .../behaviors/list-focus/BUILD.bazel | 9 ++++---- .../behaviors/list-navigation/BUILD.bazel | 9 ++++---- .../behaviors/list-selection/BUILD.bazel | 11 +++++---- .../behaviors/list-typeahead/BUILD.bazel | 11 +++++---- .../behaviors/signal-like/BUILD.bazel | 4 ++-- .../ui-patterns/listbox/BUILD.bazel | 18 +++++++-------- src/cdk/BUILD.bazel | 7 +++--- src/cdk/coercion/BUILD.bazel | 14 +++++------ src/cdk/keycodes/BUILD.bazel | 11 +++++---- src/cdk/testing/private/BUILD.bazel | 12 ++++++---- src/cdk/testing/protractor/BUILD.bazel | 10 ++++---- .../testing/selenium-webdriver/BUILD.bazel | 12 ++++++---- src/cdk/testing/testbed/BUILD.bazel | 13 +++++++---- src/cdk/testing/tests/BUILD.bazel | 23 ++++++++++--------- src/components-examples/private/BUILD.bazel | 12 ++++++---- src/google-maps/testing/BUILD.bazel | 12 ++++++---- src/material/BUILD.bazel | 5 ++-- src/material/autocomplete/testing/BUILD.bazel | 7 +++--- src/material/badge/testing/BUILD.bazel | 7 +++--- tools/bazel/ts_project_interop.bzl | 13 ----------- 26 files changed, 138 insertions(+), 127 deletions(-) diff --git a/.bazelrc b/.bazelrc index 235349ee660e..34647d8f37ec 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,7 +11,7 @@ common --@aspect_rules_ts//ts:default_to_tsc_transpiler # https://github.com/bazelbuild/rules_typescript/issues/12 which affects the common case of # having `tsconfig.json` in the WORKSPACE directory. Instead, you should run # `bazel info output_base` to find out where the outputs went. -build --symlink_prefix=/ +build --symlink_prefix=dist/ # Performance: avoid stat'ing input files build --watchfs diff --git a/integration/size-test/BUILD.bazel b/integration/size-test/BUILD.bazel index 41db55a67cf5..4f2f95d39341 100644 --- a/integration/size-test/BUILD.bazel +++ b/integration/size-test/BUILD.bazel @@ -1,5 +1,5 @@ load("@npm//@bazel/esbuild:index.bzl", "esbuild_config") -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -19,16 +19,14 @@ esbuild_config( ], ) -ts_library( +ts_project( name = "check-size", srcs = ["check-size.ts"], - # TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`. - devmode_module = "commonjs", deps = [ - "@npm//@bazel/runfiles", - "@npm//@types/node", - "@npm//@types/yaml", - "@npm//chalk", - "@npm//yaml", + "//:node_modules/@bazel/runfiles", + "//:node_modules/@types/node", + "//:node_modules/@types/yaml", + "//:node_modules/chalk", + "//:node_modules/yaml", ], ) diff --git a/src/BUILD.bazel b/src/BUILD.bazel index b324cc433b24..ddae46fb16f9 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -4,7 +4,7 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS") load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS") load("//tools/dgeni:index.bzl", "dgeni_api_docs") -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -56,7 +56,7 @@ dgeni_api_docs( tags = ["docs-package"], ) -ts_library( +ts_project( name = "dev_mode_types", srcs = ["dev-mode-types.d.ts"], ) diff --git a/src/cdk-experimental/BUILD.bazel b/src/cdk-experimental/BUILD.bazel index f9804d89bcb9..e3b41c7f03eb 100644 --- a/src/cdk-experimental/BUILD.bazel +++ b/src/cdk-experimental/BUILD.bazel @@ -1,15 +1,16 @@ load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_TARGETS") -load("//tools:defaults.bzl", "ng_package", "ts_library") +load("//tools:defaults.bzl", "ng_package") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "cdk-experimental", srcs = glob( ["*.ts"], exclude = ["**/*.spec.ts"], ), - deps = ["@npm//@angular/core"], + deps = ["//:node_modules/@angular/core"], ) ng_package( diff --git a/src/cdk-experimental/ui-patterns/BUILD.bazel b/src/cdk-experimental/ui-patterns/BUILD.bazel index e9a32359e012..eaed798277af 100644 --- a/src/cdk-experimental/ui-patterns/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/BUILD.bazel @@ -1,16 +1,16 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "ui-patterns", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", - "//src/cdk-experimental/ui-patterns/listbox", - "@npm//@angular/core", + "//:node_modules/@angular/core", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", + "//src/cdk-experimental/ui-patterns/listbox:listbox_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/event-manager/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/event-manager/BUILD.bazel index 563b0ff1ba15..e2682f2952a4 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/event-manager/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/event-manager/BUILD.bazel @@ -1,14 +1,14 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "event-manager", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/list-focus/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/list-focus/BUILD.bazel index 37bda0ab9d97..b5ee34e7ee2a 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/list-focus/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/list-focus/BUILD.bazel @@ -1,16 +1,17 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "list-focus", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/list-navigation", - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", + "//src/cdk-experimental/ui-patterns/behaviors/list-navigation:list-navigation_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/list-navigation/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/list-navigation/BUILD.bazel index 9bf541fbe517..b65828fec5c2 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/list-navigation/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/list-navigation/BUILD.bazel @@ -1,16 +1,17 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "list-navigation", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", - "@npm//@angular/core", + "//:node_modules/@angular/core", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/list-selection/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/list-selection/BUILD.bazel index fad8ca69513d..706019611729 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/list-selection/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/list-selection/BUILD.bazel @@ -1,17 +1,18 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "list-selection", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/list-navigation", - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", - "@npm//@angular/core", + "//:node_modules/@angular/core", + "//src/cdk-experimental/ui-patterns/behaviors/list-navigation:list-navigation_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/list-typeahead/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/list-typeahead/BUILD.bazel index 9c415122deb3..f7b3e5b768d8 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/list-typeahead/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/list-typeahead/BUILD.bazel @@ -1,17 +1,18 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "list-typeahead", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/list-navigation", - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", - "@npm//@angular/core", + "//:node_modules/@angular/core", + "//src/cdk-experimental/ui-patterns/behaviors/list-navigation:list-navigation_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk-experimental/ui-patterns/behaviors/signal-like/BUILD.bazel b/src/cdk-experimental/ui-patterns/behaviors/signal-like/BUILD.bazel index 47d463668358..e64b0007568b 100644 --- a/src/cdk-experimental/ui-patterns/behaviors/signal-like/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/behaviors/signal-like/BUILD.bazel @@ -1,8 +1,8 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "signal-like", srcs = ["signal-like.ts"], deps = [], diff --git a/src/cdk-experimental/ui-patterns/listbox/BUILD.bazel b/src/cdk-experimental/ui-patterns/listbox/BUILD.bazel index 9d68e2822333..00b3dd6c0603 100644 --- a/src/cdk-experimental/ui-patterns/listbox/BUILD.bazel +++ b/src/cdk-experimental/ui-patterns/listbox/BUILD.bazel @@ -1,20 +1,20 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "listbox", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "//src/cdk-experimental/ui-patterns/behaviors/event-manager", - "//src/cdk-experimental/ui-patterns/behaviors/list-focus", - "//src/cdk-experimental/ui-patterns/behaviors/list-navigation", - "//src/cdk-experimental/ui-patterns/behaviors/list-selection", - "//src/cdk-experimental/ui-patterns/behaviors/list-typeahead", - "//src/cdk-experimental/ui-patterns/behaviors/signal-like", - "@npm//@angular/core", + "//:node_modules/@angular/core", + "//src/cdk-experimental/ui-patterns/behaviors/event-manager:event-manager_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/list-focus:list-focus_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/list-navigation:list-navigation_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/list-selection:list-selection_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/list-typeahead:list-typeahead_rjs", + "//src/cdk-experimental/ui-patterns/behaviors/signal-like:signal-like_rjs", ], ) diff --git a/src/cdk/BUILD.bazel b/src/cdk/BUILD.bazel index 41f22fa3e977..68bff715317e 100644 --- a/src/cdk/BUILD.bazel +++ b/src/cdk/BUILD.bazel @@ -1,15 +1,16 @@ load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS", "CDK_ENTRYPOINTS_WITH_STYLES", "CDK_SCSS_LIBS", "CDK_TARGETS") -load("//tools:defaults.bzl", "ng_package", "sass_library", "ts_library") +load("//tools:defaults.bzl", "ng_package", "sass_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "cdk", srcs = glob( ["*.ts"], exclude = ["**/*.spec.ts"], ), - deps = ["@npm//@angular/core"], + deps = ["//:node_modules/@angular/core"], ) # List of style files that need to be copied to the root of the CDK package. We do this diff --git a/src/cdk/coercion/BUILD.bazel b/src/cdk/coercion/BUILD.bazel index c6887bee13c6..99c194d71144 100644 --- a/src/cdk/coercion/BUILD.bazel +++ b/src/cdk/coercion/BUILD.bazel @@ -1,19 +1,20 @@ -load("//tools:defaults.bzl", "karma_web_test_suite", "markdown_to_html", "ts_library") +load("//tools:defaults.bzl", "karma_web_test_suite", "markdown_to_html") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "coercion", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), deps = [ - "@npm//@angular/core", + "//:node_modules/@angular/core", ], ) -ts_library( +ts_project( name = "unit_test_sources", testonly = True, srcs = glob( @@ -21,9 +22,8 @@ ts_library( exclude = ["**/*.e2e.spec.ts"], ), deps = [ - ":coercion", - "@npm//@angular/core", - "@npm//@types/jasmine", + ":coercion_rjs", + "//:node_modules/@angular/core", ], ) diff --git a/src/cdk/keycodes/BUILD.bazel b/src/cdk/keycodes/BUILD.bazel index 5fb355a70006..c7c4a1198f02 100644 --- a/src/cdk/keycodes/BUILD.bazel +++ b/src/cdk/keycodes/BUILD.bazel @@ -1,4 +1,5 @@ -load("//tools:defaults.bzl", "karma_web_test_suite", "markdown_to_html", "ng_module", "ts_library") +load("//tools:defaults.bzl", "karma_web_test_suite", "markdown_to_html", "ng_module") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -14,17 +15,19 @@ ng_module( ), ) -ts_library( +ts_project( name = "unit_test_sources", testonly = True, srcs = glob( ["**/*.spec.ts"], exclude = ["**/*.e2e.spec.ts"], ), - deps = [ + interop_deps = [ ":keycodes", "//src/cdk/testing/private", - "@npm//@types/jasmine", + ], + deps = [ + "//:node_modules/@types/jasmine", ], ) diff --git a/src/cdk/testing/private/BUILD.bazel b/src/cdk/testing/private/BUILD.bazel index fb1b5b5212eb..2b46e900eed2 100644 --- a/src/cdk/testing/private/BUILD.bazel +++ b/src/cdk/testing/private/BUILD.bazel @@ -1,17 +1,19 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "private", testonly = True, srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/testing/testbed", - "@npm//@angular/core", - "@npm//@types/jasmine", + ], + deps = [ + "//:node_modules/@angular/core", + "//:node_modules/@types/jasmine", ], ) diff --git a/src/cdk/testing/protractor/BUILD.bazel b/src/cdk/testing/protractor/BUILD.bazel index 53d5a5ebfb03..043383573e7b 100644 --- a/src/cdk/testing/protractor/BUILD.bazel +++ b/src/cdk/testing/protractor/BUILD.bazel @@ -1,16 +1,18 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "protractor", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/testing", - "@npm//protractor", + ], + deps = [ + "//:node_modules/protractor", ], ) diff --git a/src/cdk/testing/selenium-webdriver/BUILD.bazel b/src/cdk/testing/selenium-webdriver/BUILD.bazel index 2835524b0b01..9163d54678e2 100644 --- a/src/cdk/testing/selenium-webdriver/BUILD.bazel +++ b/src/cdk/testing/selenium-webdriver/BUILD.bazel @@ -1,17 +1,19 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "selenium-webdriver", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/testing", - "@npm//@types/selenium-webdriver", - "@npm//selenium-webdriver", + ], + deps = [ + "//:node_modules/@types/selenium-webdriver", + "//:node_modules/selenium-webdriver", ], ) diff --git a/src/cdk/testing/testbed/BUILD.bazel b/src/cdk/testing/testbed/BUILD.bazel index b5379ee56797..65980379140b 100644 --- a/src/cdk/testing/testbed/BUILD.bazel +++ b/src/cdk/testing/testbed/BUILD.bazel @@ -1,18 +1,21 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "testbed", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/keycodes", "//src/cdk/testing", - "@npm//@angular/core", - "@npm//rxjs", + ], + deps = [ + "//:node_modules/@angular/core", + "//:node_modules/rxjs", ], ) diff --git a/src/cdk/testing/tests/BUILD.bazel b/src/cdk/testing/tests/BUILD.bazel index 39f630381694..115a65df68d1 100644 --- a/src/cdk/testing/tests/BUILD.bazel +++ b/src/cdk/testing/tests/BUILD.bazel @@ -1,4 +1,5 @@ -load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ts_library") +load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -20,10 +21,10 @@ ng_module( ], ) -ts_library( +ts_project( name = "test_harnesses", srcs = glob(["harnesses/**/*.ts"]), - deps = [ + interop_deps = [ "//src/cdk/testing", ], ) @@ -78,20 +79,20 @@ ng_e2e_test_library( ], ) -ts_library( +ts_project( name = "webdriver_test_sources", testonly = True, srcs = ["webdriver.e2e.spec.ts"], - # TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`. - devmode_module = "commonjs", - deps = [ + interop_deps = [ ":cross_environment_specs", ":test_harnesses", "//src/cdk/testing", "//src/cdk/testing/selenium-webdriver", - "@npm//@bazel/runfiles", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//@types/selenium-webdriver", + ], + deps = [ + "//:node_modules/@bazel/runfiles", + "//:node_modules/@types/jasmine", + "//:node_modules/@types/node", + "//:node_modules/@types/selenium-webdriver", ], ) diff --git a/src/components-examples/private/BUILD.bazel b/src/components-examples/private/BUILD.bazel index 6b0a0abf7b30..56753e687609 100644 --- a/src/components-examples/private/BUILD.bazel +++ b/src/components-examples/private/BUILD.bazel @@ -1,17 +1,19 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "private", srcs = glob(["*.ts"]), - deps = [ + interop_deps = [ "//src/components-examples", - "@npm//@angular/core", + ], + deps = [ + "//:node_modules/@angular/core", ], ) -ts_library( +ts_project( name = "localize_types", srcs = ["localize-types.d.ts"], ) diff --git a/src/google-maps/testing/BUILD.bazel b/src/google-maps/testing/BUILD.bazel index 415807b6a3b6..2f31d31981cf 100644 --- a/src/google-maps/testing/BUILD.bazel +++ b/src/google-maps/testing/BUILD.bazel @@ -1,14 +1,16 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "testing", testonly = True, srcs = glob(["**/*.ts"]), - deps = [ + interop_deps = [ "//src/google-maps", - "@npm//@types/google.maps", - "@npm//@types/jasmine", + ], + deps = [ + "//:node_modules/@types/google.maps", + "//:node_modules/@types/jasmine", ], ) diff --git a/src/material/BUILD.bazel b/src/material/BUILD.bazel index eb248fe7e30c..5b402621d38f 100644 --- a/src/material/BUILD.bazel +++ b/src/material/BUILD.bazel @@ -5,11 +5,12 @@ load( "MATERIAL_TARGETS", "MATERIAL_TESTING_TARGETS", ) -load("//tools:defaults.bzl", "ng_package", "sass_library", "ts_library") +load("//tools:defaults.bzl", "ng_package", "sass_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "material", srcs = ["index.ts"], ) diff --git a/src/material/autocomplete/testing/BUILD.bazel b/src/material/autocomplete/testing/BUILD.bazel index de2a2bc59400..34e93ade6416 100644 --- a/src/material/autocomplete/testing/BUILD.bazel +++ b/src/material/autocomplete/testing/BUILD.bazel @@ -1,14 +1,15 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "testing", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/coercion", "//src/cdk/testing", "//src/material/core/testing", diff --git a/src/material/badge/testing/BUILD.bazel b/src/material/badge/testing/BUILD.bazel index c04825a62a99..8b9b236b7c92 100644 --- a/src/material/badge/testing/BUILD.bazel +++ b/src/material/badge/testing/BUILD.bazel @@ -1,14 +1,15 @@ -load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library") +load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "testing", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/testing", "//src/material/badge", ], diff --git a/tools/bazel/ts_project_interop.bzl b/tools/bazel/ts_project_interop.bzl index 0827437a1841..72e4f28e64cb 100644 --- a/tools/bazel/ts_project_interop.bzl +++ b/tools/bazel/ts_project_interop.bzl @@ -2,7 +2,6 @@ load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info") load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project") load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "JSEcmaScriptModuleInfo", "JSModuleInfo", "LinkablePackageInfo") load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test") -load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "LinkerPackageMappingInfo") def _ts_deps_interop_impl(ctx): types = [] @@ -82,18 +81,6 @@ def _ts_project_module_impl(ctx): files = info.sources, ), ) - providers.append( - LinkerPackageMappingInfo( - mappings = depset([ - struct( - package_name = ctx.attr.module_name, - package_path = "", - link_path = ctx.label.package, - ), - ]), - node_modules_roots = depset([]), - ), - ) return providers From 47015aa2ccfd98bf6ea491dcd5729da7a9a231a4 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 24 Mar 2025 07:27:24 +0000 Subject: [PATCH 3/4] build: include `src/cdk` in pnpm workspace This will allow pnpm to identifiy dependencies like `parse5` to be understood as non-dev dependencies, so that they are propagated with `rules_js` even when `cdk` is linked as `npm_package`. This is necessary when using the npm package of CDK in the Material schematic tests. To do this we need to give up on our non-statically readable substitutions for tslib and RxJS but this is acceptable as those don't change often and the benefits of the pnpm workspace are more important. We move `parse5` from `optionalDependencies` to `dependencies` so that pnpm recognizes this as non-dev dependency for the runtime execution of the CDK package. `parse5` doesn't have any native code, so `optionalDependencies` vs `dependencies` doesn't make a difference. Long-term we should consider simply bundling `parse5` here. --- .../npm_translate_lock_MzA5NzUwNzMx | 5 +- .bazelignore | 2 + .npmrc | 5 + WORKSPACE | 1 + packages.bzl | 10 -- pnpm-lock.yaml | 126 ++++++------------ src/cdk-experimental/package.json | 2 +- src/cdk/package.json | 8 +- src/components-examples/package.json | 2 +- src/google-maps/package.json | 4 +- src/material-date-fns-adapter/package.json | 2 +- src/material-experimental/package.json | 2 +- src/material-luxon-adapter/package.json | 2 +- src/material-moment-adapter/package.json | 2 +- src/material/package.json | 4 +- src/material/schematics/BUILD.bazel | 30 ++--- src/youtube-player/package.json | 4 +- 17 files changed, 84 insertions(+), 127 deletions(-) diff --git a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx index ac510797bf17..10eb2f36298c 100755 --- a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx +++ b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx @@ -1,8 +1,9 @@ # @generated # Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml"). # This file should be checked into version control along with the pnpm-lock.yaml file. -.npmrc=-2023857461 +.npmrc=-1406867100 package.json=-370577278 -pnpm-lock.yaml=997015112 +pnpm-lock.yaml=-1162470554 pnpm-workspace.yaml=1711114604 +src/cdk/package.json=-908433069 yarn.lock=-987404687 diff --git a/.bazelignore b/.bazelignore index 8acf7d2bfa0c..4090f06d7091 100644 --- a/.bazelignore +++ b/.bazelignore @@ -17,3 +17,5 @@ integration/yarn-pnp-compat/.yarn/cache integration/yarn-pnp-compat/.yarn/unplugged integration/yarn-pnp-compat/.yarn/install-state.gz integration/yarn-pnp-compat/node_modules + +src/cdk/node_modules diff --git a/.npmrc b/.npmrc index b8d41f41d029..7c7738880a15 100644 --- a/.npmrc +++ b/.npmrc @@ -5,3 +5,8 @@ engine-strict = false # projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what # rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules) hoist=false + +# Avoid pnpm auto-installing peer dependencies. We want to be explicit about our versions used +# for peer dependencies, avoiding potential mismatches. In addition, it ensures we can continue +# to rely on peer dependency placeholders substituted via Bazel. +auto-install-peers=false diff --git a/WORKSPACE b/WORKSPACE index c1f34c5866e9..bfb2e263912a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -175,6 +175,7 @@ npm_translate_lock( data = [ "//:package.json", "//:pnpm-workspace.yaml", + "//src/cdk:package.json", ], npmrc = "//:.npmrc", pnpm_lock = "//:pnpm-lock.yaml", diff --git a/packages.bzl b/packages.bzl index 71734420cc6f..31100e528fb3 100644 --- a/packages.bzl +++ b/packages.bzl @@ -1,9 +1,3 @@ -# Each individual package uses a placeholder for the version of Angular to ensure they're -# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate -# version for the placeholders. -TSLIB_PACKAGE_VERSION = "^2.3.0" -RXJS_PACKAGE_VERSION = "^6.5.3 || ^7.4.0" - # Packages which are versioned together on npm ANGULAR_COMPONENTS_SCOPED_PACKAGES = ["@angular/%s" % p for p in [ "material", @@ -27,12 +21,8 @@ PKG_GROUP_REPLACEMENTS = { NPM_PACKAGE_SUBSTITUTIONS = dict(PKG_GROUP_REPLACEMENTS, **{ # Peer dependency version on the Angular framework. "0.0.0-NG": "{STABLE_FRAMEWORK_PEER_DEP_RANGE}", - # Version of `tslib` - "0.0.0-TSLIB": TSLIB_PACKAGE_VERSION, # Version of the local package being built, generated via the `--workspace_status_command` flag. "0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}", - # Version of `rxjs` - "0.0.0-RXJS": RXJS_PACKAGE_VERSION, }) NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30715704d51b..918f0967b744 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: '6.0' settings: - autoInstallPeers: true + autoInstallPeers: false excludeLinksFromLockfile: false onlyBuiltDependencies: [] @@ -58,7 +58,7 @@ importers: devDependencies: '@angular-devkit/build-angular': specifier: ^20.0.0-next.2 - version: 20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@16.18.101)(browser-sync@2.26.13)(karma@6.4.3)(protractor@7.0.0)(typescript@5.8.2)(vite@6.2.2)(yaml@1.10.2) + version: 20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@16.18.101)(browser-sync@2.26.13)(karma@6.4.3)(protractor@7.0.0)(typescript@5.8.2)(yaml@1.10.2) '@angular-devkit/core': specifier: ^20.0.0-next.2 version: 20.0.0-next.2 @@ -73,7 +73,7 @@ importers: version: 20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@16.18.101)(karma@6.4.3)(less@4.2.2)(postcss@8.5.3)(terser@5.39.0)(typescript@5.8.2)(yaml@1.10.2) '@angular/build-tooling': specifier: https://github.com/angular/dev-infra-private-build-tooling-builds.git#ec9df12469082e3cb087a9af55072dc2d833c73f - version: github.com/angular/dev-infra-private-build-tooling-builds/ec9df12469082e3cb087a9af55072dc2d833c73f(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(less@4.2.2)(postcss@8.5.3)(rxjs@6.6.7)(terser@5.39.0)(yaml@1.10.2)(zone.js@0.15.0) + version: github.com/angular/dev-infra-private-build-tooling-builds/ec9df12469082e3cb087a9af55072dc2d833c73f(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(postcss@8.5.3)(rxjs@6.6.7)(terser@5.39.0)(yaml@1.10.2)(zone.js@0.15.0) '@angular/cli': specifier: ^20.0.0-next.2 version: 20.0.0-next.2(@types/node@16.18.101) @@ -112,7 +112,7 @@ importers: version: 6.1.2 '@bazel/concatjs': specifier: 5.8.1 - version: 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) + version: 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) '@bazel/esbuild': specifier: 5.8.1 version: 5.8.1 @@ -410,7 +410,7 @@ packages: - chokidar dev: true - /@angular-devkit/build-angular@20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@16.18.101)(browser-sync@2.26.13)(karma@6.4.3)(protractor@7.0.0)(typescript@5.8.2)(vite@6.2.2)(yaml@1.10.2): + /@angular-devkit/build-angular@20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@16.18.101)(browser-sync@2.26.13)(karma@6.4.3)(protractor@7.0.0)(typescript@5.8.2)(yaml@1.10.2): resolution: {integrity: sha512-0uKksY0jYd4jOveWfA6BPRJYtrUBOpcOYeTbDei5Eg637JzP3dLxCGbaBThIneVB1XIQOLm9IZoqnFAUBteSFA==} engines: {node: ^20.11.1 || >=22.0.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} peerDependencies: @@ -473,7 +473,7 @@ packages: '@babel/runtime': 7.26.10 '@discoveryjs/json-ext': 0.6.3 '@ngtools/webpack': 20.0.0-next.2(@angular/compiler-cli@20.0.0-next.3)(typescript@5.8.2)(webpack@5.98.0) - '@vitejs/plugin-basic-ssl': 2.0.0(vite@6.2.2) + '@vitejs/plugin-basic-ssl': 2.0.0(vite@6.2.0) ansi-colors: 4.1.3 autoprefixer: 10.4.21(postcss@8.5.3) babel-loader: 10.0.0(@babel/core@7.26.10)(webpack@5.98.0) @@ -511,7 +511,7 @@ packages: tree-kill: 1.2.2 tslib: 2.8.1 typescript: 5.8.2 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) webpack-dev-middleware: 7.4.2(webpack@5.98.0) webpack-dev-server: 5.2.0(webpack@5.98.0) webpack-merge: 6.0.1 @@ -551,7 +551,7 @@ packages: dependencies: '@angular-devkit/architect': 0.2000.0-next.2 rxjs: 7.8.2 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) webpack-dev-server: 5.2.0(webpack@5.98.0) transitivePeerDependencies: - chokidar @@ -567,7 +567,7 @@ packages: optional: true dependencies: ajv: 8.17.1 - ajv-formats: 3.0.1(ajv@8.17.1) + ajv-formats: 3.0.1 jsonc-parser: 3.3.1 picomatch: 4.0.2 rxjs: 7.8.2 @@ -584,7 +584,7 @@ packages: optional: true dependencies: ajv: 8.17.1 - ajv-formats: 3.0.1(ajv@8.17.1) + ajv-formats: 3.0.1 jsonc-parser: 3.3.1 picomatch: 4.0.2 rxjs: 7.8.2 @@ -627,7 +627,7 @@ packages: - zone.js dev: true - /@angular/build@20.0.0-next.0(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@20.17.24)(karma@6.4.3)(less@4.2.2)(postcss@8.5.3)(terser@5.39.0)(typescript@5.8.2)(yaml@1.10.2): + /@angular/build@20.0.0-next.0(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@20.17.24)(karma@6.4.3)(postcss@8.5.3)(terser@5.39.0)(typescript@5.8.2)(yaml@1.10.2): resolution: {integrity: sha512-8Cu4smOcsxC+/jecUkS7W5sdiD1XTby7KA3Fi77KpBJAjNLNMHVFh/zZkALVYoG/Uyy7wcQAg/3yo6/7g0WDkA==} engines: {node: ^20.11.1 || >=22.0.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} peerDependencies: @@ -681,7 +681,6 @@ packages: https-proxy-agent: 5.0.0(supports-color@10.0.0) istanbul-lib-instrument: 6.0.3 karma: 6.4.3 - less: 4.2.2 listr2: 8.2.5 magic-string: 0.30.17 mrmime: 2.0.1 @@ -695,7 +694,7 @@ packages: source-map-support: 0.5.21 tinyglobby: 0.2.12 typescript: 5.8.2 - vite: 6.2.0(@types/node@20.17.24)(less@4.2.2)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2) + vite: 6.2.0(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2) watchpack: 2.4.2 optionalDependencies: lmdb: 3.2.6 @@ -2168,7 +2167,7 @@ packages: hasBin: true dev: true - /@bazel/concatjs@5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2): + /@bazel/concatjs@5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2): resolution: {integrity: sha512-TkARsNUxgi3bjFeGwIGlffmQglNhuR9qK9uE7uKhdBZvQE5caAWVCjYiMTzo3viKDhwKn5QNRcHY5huuJMVFfA==} hasBin: true peerDependencies: @@ -2184,7 +2183,6 @@ packages: karma-chrome-launcher: 3.2.0 karma-firefox-launcher: 2.1.3 karma-jasmine: 4.0.2(karma@6.4.3) - karma-junit-reporter: 2.0.1(karma@6.4.3) karma-requirejs: 1.1.0(karma@6.4.3)(requirejs@2.3.6) karma-sourcemap-loader: 0.3.8 protobufjs: 6.8.8 @@ -3763,7 +3761,7 @@ packages: dependencies: '@angular/compiler-cli': 20.0.0-next.3(@angular/compiler@20.0.0-next.3)(typescript@5.8.2) typescript: 5.8.2 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /@nodelib/fs.scandir@2.1.5: @@ -4636,7 +4634,7 @@ packages: '@types/node': 16.18.101 ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) - ajv-formats: 3.0.1(ajv@8.13.0) + ajv-formats: 3.0.1 fs-extra: 11.3.0 import-lazy: 4.0.0 jju: 1.4.0 @@ -4655,7 +4653,7 @@ packages: '@types/node': 20.17.24 ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) - ajv-formats: 3.0.1(ajv@8.13.0) + ajv-formats: 3.0.1 fs-extra: 11.3.0 import-lazy: 4.0.0 jju: 1.4.0 @@ -5275,7 +5273,7 @@ packages: peerDependencies: vite: ^6.0.0 dependencies: - vite: 6.2.0(@types/node@20.17.24)(less@4.2.2)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2) + vite: 6.2.0(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2) dev: true /@vitejs/plugin-basic-ssl@2.0.0(vite@6.2.2): @@ -5531,35 +5529,14 @@ packages: ajv: 8.13.0 dev: true - /ajv-formats@2.1.1(ajv@8.17.1): + /ajv-formats@2.1.1: resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true dependencies: ajv: 8.17.1 dev: true - /ajv-formats@3.0.1(ajv@8.13.0): + /ajv-formats@3.0.1: resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true - dependencies: - ajv: 8.13.0 - dev: true - - /ajv-formats@3.0.1(ajv@8.17.1): - resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true dependencies: ajv: 8.17.1 dev: true @@ -5919,7 +5896,7 @@ packages: dependencies: '@babel/core': 7.26.10 find-up: 5.0.0 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /babel-plugin-polyfill-corejs2@0.4.11(@babel/core@7.26.10): @@ -7069,7 +7046,7 @@ packages: schema-utils: 4.3.0 serialize-javascript: 6.0.2 tinyglobby: 0.2.12 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /core-js-compat@3.40.0: @@ -7205,7 +7182,7 @@ packages: postcss-modules-values: 4.0.0(postcss@8.5.3) postcss-value-parser: 4.2.0 semver: 7.7.1 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /css-select@5.1.0: @@ -10563,17 +10540,6 @@ packages: karma: 6.4.3 dev: true - /karma-junit-reporter@2.0.1(karma@6.4.3): - resolution: {integrity: sha512-VtcGfE0JE4OE1wn0LK8xxDKaTP7slN8DO3I+4xg6gAi1IoAHAXOJ1V9G/y45Xg6sxdxPOR3THCFtDlAfBo9Afw==} - engines: {node: '>= 8'} - peerDependencies: - karma: '>=0.9' - dependencies: - karma: 6.4.3 - path-is-absolute: 1.0.1 - xmlbuilder: 12.0.0 - dev: true - /karma-parallel@0.3.1(karma@6.4.3): resolution: {integrity: sha512-64jxNYamYi/9Y67h4+FfViSYhwDgod3rLuq+ZdZ0c3XeZFp/3q3v3HVkd8b5Czp3hCB+LLF8DIv4zlR4xFqbRw==} engines: {node: '>=6'} @@ -10714,7 +10680,7 @@ packages: optional: true dependencies: less: 4.2.2 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /less@4.2.2: @@ -10756,7 +10722,7 @@ packages: webpack: optional: true dependencies: - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) webpack-sources: 3.2.3 dev: true @@ -11351,7 +11317,7 @@ packages: dependencies: schema-utils: 4.3.0 tapable: 2.2.1 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /minimalistic-assert@1.0.1: @@ -12455,7 +12421,7 @@ packages: jiti: 1.21.6 postcss: 8.5.3 semver: 7.7.1 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) transitivePeerDependencies: - typescript dev: true @@ -13535,7 +13501,7 @@ packages: dependencies: neo-async: 2.6.2 sass: 1.86.0 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /sass@1.85.1: @@ -13580,7 +13546,7 @@ packages: dependencies: '@types/json-schema': 7.0.15 ajv: 8.17.1 - ajv-formats: 2.1.1(ajv@8.17.1) + ajv-formats: 2.1.1 ajv-keywords: 5.1.0(ajv@8.17.1) dev: true @@ -14112,7 +14078,7 @@ packages: dependencies: iconv-lite: 0.6.3 source-map-js: 1.2.1 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /source-map-resolve@0.6.0: @@ -14699,7 +14665,7 @@ packages: engines: {node: '>=8'} dev: true - /terser-webpack-plugin@5.3.11(esbuild@0.17.19)(webpack@5.98.0): + /terser-webpack-plugin@5.3.11(esbuild@0.25.1)(webpack@5.98.0): resolution: {integrity: sha512-RVCsMfuD0+cTt3EwX8hSl2Ks56EbFHWmhluwcqoPKtBnfjiT6olaq7PRIRfhyU8nnC2MrnDrBLfrD/RGE+cVXQ==} engines: {node: '>= 10.13.0'} peerDependencies: @@ -14716,12 +14682,12 @@ packages: optional: true dependencies: '@jridgewell/trace-mapping': 0.3.25 - esbuild: 0.17.19 + esbuild: 0.25.1 jest-worker: 27.5.1 schema-utils: 4.3.0 serialize-javascript: 6.0.2 terser: 5.39.0 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /terser@5.39.0: @@ -14948,7 +14914,7 @@ packages: typescript: 5.8.2 dependencies: '@bazel/bazelisk': 1.12.1 - '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) + '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) glob: 7.2.3 minimatch: 3.1.2 typescript: 5.8.2 @@ -15458,7 +15424,7 @@ packages: vfile-message: 1.1.1 dev: true - /vite@6.2.0(@types/node@20.17.24)(less@4.2.2)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2): + /vite@6.2.0(@types/node@20.17.24)(sass@1.85.1)(terser@5.39.0)(yaml@1.10.2): resolution: {integrity: sha512-7dPxoo+WsT/64rDcwoOjk76XHj+TqNTIvHKcuMQ1k4/SeHDaQt5GFAeLYzrimZrMpn/O6DtdI03WUjdxuPM0oQ==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true @@ -15500,7 +15466,6 @@ packages: dependencies: '@types/node': 20.17.24 esbuild: 0.25.1 - less: 4.2.2 postcss: 8.5.3 rollup: 4.36.0 sass: 1.85.1 @@ -15666,7 +15631,7 @@ packages: on-finished: 2.4.1 range-parser: 1.2.1 schema-utils: 4.3.0 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true /webpack-dev-server@5.2.0(webpack@5.98.0): @@ -15707,7 +15672,7 @@ packages: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) webpack-dev-middleware: 7.4.2(webpack@5.98.0) ws: 8.18.0 transitivePeerDependencies: @@ -15742,10 +15707,10 @@ packages: optional: true dependencies: typed-assert: 1.0.9 - webpack: 5.98.0(esbuild@0.17.19) + webpack: 5.98.0(esbuild@0.25.1) dev: true - /webpack@5.98.0(esbuild@0.17.19): + /webpack@5.98.0(esbuild@0.25.1): resolution: {integrity: sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA==} engines: {node: '>=10.13.0'} hasBin: true @@ -15775,7 +15740,7 @@ packages: neo-async: 2.6.2 schema-utils: 4.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.11(esbuild@0.17.19)(webpack@5.98.0) + terser-webpack-plugin: 5.3.11(esbuild@0.25.1)(webpack@5.98.0) watchpack: 2.4.2 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -16016,11 +15981,6 @@ packages: engines: {node: '>=4.0'} dev: true - /xmlbuilder@12.0.0: - resolution: {integrity: sha512-lMo8DJ8u6JRWp0/Y4XLa/atVDr75H9litKlb2E5j3V3MesoL50EBgZDWoLT3F/LztVnG67GjPXLZpqcky/UMnQ==} - engines: {node: '>=6.0'} - dev: true - /xmlhttprequest-ssl@1.5.5: resolution: {integrity: sha512-/bFPLUgJrfGUL10AIv4Y7/CUt6so9CLtB/oFxQSHseSDNNCdC6vwwKEqwLN6wNPBg9YWXAiMu8jkf6RPRS/75Q==} engines: {node: '>=0.4.0'} @@ -16218,7 +16178,7 @@ packages: optional: true dependencies: '@angular/compiler-cli': 20.0.0-next.3(@angular/compiler@20.0.0-next.3)(typescript@5.8.2) - '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) + '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) '@bazel/worker': 5.8.1 '@microsoft/api-extractor': 7.52.1(@types/node@16.18.101) '@rollup/plugin-commonjs': 21.1.0(rollup@2.79.1) @@ -16235,18 +16195,18 @@ packages: - '@types/node' dev: true - github.com/angular/dev-infra-private-build-tooling-builds/ec9df12469082e3cb087a9af55072dc2d833c73f(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(less@4.2.2)(postcss@8.5.3)(rxjs@6.6.7)(terser@5.39.0)(yaml@1.10.2)(zone.js@0.15.0): + github.com/angular/dev-infra-private-build-tooling-builds/ec9df12469082e3cb087a9af55072dc2d833c73f(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(postcss@8.5.3)(rxjs@6.6.7)(terser@5.39.0)(yaml@1.10.2)(zone.js@0.15.0): resolution: {tarball: https://codeload.github.com/angular/dev-infra-private-build-tooling-builds/tar.gz/ec9df12469082e3cb087a9af55072dc2d833c73f} id: github.com/angular/dev-infra-private-build-tooling-builds/ec9df12469082e3cb087a9af55072dc2d833c73f name: '@angular/build-tooling' version: 0.0.0-335a273d3eb2a73c51efb97930fc1e0cd72e0d32 dependencies: '@angular/benchpress': 0.3.0(rxjs@6.6.7)(zone.js@0.15.0) - '@angular/build': 20.0.0-next.0(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@20.17.24)(karma@6.4.3)(less@4.2.2)(postcss@8.5.3)(terser@5.39.0)(typescript@5.8.2)(yaml@1.10.2) + '@angular/build': 20.0.0-next.0(@angular/compiler-cli@20.0.0-next.3)(@angular/compiler@20.0.0-next.3)(@angular/localize@20.0.0-next.3)(@angular/platform-server@20.0.0-next.3)(@types/node@20.17.24)(karma@6.4.3)(postcss@8.5.3)(terser@5.39.0)(typescript@5.8.2)(yaml@1.10.2) '@babel/core': 7.26.10 '@babel/plugin-proposal-async-generator-functions': 7.20.7(@babel/core@7.26.10) '@bazel/buildifier': 6.3.3 - '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-junit-reporter@2.0.1)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) + '@bazel/concatjs': 5.8.1(karma-chrome-launcher@3.2.0)(karma-firefox-launcher@2.1.3)(karma-jasmine@4.0.2)(karma-requirejs@1.1.0)(karma-sourcemap-loader@0.3.8)(karma@6.4.3)(typescript@5.8.2) '@bazel/esbuild': 5.8.1 '@bazel/protractor': 5.8.1(protractor@7.0.0) '@bazel/runfiles': 5.8.1 diff --git a/src/cdk-experimental/package.json b/src/cdk-experimental/package.json index e7d6dc18b7f4..fc3b2a6d6b59 100644 --- a/src/cdk-experimental/package.json +++ b/src/cdk-experimental/package.json @@ -16,7 +16,7 @@ "@angular/core": "0.0.0-NG" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP" diff --git a/src/cdk/package.json b/src/cdk/package.json index 677bc670f3cb..0cb0dc83ae09 100644 --- a/src/cdk/package.json +++ b/src/cdk/package.json @@ -47,13 +47,11 @@ "peerDependencies": { "@angular/core": "0.0.0-NG", "@angular/common": "0.0.0-NG", - "rxjs": "0.0.0-RXJS" + "rxjs": "^6.5.3 || ^7.4.0" }, "dependencies": { - "tslib": "0.0.0-TSLIB" - }, - "optionalDependencies": { - "parse5": "^7.1.2" + "parse5": "^7.1.2", + "tslib": "^2.3.0" }, "schematics": "./schematics/collection.json", "ng-update": { diff --git a/src/components-examples/package.json b/src/components-examples/package.json index 6fbf2398d523..34c8abe9591e 100644 --- a/src/components-examples/package.json +++ b/src/components-examples/package.json @@ -35,6 +35,6 @@ "@angular/material-date-fns-adapter": "0.0.0-PLACEHOLDER" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" } } diff --git a/src/google-maps/package.json b/src/google-maps/package.json index 5f38bff98174..bef9fabe52d9 100644 --- a/src/google-maps/package.json +++ b/src/google-maps/package.json @@ -18,12 +18,12 @@ "homepage": "https://github.com/angular/components/tree/main/src/google-maps#readme", "dependencies": { "@types/google.maps": "^3.54.10", - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "peerDependencies": { "@angular/core": "0.0.0-NG", "@angular/common": "0.0.0-NG", - "rxjs": "0.0.0-RXJS" + "rxjs": "^6.5.3 || ^7.4.0" }, "sideEffects": false, "schematics": "./schematics/collection.json", diff --git a/src/material-date-fns-adapter/package.json b/src/material-date-fns-adapter/package.json index 56a35b9b0652..f19f5b4f0993 100644 --- a/src/material-date-fns-adapter/package.json +++ b/src/material-date-fns-adapter/package.json @@ -17,7 +17,7 @@ "date-fns": ">2.20.0 <5.0" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP" diff --git a/src/material-experimental/package.json b/src/material-experimental/package.json index c45703c55ce7..4592a6d591d4 100644 --- a/src/material-experimental/package.json +++ b/src/material-experimental/package.json @@ -25,7 +25,7 @@ "@angular/material": "0.0.0-PLACEHOLDER" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP" diff --git a/src/material-luxon-adapter/package.json b/src/material-luxon-adapter/package.json index 633b572ed8ea..fafbb3afaf1b 100644 --- a/src/material-luxon-adapter/package.json +++ b/src/material-luxon-adapter/package.json @@ -17,7 +17,7 @@ "luxon": "^3.0.0" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP" diff --git a/src/material-moment-adapter/package.json b/src/material-moment-adapter/package.json index db50144ef84c..3efa0addd3a0 100644 --- a/src/material-moment-adapter/package.json +++ b/src/material-moment-adapter/package.json @@ -17,7 +17,7 @@ "moment": "^2.18.1" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP" diff --git a/src/material/package.json b/src/material/package.json index 2f6914964f4e..bdb2012f1271 100644 --- a/src/material/package.json +++ b/src/material/package.json @@ -61,10 +61,10 @@ "@angular/common": "0.0.0-NG", "@angular/forms": "0.0.0-NG", "@angular/platform-browser": "0.0.0-NG", - "rxjs": "0.0.0-RXJS" + "rxjs": "^6.5.3 || ^7.4.0" }, "dependencies": { - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "schematics": "./schematics/collection.json", "ng-update": { diff --git a/src/material/schematics/BUILD.bazel b/src/material/schematics/BUILD.bazel index 67380d0ded2e..b208fa870fd0 100644 --- a/src/material/schematics/BUILD.bazel +++ b/src/material/schematics/BUILD.bazel @@ -1,5 +1,6 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "jasmine_node_test", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -87,20 +88,7 @@ pkg_npm( ], ) -### Testing rules - -jasmine_node_test( - name = "unit_tests", - srcs = [":unit_test_sources"], - data = [ - ":collection_assets", - ":ng_generate_assets", - ":schema_assets", - ":schematics_test_cases", - ], -) - -ts_library( +ts_project( name = "unit_test_sources", testonly = True, srcs = glob( @@ -138,3 +126,15 @@ filegroup( "ng-update/test-cases/**/*_expected_output.ts", ]), ) + +jasmine_test( + name = "unit_tests", + data = [ + ":collection_assets", + ":ng_generate_assets", + ":schema_assets", + ":schematics_test_cases", + ":unit_test_sources_rjs", + "//src/material/schematics:package_json", + ], +) diff --git a/src/youtube-player/package.json b/src/youtube-player/package.json index bac679e02343..001df21b69bb 100644 --- a/src/youtube-player/package.json +++ b/src/youtube-player/package.json @@ -18,12 +18,12 @@ "homepage": "https://github.com/angular/components/tree/main/src/youtube-player#readme", "dependencies": { "@types/youtube": "^0.1.0", - "tslib": "0.0.0-TSLIB" + "tslib": "^2.3.0" }, "peerDependencies": { "@angular/core": "0.0.0-NG", "@angular/common": "0.0.0-NG", - "rxjs": "0.0.0-RXJS" + "rxjs": "^6.5.3 || ^7.4.0" }, "sideEffects": false, "schematics": "./schematics/collection.json", From 22b6d50b800d44801e829f36b64e9f7dfdcd9fb5 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 21 Mar 2025 07:03:12 +0000 Subject: [PATCH 4/4] build: migrate schematics to `ts_project` Migrates all schematics code to `ts_project` and simplifies complexity/confusion around devmode,prodmode ESM and CommonJS. --- .../npm_translate_lock_MzA5NzUwNzMx | 4 +- WORKSPACE | 1 + pnpm-lock.yaml | 11 +- pnpm-workspace.yaml | 1 + src/cdk/schematics/BUILD.bazel | 115 ++++++++++-------- src/cdk/schematics/testing/BUILD.bazel | 35 +++--- src/cdk/schematics/testing/tsconfig.json | 4 +- src/cdk/schematics/tsconfig-test.json | 7 ++ src/cdk/schematics/tsconfig.json | 9 +- src/cdk/schematics/update-tool/BUILD.bazel | 13 +- src/cdk/schematics/update-tool/tsconfig.json | 4 +- src/google-maps/schematics/BUILD.bazel | 27 ++-- src/google-maps/schematics/migration.json | 2 +- .../schematics/ng-update/BUILD.bazel | 42 ++----- .../schematics/ng-update/tsconfig.json | 7 -- src/google-maps/schematics/tsconfig.json | 9 ++ .../schematics/BUILD.bazel | 19 +-- .../schematics/tsconfig.json | 9 ++ .../schematics/BUILD.bazel | 19 +-- .../schematics/tsconfig.json | 9 ++ .../schematics/BUILD.bazel | 19 +-- .../schematics/tsconfig.json | 9 ++ src/material/schematics/BUILD.bazel | 109 +++++++++-------- .../migration-utilities/BUILD.bazel | 29 +++-- src/material/schematics/ng-add/index.spec.ts | 2 +- .../ng-generate/address-form/index.spec.ts | 2 +- .../ng-generate/dashboard/index.spec.ts | 2 +- .../ng-generate/navigation/index.spec.ts | 2 +- .../ng-generate/table/index.spec.ts | 2 +- .../ng-generate/theme-color/BUILD.bazel | 76 ++++++------ .../ng-generate/theme-color/index.spec.ts | 15 +-- .../theme-color/index_bundled.d.ts | 11 ++ .../schematics/ng-generate/tree/index.spec.ts | 2 +- src/material/schematics/ng-update/BUILD.bazel | 75 ++++-------- .../ng-update/test-cases/index.spec.ts | 5 +- .../schematics/ng-update/tsconfig.json | 8 -- src/material/schematics/tsconfig-test.json | 7 ++ src/material/schematics/tsconfig.json | 32 ++--- src/youtube-player/schematics/BUILD.bazel | 19 +-- src/youtube-player/schematics/tsconfig.json | 9 ++ tools/defaults2.bzl | 4 + 41 files changed, 411 insertions(+), 375 deletions(-) create mode 100644 src/cdk/schematics/tsconfig-test.json delete mode 100644 src/google-maps/schematics/ng-update/tsconfig.json create mode 100644 src/google-maps/schematics/tsconfig.json create mode 100644 src/material-date-fns-adapter/schematics/tsconfig.json create mode 100644 src/material-luxon-adapter/schematics/tsconfig.json create mode 100644 src/material-moment-adapter/schematics/tsconfig.json create mode 100644 src/material/schematics/ng-generate/theme-color/index_bundled.d.ts delete mode 100644 src/material/schematics/ng-update/tsconfig.json create mode 100644 src/material/schematics/tsconfig-test.json create mode 100644 src/youtube-player/schematics/tsconfig.json diff --git a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx index 10eb2f36298c..31764dcf00fb 100755 --- a/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx +++ b/.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx @@ -3,7 +3,7 @@ # This file should be checked into version control along with the pnpm-lock.yaml file. .npmrc=-1406867100 package.json=-370577278 -pnpm-lock.yaml=-1162470554 -pnpm-workspace.yaml=1711114604 +pnpm-lock.yaml=1107477480 +pnpm-workspace.yaml=14857322 src/cdk/package.json=-908433069 yarn.lock=-987404687 diff --git a/WORKSPACE b/WORKSPACE index bfb2e263912a..c595dd687202 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -116,6 +116,7 @@ yarn_install( "//:tools/postinstall/patches/@angular+build-tooling+0.0.0-1ebf18a3a60b182a3dbad12e9a149fd93af5c29b.patch", "//:tools/postinstall/patches/@bazel+concatjs+5.8.1.patch", "//:tools/postinstall/patches/tsec+0.2.2.patch", + "//src/cdk:package.json", ], # Currently disabled due to: # 1. Missing Windows support currently. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 918f0967b744..c3b2d0ac9403 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -381,6 +381,15 @@ importers: specifier: ^6.2.4 version: 6.2.5 + src/cdk: + dependencies: + parse5: + specifier: ^7.1.2 + version: 7.1.2 + tslib: + specifier: ^2.3.0 + version: 2.8.1 + packages: /@ampproject/remapping@2.3.0: @@ -7868,7 +7877,6 @@ packages: /entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} - dev: true /env-paths@2.2.1: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} @@ -12214,7 +12222,6 @@ packages: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} dependencies: entities: 4.5.0 - dev: true /parseqs@0.0.5: resolution: {integrity: sha512-B3Nrjw2aL7aI4TDujOzfA4NsEc4u1lVcIRE0xesutH8kjeWF70uk+W5cBlIQx04zUH9NTBvuN36Y9xLRPK6Jjw==} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d05a7e7dc84a..fd38b74a8caa 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,2 +1,3 @@ packages: - . + - src/cdk diff --git a/src/cdk/schematics/BUILD.bazel b/src/cdk/schematics/BUILD.bazel index b555514cf4da..7f2f4b2f4853 100644 --- a/src/cdk/schematics/BUILD.bazel +++ b/src/cdk/schematics/BUILD.bazel @@ -1,67 +1,73 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "jasmine_node_test", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "jasmine_node_test") +load("//tools:defaults2.bzl", "npm_package", "ts_project") +load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob([ - "**/files/**/*", - "**/*.json", - ]), + srcs = glob( + [ + "**/files/**/*", + "**/*.json", + ], + exclude = [ + "tsconfig.json", + "tsconfig-test.json", + "package.json", + ], + ), +) + +copy_to_bin( + name = "package_json", + srcs = ["package.json"], ) -ts_library( +rules_js_tsconfig( + name = "tsconfig", + src = "tsconfig.json", +) + +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = [ - "**/files/**/*.ts", + "**/files/**/*", "**/*.spec.ts", "testing/**/*.ts", ], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", - tsconfig = ":tsconfig.json", - deps = [ + interop_deps = [ "//src/cdk/schematics/update-tool", - "@npm//@schematics/angular", - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - # TODO(devversion): Only include jasmine for test sources (See: tsconfig types). - "@npm//@types/jasmine", - "@npm//@types/glob", - "@npm//@types/node", - "@npm//glob", - "@npm//parse5", - "@npm//typescript", ], -) - -# This package is intended to be combined into the main @angular/cdk package as a dep. -pkg_npm( - name = "npm_package", - srcs = ["package.json"], + tsconfig = "tsconfig.json", deps = [ - ":schematics", - ":schematics_assets", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/glob", + "//:node_modules/@types/node", + "//:node_modules/glob", + "//:node_modules/parse5", + "//:node_modules/typescript", ], ) -### Testing rules - -jasmine_node_test( - name = "unit_tests", - srcs = [":unit_test_sources"], - data = [ +# This package is intended to be combined into the main @angular/cdk package as a dep. +npm_package( + name = "npm_package", + srcs = [ + "package.json", ":schematics_assets", + ":schematics_rjs", ], + package = "@angular/cdk/schematics", ) -ts_library( +ts_project( name = "unit_test_sources", testonly = True, srcs = glob( @@ -71,21 +77,28 @@ ts_library( "**/files/**/*.spec.ts", ], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", - tsconfig = ":tsconfig.json", - deps = [ - ":schematics", + extends = "tsconfig.json", + interop_deps = [ "//src/cdk/schematics/testing", "//src/cdk/schematics/update-tool", "//src/cdk/testing/private", - "@npm//@angular-devkit/schematics", - "@npm//@bazel/runfiles", - "@npm//@schematics/angular", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//typescript", + ], + tsconfig = "tsconfig-test.json", + deps = [ + ":schematics_rjs", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@bazel/runfiles", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/jasmine", + "//:node_modules/@types/node", + "//:node_modules/typescript", + ], +) + +jasmine_node_test( + name = "unit_tests", + srcs = [":unit_test_sources"], + data = [ + ":schematics_assets", ], ) diff --git a/src/cdk/schematics/testing/BUILD.bazel b/src/cdk/schematics/testing/BUILD.bazel index d2daadf07a94..e2dc4351252d 100644 --- a/src/cdk/schematics/testing/BUILD.bazel +++ b/src/cdk/schematics/testing/BUILD.bazel @@ -1,27 +1,28 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "testing", testonly = True, srcs = glob(["**/*.ts"]), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + # Needed to ensure these files are picked up as CommonJS, as otherwise + # the higher-level `package.json` from `src/package.json` is `type: module`. + data = ["//src/cdk/schematics:package_json"], + extends = "//src/cdk/schematics:tsconfig", tsconfig = "tsconfig.json", deps = [ - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@bazel/runfiles", - "@npm//@schematics/angular", - "@npm//@types/fs-extra", - "@npm//@types/glob", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//fs-extra", - "@npm//jsonc-parser", - "@npm//rxjs", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@bazel/runfiles", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/glob", + "//:node_modules/@types/jasmine", + "//:node_modules/@types/node", + "//:node_modules/fs-extra", + "//:node_modules/glob", + "//:node_modules/jsonc-parser", + "//:node_modules/rxjs", ], ) diff --git a/src/cdk/schematics/testing/tsconfig.json b/src/cdk/schematics/testing/tsconfig.json index 072ed7aa1158..7509bccd7f5b 100644 --- a/src/cdk/schematics/testing/tsconfig.json +++ b/src/cdk/schematics/testing/tsconfig.json @@ -1,7 +1,9 @@ { + "extends": "../tsconfig.json", "compilerOptions": { "strict": true, "lib": ["es2015"], "types": ["node", "jasmine", "glob"] - } + }, + "exclude": [] } diff --git a/src/cdk/schematics/tsconfig-test.json b/src/cdk/schematics/tsconfig-test.json new file mode 100644 index 000000000000..6b63c9589e00 --- /dev/null +++ b/src/cdk/schematics/tsconfig-test.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": ["jasmine", "node"] + }, + "exclude": [] +} diff --git a/src/cdk/schematics/tsconfig.json b/src/cdk/schematics/tsconfig.json index 0733e83f5692..f1bdd2b85206 100644 --- a/src/cdk/schematics/tsconfig.json +++ b/src/cdk/schematics/tsconfig.json @@ -4,10 +4,10 @@ "lib": ["es2017"], "module": "commonjs", "moduleResolution": "node", - "outDir": "../../../dist/packages/cdk/schematics", - "noEmitOnError": false, + "rootDir": ".", "strictNullChecks": true, "noPropertyAccessFromIndexSignature": true, + "strict": true, "useUnknownInCatchVariables": true, "noImplicitOverride": true, "noImplicitReturns": true, @@ -22,8 +22,5 @@ "target": "es2015", "types": ["jasmine", "node"] }, - "exclude": ["**/files/**/*", "**/*.spec.ts", "ng-update/test-cases/**/*", "testing/**/*.ts"], - "bazelOptions": { - "suppressTsconfigOverrideWarnings": true - } + "exclude": ["**/files/**/*", "**/*.spec.ts", "ng-update/test-cases/**/*", "testing/**/*.ts"] } diff --git a/src/cdk/schematics/update-tool/BUILD.bazel b/src/cdk/schematics/update-tool/BUILD.bazel index 997c4e84676f..1ce5a0914d01 100644 --- a/src/cdk/schematics/update-tool/BUILD.bazel +++ b/src/cdk/schematics/update-tool/BUILD.bazel @@ -1,17 +1,14 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "update-tool", srcs = glob(["**/*.ts"]), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + extends = "//src/cdk/schematics:tsconfig", tsconfig = ":tsconfig.json", deps = [ - "@npm//@types/node", - "@npm//typescript", + "//:node_modules/@types/node", + "//:node_modules/typescript", ], ) diff --git a/src/cdk/schematics/update-tool/tsconfig.json b/src/cdk/schematics/update-tool/tsconfig.json index c553c223f3dd..9e023b9fac02 100644 --- a/src/cdk/schematics/update-tool/tsconfig.json +++ b/src/cdk/schematics/update-tool/tsconfig.json @@ -1,7 +1,9 @@ { + "extends": "../tsconfig.json", "compilerOptions": { "strict": true, "lib": ["es2015"], "types": ["node", "glob"] - } + }, + "exclude": [] } diff --git a/src/google-maps/schematics/BUILD.bazel b/src/google-maps/schematics/BUILD.bazel index 72c95a675a7d..c162b755b1e5 100644 --- a/src/google-maps/schematics/BUILD.bazel +++ b/src/google-maps/schematics/BUILD.bazel @@ -1,26 +1,33 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm") +load("//tools:defaults2.bzl", "ts_project") +load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob(["**/*.json"]), + srcs = glob( + ["**/*.json"], + exclude = ["tsconfig.json"], + ), +) + +rules_js_tsconfig( + name = "tsconfig", + src = "tsconfig.json", ) -ts_library( +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + tsconfig = ":tsconfig", deps = [ - "@npm//@angular-devkit/schematics", - "@npm//@types/node", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@types/node", ], ) @@ -30,6 +37,6 @@ pkg_npm( deps = [ ":schematics", ":schematics_assets", - "//src/google-maps/schematics/ng-update:ng_update_index", + "//src/google-maps/schematics/ng-update", ], ) diff --git a/src/google-maps/schematics/migration.json b/src/google-maps/schematics/migration.json index 45c93051dfc9..6702dc7cbee2 100644 --- a/src/google-maps/schematics/migration.json +++ b/src/google-maps/schematics/migration.json @@ -3,7 +3,7 @@ "migration-v20": { "version": "20.0.0-0", "description": "Updates the Angular Google Maps package to v20", - "factory": "./ng-update/index_bundled#updateToV20" + "factory": "./ng-update/index#updateToV20" } } } diff --git a/src/google-maps/schematics/ng-update/BUILD.bazel b/src/google-maps/schematics/ng-update/BUILD.bazel index fa96cad96ab5..2ba08b29cd45 100644 --- a/src/google-maps/schematics/ng-update/BUILD.bazel +++ b/src/google-maps/schematics/ng-update/BUILD.bazel @@ -1,40 +1,18 @@ -load("//tools:defaults.bzl", "esbuild", "ts_library") +load("//tools:defaults2.bzl", "ts_project") -## THIS ONE IS ESM -# By default everything is ESM -# ESBUild needs ESM for bundling. Cannot reliably use CJS as input. -ts_library( - name = "ng_update_lib", +ts_project( + name = "ng-update", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", + tsconfig = "//src/google-maps/schematics:tsconfig", + visibility = ["//src/google-maps/schematics:__pkg__"], deps = [ - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@schematics/angular", - "@npm//@types/node", - "@npm//typescript", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/node", + "//:node_modules/typescript", ], ) - -esbuild( - name = "ng_update_index", - entry_point = ":index.ts", - external = [ - "@schematics/angular", - "@angular-devkit/schematics", - "@angular-devkit/core", - "typescript", - ], - # TODO: Switch to ESM when Angular CLI supports it. - format = "cjs", - output = "index_bundled.js", - platform = "node", - target = "es2015", - visibility = ["//src/google-maps/schematics:__pkg__"], - deps = [":ng_update_lib"], -) diff --git a/src/google-maps/schematics/ng-update/tsconfig.json b/src/google-maps/schematics/ng-update/tsconfig.json deleted file mode 100644 index 78f1753e68b0..000000000000 --- a/src/google-maps/schematics/ng-update/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "module": "esnext", - "target": "es2015" - } -} diff --git a/src/google-maps/schematics/tsconfig.json b/src/google-maps/schematics/tsconfig.json new file mode 100644 index 000000000000..41932c86a248 --- /dev/null +++ b/src/google-maps/schematics/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, + "sourceMap": true, + "declaration": true + } +} diff --git a/src/material-date-fns-adapter/schematics/BUILD.bazel b/src/material-date-fns-adapter/schematics/BUILD.bazel index a412cee88827..7c72a96aef47 100644 --- a/src/material-date-fns-adapter/schematics/BUILD.bazel +++ b/src/material-date-fns-adapter/schematics/BUILD.bazel @@ -1,26 +1,27 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob(["**/*.json"]), + srcs = glob( + ["**/*.json"], + exclude = ["tsconfig.json"], + ), ) -ts_library( +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + tsconfig = "tsconfig.json", deps = [ - "@npm//@angular-devkit/schematics", - "@npm//@types/node", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@types/node", ], ) diff --git a/src/material-date-fns-adapter/schematics/tsconfig.json b/src/material-date-fns-adapter/schematics/tsconfig.json new file mode 100644 index 000000000000..41932c86a248 --- /dev/null +++ b/src/material-date-fns-adapter/schematics/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, + "sourceMap": true, + "declaration": true + } +} diff --git a/src/material-luxon-adapter/schematics/BUILD.bazel b/src/material-luxon-adapter/schematics/BUILD.bazel index aaa2c12aa7dc..eb54fb0cd8e8 100644 --- a/src/material-luxon-adapter/schematics/BUILD.bazel +++ b/src/material-luxon-adapter/schematics/BUILD.bazel @@ -1,26 +1,27 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob(["**/*.json"]), + srcs = glob( + ["**/*.json"], + exclude = ["tsconfig.json"], + ), ) -ts_library( +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + tsconfig = "tsconfig.json", deps = [ - "@npm//@angular-devkit/schematics", - "@npm//@types/node", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@types/node", ], ) diff --git a/src/material-luxon-adapter/schematics/tsconfig.json b/src/material-luxon-adapter/schematics/tsconfig.json new file mode 100644 index 000000000000..41932c86a248 --- /dev/null +++ b/src/material-luxon-adapter/schematics/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, + "sourceMap": true, + "declaration": true + } +} diff --git a/src/material-moment-adapter/schematics/BUILD.bazel b/src/material-moment-adapter/schematics/BUILD.bazel index 0724674f6cf8..b6b0336a21a4 100644 --- a/src/material-moment-adapter/schematics/BUILD.bazel +++ b/src/material-moment-adapter/schematics/BUILD.bazel @@ -1,26 +1,27 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob(["**/*.json"]), + srcs = glob( + ["**/*.json"], + exclude = ["tsconfig.json"], + ), ) -ts_library( +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + tsconfig = "tsconfig.json", deps = [ - "@npm//@angular-devkit/schematics", - "@npm//@types/node", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@types/node", ], ) diff --git a/src/material-moment-adapter/schematics/tsconfig.json b/src/material-moment-adapter/schematics/tsconfig.json new file mode 100644 index 000000000000..41932c86a248 --- /dev/null +++ b/src/material-moment-adapter/schematics/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, + "sourceMap": true, + "declaration": true + } +} diff --git a/src/material/schematics/BUILD.bazel b/src/material/schematics/BUILD.bazel index b208fa870fd0..67c0ae0dce13 100644 --- a/src/material/schematics/BUILD.bazel +++ b/src/material/schematics/BUILD.bazel @@ -1,9 +1,17 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") -load("//tools:defaults2.bzl", "ts_project") +load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config") +load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project") +load("@aspect_rules_js//npm:defs.bzl", "npm_link_package") package(default_visibility = ["//visibility:public"]) +# TODO(devversion): Remove when CDK is fully linked properly. +npm_link_package( + name = "node_modules/@angular/cdk/schematics", + src = "//src/cdk/schematics:npm_package", + root_package = package_name(), +) + copy_to_bin( name = "collection_assets", srcs = [ @@ -26,7 +34,29 @@ copy_to_bin( ]), ) -ts_library( +copy_to_bin( + name = "package_json", + srcs = ["package.json"], +) + +rules_js_tsconfig( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:node_modules/@types/node", + ], +) + +rules_js_tsconfig( + name = "tsconfig-test", + src = "tsconfig-test.json", + deps = [ + "tsconfig.json", + "//:node_modules/@types/jasmine", + ], +) + +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], @@ -36,54 +66,41 @@ ts_library( "ng-generate/*/files/**/*.ts", ], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", - tsconfig = ":tsconfig.json", + tsconfig = ":tsconfig", deps = [ - "//src/cdk/schematics", - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@schematics/angular", - # TODO(devversion): Only include jasmine for test sources (See: tsconfig types). - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//rxjs", - "@npm//tslint", - "@npm//typescript", + ":node_modules/@angular/cdk/schematics", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@schematics/angular", + "//:node_modules/rxjs", + "//:node_modules/tslint", + "//:node_modules/typescript", ], ) -ts_library( +ts_project( name = "paths", testonly = True, srcs = ["paths.ts"], data = [ ":collection_assets", ], - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", - tsconfig = ":tsconfig.json", + tsconfig = ":tsconfig", deps = [ - "@npm//@bazel/runfiles", + "//:node_modules/@bazel/runfiles", ], ) # This package is intended to be combined into the main @angular/material package as a dep. -pkg_npm( +npm_package( name = "npm_package", - srcs = ["package.json"], - nested_packages = [ - "//src/material/schematics/ng-generate/theme-color:npm_package", - ], - deps = [ + srcs = [ + "package.json", ":collection_assets", ":ng_generate_assets", ":schema_assets", - ":schematics", + ":schematics_rjs", + "//src/material/schematics/ng-generate/theme-color:npm_package", "//src/material/schematics/ng-update:ng_update_index", ], ) @@ -98,23 +115,19 @@ ts_project( "ng-generate/*/files/**/*.spec.ts", ], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", - tsconfig = ":tsconfig.json", + tsconfig = ":tsconfig-test", deps = [ - ":paths", - ":schematics", - "//src/cdk/schematics", - "//src/cdk/schematics/testing", - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@schematics/angular", - "@npm//@types/fs-extra", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//fs-extra", + ":node_modules/@angular/cdk/schematics", + ":paths_rjs", + ":schematics_rjs", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/jasmine", + "//:node_modules/@types/node", + "//:node_modules/fs-extra", + "//src/cdk/schematics/testing:testing_rjs", ], ) diff --git a/src/material/schematics/migration-utilities/BUILD.bazel b/src/material/schematics/migration-utilities/BUILD.bazel index f9f9409ed5bb..cf63af0b6edd 100644 --- a/src/material/schematics/migration-utilities/BUILD.bazel +++ b/src/material/schematics/migration-utilities/BUILD.bazel @@ -1,36 +1,35 @@ -load("//tools:defaults.bzl", "jasmine_node_test", "spec_bundle", "ts_library") +load("//tools:defaults2.bzl", "jasmine_test", "ts_project") package(default_visibility = ["//visibility:public"]) -ts_library( +ts_project( name = "migration-utilities", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), + tsconfig = "//src/material/schematics:tsconfig", deps = [ - "@npm//typescript", + "//:node_modules/typescript", ], ) -ts_library( +ts_project( name = "unit_tests_lib", testonly = True, srcs = glob(["**/*.spec.ts"] + ["rules/components/test-setup-helper.ts"]), + tsconfig = "//src/material/schematics:tsconfig-test", deps = [ - ":migration-utilities", - "@npm//@types/jasmine", - "@npm//typescript", + ":migration-utilities_rjs", + "//:node_modules/@types/jasmine", + "//:node_modules/typescript", ], ) -spec_bundle( - name = "unit_tests_bundle", - platform = "cjs-legacy", - deps = [":unit_tests_lib"], -) - -jasmine_node_test( +jasmine_test( name = "unit_tests", - deps = [":unit_tests_bundle"], + data = [ + ":unit_tests_lib_rjs", + "//src/material/schematics:package_json", + ], ) diff --git a/src/material/schematics/ng-add/index.spec.ts b/src/material/schematics/ng-add/index.spec.ts index 1b394d54831a..14696f621391 100644 --- a/src/material/schematics/ng-add/index.spec.ts +++ b/src/material/schematics/ng-add/index.spec.ts @@ -7,7 +7,7 @@ import { getProjectStyleFile, getProjectTargetOptions, } from '@angular/cdk/schematics'; -import {createTestApp, createTestLibrary, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, createTestLibrary, getFileContent} from '../../../cdk/schematics/testing'; import {getWorkspace} from '@schematics/angular/utility/workspace'; import {COLLECTION_PATH} from '../paths'; import {addPackageToPackageJson} from './package-config'; diff --git a/src/material/schematics/ng-generate/address-form/index.spec.ts b/src/material/schematics/ng-generate/address-form/index.spec.ts index c1a334de9725..f0c5e08b723d 100644 --- a/src/material/schematics/ng-generate/address-form/index.spec.ts +++ b/src/material/schematics/ng-generate/address-form/index.spec.ts @@ -1,5 +1,5 @@ import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; -import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, getFileContent} from '../../../../cdk/schematics/testing'; import {COLLECTION_PATH} from '../../paths'; import {Schema} from './schema'; diff --git a/src/material/schematics/ng-generate/dashboard/index.spec.ts b/src/material/schematics/ng-generate/dashboard/index.spec.ts index 97f7792abf2f..1d867252f67f 100644 --- a/src/material/schematics/ng-generate/dashboard/index.spec.ts +++ b/src/material/schematics/ng-generate/dashboard/index.spec.ts @@ -1,5 +1,5 @@ import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; -import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, getFileContent} from '../../../../cdk/schematics/testing'; import {COLLECTION_PATH} from '../../paths'; import {Schema} from './schema'; diff --git a/src/material/schematics/ng-generate/navigation/index.spec.ts b/src/material/schematics/ng-generate/navigation/index.spec.ts index e17ce5b14e92..266db2943c87 100644 --- a/src/material/schematics/ng-generate/navigation/index.spec.ts +++ b/src/material/schematics/ng-generate/navigation/index.spec.ts @@ -1,5 +1,5 @@ import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing'; -import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, getFileContent} from '../../../../cdk/schematics/testing'; import {COLLECTION_PATH} from '../../paths'; import {Schema} from './schema'; diff --git a/src/material/schematics/ng-generate/table/index.spec.ts b/src/material/schematics/ng-generate/table/index.spec.ts index dbdf545983bd..45887d312fd4 100644 --- a/src/material/schematics/ng-generate/table/index.spec.ts +++ b/src/material/schematics/ng-generate/table/index.spec.ts @@ -1,5 +1,5 @@ import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; -import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, getFileContent} from '../../../../cdk/schematics/testing'; import {COLLECTION_PATH} from '../../paths'; import {Schema} from './schema'; diff --git a/src/material/schematics/ng-generate/theme-color/BUILD.bazel b/src/material/schematics/ng-generate/theme-color/BUILD.bazel index dae38aaf9cba..44cbe279b21b 100644 --- a/src/material/schematics/ng-generate/theme-color/BUILD.bazel +++ b/src/material/schematics/ng-generate/theme-color/BUILD.bazel @@ -1,5 +1,6 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "esbuild", "jasmine_node_test", "pkg_npm", "spec_bundle", "ts_library") +load("//tools:defaults.bzl", "esbuild", "pkg_npm") +load("//tools:defaults2.bzl", "jasmine_test", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -7,24 +8,27 @@ STATIC_ASSETS = [ "schema.json", ] -ts_library( +ts_project( name = "m3_theme_lib", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"] + ["rules/components/test-setup-helper.ts"], ), - deps = [ + interop_deps = [ "//src/cdk/schematics", - "@npm//@angular-devkit/schematics", - "@npm//@material/material-color-utilities", - "@npm//@types/node", - "@npm//sass", - "@npm//typescript", + ], + tsconfig = "//src/material/schematics:tsconfig", + deps = [ + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@material/material-color-utilities", + "//:node_modules/@types/node", + "//:node_modules/sass", + "//:node_modules/typescript", ], ) esbuild( - name = "m3_theme_bundle", + name = "index_bundled", entry_point = ":index.ts", external = [ "@angular/cdk/schematics", @@ -47,62 +51,54 @@ esbuild( pkg_npm( name = "npm_package", srcs = STATIC_ASSETS, - deps = [":m3_theme_bundle"], + deps = [":index_bundled"], ) ######################################## # Testing configuration # ######################################## -ts_library( +ts_project( name = "unit_tests_lib", testonly = True, - srcs = glob(["**/*.spec.ts"] + ["rules/components/test-setup-helper.ts"]), - devmode_module = "commonjs", + srcs = glob([ + "**/*.spec.ts", + "index_bundled.d.ts", + ] + ["rules/components/test-setup-helper.ts"]), + data = [":index_bundled"], + tsconfig = "//src/material/schematics:tsconfig-test", deps = [ - ":m3_theme_lib", - "//src/cdk/schematics/testing", - "//tools/sass:sass_lib", - "@npm//@angular-devkit/schematics", - "@npm//@bazel/runfiles", - "@npm//@material/material-color-utilities", - "@npm//@types/jasmine", - "@npm//@types/node", - "@npm//sass", + ":m3_theme_lib_rjs", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@bazel/runfiles", + "//:node_modules/@material/material-color-utilities", + "//:node_modules/sass", + "//src/cdk/schematics/testing:testing_rjs", + "//tools/sass:sass_lib_rjs", ], ) -spec_bundle( - name = "unit_tests_bundle", - # Exclude the `node` devkit entry-point to avoid bundling native modules like - # `chokidar` and `fsevents`. These rely on native bindings and break with ESBuild. - external = ["@angular-devkit/core/node"], - platform = "node", - target = "es2020", - deps = [":unit_tests_lib"], -) - copy_to_bin( name = "unit_tests_assets", testonly = True, srcs = STATIC_ASSETS, ) -jasmine_node_test( +jasmine_test( name = "unit_tests", data = [ - ":m3_theme_bundle", ":unit_tests_assets", + ":unit_tests_lib_rjs", + "//src/material:sass_lib", + "//src/material-experimental:sass_lib", "//src/material/schematics:collection_assets", "//src/material/schematics:ng_generate_assets", + "//src/material/schematics:package_json", ], - shard_count = 10, - deps = [ - ":unit_tests_bundle", - # Runtime dependencies needed by the test and actual migration sources. These need - # to be specified explicitly here because they are not captured by the bundling. - "@npm//@schematics/angular", + no_copy_to_bin = [ + # TODO(devversion): Ensure Sass is copied to `bazel-bin`. "//src/material:sass_lib", "//src/material-experimental:sass_lib", ], + shard_count = 10, ) diff --git a/src/material/schematics/ng-generate/theme-color/index.spec.ts b/src/material/schematics/ng-generate/theme-color/index.spec.ts index 82e5e672b486..cae1ad3c9b96 100644 --- a/src/material/schematics/ng-generate/theme-color/index.spec.ts +++ b/src/material/schematics/ng-generate/theme-color/index.spec.ts @@ -1,17 +1,14 @@ import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing'; -import {createTestApp} from '@angular/cdk/schematics/testing'; +import {createTestApp} from '../../../../cdk/schematics/testing'; import {runfiles} from '@bazel/runfiles'; import {compileString} from 'sass'; import * as path from 'path'; import {createLocalAngularPackageImporter} from '../../../../../tools/sass/local-sass-importer'; -import {ColorPalettes, generateSCSSTheme, getColorPalettes} from './index'; +import {ColorPalettes, generateSCSSTheme, getColorPalettes} from './index_bundled'; import {Schema} from './schema'; -// Note: For Windows compatibility, we need to resolve the directory paths through runfiles -// which are guaranteed to reside in the source tree. -const testDir = runfiles.resolvePackageRelative('../theme-color'); -const packagesDir = path.join(runfiles.resolveWorkspaceRelative('src/cdk/_index.scss'), '../..'); +const packagesDir = path.resolve('../../../..'); const localPackageSassImporter = createLocalAngularPackageImporter(packagesDir); describe('material-theme-color-schematic', () => { @@ -65,7 +62,7 @@ describe('material-theme-color-schematic', () => { } `, { - loadPaths: [testDir], + loadPaths: [], importers: [localPackageSassImporter], }, ).css.toString(); @@ -91,7 +88,7 @@ describe('material-theme-color-schematic', () => { } }); - describe('with scss output', async () => { + describe('with scss output', () => { it('should generate theme file', async () => { const tree = await runM3ThemeSchematic(runner, { primaryColor: '#984061', @@ -418,7 +415,7 @@ describe('material-theme-color-schematic', () => { }); }); - describe('with CSS output', async () => { + describe('with CSS output', () => { it('should generate m3 theme CSS file', async () => { const tree = await runM3ThemeSchematic(runner, { primaryColor: '#984061', diff --git a/src/material/schematics/ng-generate/theme-color/index_bundled.d.ts b/src/material/schematics/ng-generate/theme-color/index_bundled.d.ts new file mode 100644 index 000000000000..07066146182c --- /dev/null +++ b/src/material/schematics/ng-generate/theme-color/index_bundled.d.ts @@ -0,0 +1,11 @@ +/** + * @license + * Copyright Google LLC 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 + */ + +// Represents the bundled `index.ts` file. We bundle because of the external ESM +// dependency while schematics are executed as CommonJS. +export * from './index'; diff --git a/src/material/schematics/ng-generate/tree/index.spec.ts b/src/material/schematics/ng-generate/tree/index.spec.ts index d4d88822ba7a..65f1affbf815 100644 --- a/src/material/schematics/ng-generate/tree/index.spec.ts +++ b/src/material/schematics/ng-generate/tree/index.spec.ts @@ -1,5 +1,5 @@ import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; -import {createTestApp, getFileContent} from '@angular/cdk/schematics/testing'; +import {createTestApp, getFileContent} from '../../../../cdk/schematics/testing'; import {COLLECTION_PATH} from '../../paths'; import {Schema} from './schema'; diff --git a/src/material/schematics/ng-update/BUILD.bazel b/src/material/schematics/ng-update/BUILD.bazel index d6eb41c5c2dc..2666465160dd 100644 --- a/src/material/schematics/ng-update/BUILD.bazel +++ b/src/material/schematics/ng-update/BUILD.bazel @@ -1,9 +1,7 @@ -load("//tools:defaults.bzl", "esbuild", "jasmine_node_test", "spec_bundle", "ts_library") +load("//tools:defaults.bzl", "esbuild") +load("//tools:defaults2.bzl", "jasmine_test", "ts_project") -## THIS ONE IS ESM -# By default everything is ESM -# ESBUild needs ESM for bundling. Cannot reliably use CJS as input. -ts_library( +ts_project( name = "ng_update_lib", srcs = glob( ["**/*.ts"], @@ -11,18 +9,16 @@ ts_library( "test-cases/**/*.ts", ], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", + tsconfig = "//src/material/schematics:tsconfig", deps = [ - "//src/cdk/schematics", - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@schematics/angular", - "@npm//@types/node", - "@npm//postcss", - "@npm//postcss-scss", - "@npm//typescript", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@schematics/angular", + "//:node_modules/@types/node", + "//:node_modules/postcss", + "//:node_modules/postcss-scss", + "//:node_modules/typescript", + "//src/material/schematics:node_modules/@angular/cdk/schematics", ], ) @@ -36,7 +32,6 @@ esbuild( "@angular-devkit/core", "typescript", ], - # TODO: Switch to ESM when Angular CLI supports it. format = "cjs", output = "index_bundled.js", platform = "node", @@ -45,10 +40,6 @@ esbuild( deps = [":ng_update_lib"], ) -################# -## Specs -################# - filegroup( name = "schematics_test_cases", testonly = True, @@ -58,46 +49,30 @@ filegroup( ]), ) -# This one is now ESM, the default in the repository -# Needs to be ESM because we import frm `ng_update_lib` (which is also ESM) -ts_library( +ts_project( name = "test_lib", testonly = True, srcs = glob(["**/*.spec.ts"]), + tsconfig = "//src/material/schematics:tsconfig-test", deps = [ - ":ng_update_lib", - "//src/cdk/schematics", - "//src/cdk/schematics/testing", - "//src/material/schematics:paths", - "@npm//@angular-devkit/core", - "@npm//@angular-devkit/schematics", - "@npm//@bazel/runfiles", - "@npm//@types/jasmine", - "@npm//@types/node", + ":ng_update_lib_rjs", + "//:node_modules/@angular-devkit/core", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@bazel/runfiles", + "//src/cdk/schematics/testing:testing_rjs", + "//src/material/schematics:node_modules/@angular/cdk/schematics", + "//src/material/schematics:paths_rjs", ], ) -spec_bundle( - name = "spec_bundle", - external = [ - "*/paths.js", - "@angular-devkit/core/node", - ], - platform = "cjs-legacy", - target = "es2020", - deps = [":test_lib"], -) - -jasmine_node_test( +jasmine_test( name = "test", data = [ - ":ng_update_index", ":schematics_test_cases", - "//src/cdk/schematics", + ":test_lib_rjs", "//src/material/schematics:collection_assets", + "//src/material/schematics:node_modules/@angular/cdk/schematics", + "//src/material/schematics:package_json", ], shard_count = 4, - deps = [ - ":spec_bundle", - ], ) diff --git a/src/material/schematics/ng-update/test-cases/index.spec.ts b/src/material/schematics/ng-update/test-cases/index.spec.ts index 824ee60dedc4..45af0a6c271d 100644 --- a/src/material/schematics/ng-update/test-cases/index.spec.ts +++ b/src/material/schematics/ng-update/test-cases/index.spec.ts @@ -1,5 +1,8 @@ import {getAllVersionNames} from '@angular/cdk/schematics'; -import {defineJasmineTestCases, findBazelVersionTestCases} from '@angular/cdk/schematics/testing'; +import { + defineJasmineTestCases, + findBazelVersionTestCases, +} from '../../../../cdk/schematics/testing/index'; import {MIGRATION_PATH} from '../../paths'; describe('Material upgrade test cases', () => { diff --git a/src/material/schematics/ng-update/tsconfig.json b/src/material/schematics/ng-update/tsconfig.json deleted file mode 100644 index 695bc2ef40b4..000000000000 --- a/src/material/schematics/ng-update/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// For IDE -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "module": "esnext", - "target": "es2015" - } -} diff --git a/src/material/schematics/tsconfig-test.json b/src/material/schematics/tsconfig-test.json new file mode 100644 index 000000000000..6b63c9589e00 --- /dev/null +++ b/src/material/schematics/tsconfig-test.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": ["jasmine", "node"] + }, + "exclude": [] +} diff --git a/src/material/schematics/tsconfig.json b/src/material/schematics/tsconfig.json index 227597b4f5cb..3a72ab670281 100644 --- a/src/material/schematics/tsconfig.json +++ b/src/material/schematics/tsconfig.json @@ -1,30 +1,17 @@ { "compilerOptions": { - "lib": ["es2017"], - "module": "commonjs", - "moduleResolution": "node", - "outDir": "../../../dist/packages/material/schematics", - "noEmitOnError": false, - "strictNullChecks": true, - "noPropertyAccessFromIndexSignature": true, - "useUnknownInCatchVariables": true, - "noImplicitOverride": true, - "noImplicitAny": true, - "noFallthroughCasesInSwitch": true, - "noImplicitThis": true, - "noImplicitReturns": true, - "skipDefaultLibCheck": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "strictFunctionTypes": true, + "lib": ["es2022"], + "target": "es2022", + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, "skipLibCheck": true, "sourceMap": true, "declaration": true, - "target": "es6", "types": ["jasmine", "node"], - "baseUrl": ".", "paths": { - "@angular/cdk/schematics": ["../../cdk/schematics"] + "@angular/cdk/schematics": ["../../cdk/schematics"], + "@angular/cdk/schematics/*": ["../../cdk/schematics/*"] } }, "exclude": [ @@ -35,8 +22,5 @@ "ng-generate/*/files/**/*.ts", // Exclude all test-case files because those should not be included in the schematics output. "ng-update/test-cases/**/*.ts" - ], - "bazelOptions": { - "suppressTsconfigOverrideWarnings": true - } + ] } diff --git a/src/youtube-player/schematics/BUILD.bazel b/src/youtube-player/schematics/BUILD.bazel index e6dd9670bb45..21d783a8087a 100644 --- a/src/youtube-player/schematics/BUILD.bazel +++ b/src/youtube-player/schematics/BUILD.bazel @@ -1,26 +1,27 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin") -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm") +load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) copy_to_bin( name = "schematics_assets", - srcs = glob(["**/*.json"]), + srcs = glob( + ["**/*.json"], + exclude = ["tsconfig.json"], + ), ) -ts_library( +ts_project( name = "schematics", srcs = glob( ["**/*.ts"], exclude = ["**/*.spec.ts"], ), - # Schematics can not yet run in ESM module. For now we continue to use CommonJS. - # TODO(ESM): remove this once the Angular CLI supports ESM schematics. - devmode_module = "commonjs", - prodmode_module = "commonjs", + tsconfig = "tsconfig.json", deps = [ - "@npm//@angular-devkit/schematics", - "@npm//@types/node", + "//:node_modules/@angular-devkit/schematics", + "//:node_modules/@types/node", ], ) diff --git a/src/youtube-player/schematics/tsconfig.json b/src/youtube-player/schematics/tsconfig.json new file mode 100644 index 000000000000..41932c86a248 --- /dev/null +++ b/src/youtube-player/schematics/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "node10", + "strict": true, + "sourceMap": true, + "declaration": true + } +} diff --git a/tools/defaults2.bzl b/tools/defaults2.bzl index 30438f639922..c500b4240d3e 100644 --- a/tools/defaults2.bzl +++ b/tools/defaults2.bzl @@ -1,6 +1,10 @@ load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test") load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project") load("//tools/bazel:module_name.bzl", "compute_module_name") +load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package") + +def npm_package(**kwargs): + _npm_package(**kwargs) def ts_project( name,