Skip to content

Commit b343c83

Browse files
committed
refactor: use native browserslist 'baseline' query
With the release of browserslist v4.26.0, the 'baseline' query is now natively supported. This removes the need for a custom tool to generate the browserslist configuration. See: browserslist/browserslist#903
1 parent 48e85ef commit b343c83

22 files changed

+58
-251
lines changed

.bazelignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ packages/ngtools/webpack/node_modules
1717
packages/schematics/angular/node_modules
1818
modules/testing/builder/node_modules
1919
tests/node_modules
20-
tools/baseline_browserslist/node_modules

MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ npm.npm_translate_lock(
153153
"//packages/ngtools/webpack:package.json",
154154
"//packages/schematics/angular:package.json",
155155
"//tests:package.json",
156-
"//tools/baseline_browserslist:package.json",
157156
],
158157
lifecycle_hooks_envs = {
159158
# TODO: Standardize browser management for `rules_js`

docs/process/release.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ will block the next weekly release.
123123
pnpm ng-dev release build
124124
```
125125
1. Log in to NPM as `angular`.
126+
126127
```shell
127128
npm login
128129
```
130+
129131
- See these two Valentine entries for authentication details:
130132
- https://valentine.corp.google.com/#/show/1460636514618735
131133
- https://valentine.corp.google.com/#/show/1531867371192103
134+
132135
1. Publish the release.
133136
```shell
134137
(cd dist/releases/my-scope/my-pkg/ && npm publish --access public)
@@ -161,17 +164,10 @@ A few weeks before a major (around feature freeze):
161164
- Picking a date at the end of a month makes it easier to cross-reference
162165
Angular's support with other tools (like MDN) which state Baseline support
163166
using month specificity.
164-
- You can view the generated `browserlist` configuration with:
165-
```shell
166-
bazel build //packages/angular/build:angular_browserslist
167-
cat dist/bin/packages/angular/build/.browserslistrc
168-
```
169167
- Commit and merge the change, no other alterations or automation is
170168
necessary in the CLI repo.
171-
2. Update
172-
[`/.browserslistrc`](https://github.com/ng-packagr/ng-packagr/tree/main/.browserslistrc)
173-
in the `ng-packagr` repo.
174-
- Use the generated configuration from above.
169+
2. Update the date in the `ng-packagr` repo.
170+
[`/.stylesheet-processor.ts`](https://github.com/ng-packagr/ng-packagr/blob/main/src/lib/styles/stylesheet-processor.ts#L25).
175171
3. Update
176172
[`angular.dev` documentation](https://github.com/angular/angular/tree/main/adev/src/content/reference/versions.md#browser-support)
177173
to specify the date used and link to [browsersl.ist](https://browsersl.ist)

packages/angular/build/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
load("@devinfra//bazel/api-golden:index.bzl", "api_golden_test_npm_package")
22
load("@npm//:defs.bzl", "npm_link_all_packages")
3-
load("//:constants.bzl", "BASELINE_DATE")
43
load("//tools:defaults.bzl", "copy_to_bin", "jasmine_test", "npm_package", "ts_project")
54
load("//tools:ts_json_schema.bzl", "ts_json_schema")
6-
load("//tools/baseline_browserslist:baseline_browserslist.bzl", "baseline_browserslist")
75

86
licenses(["notice"])
97

@@ -46,12 +44,6 @@ copy_to_bin(
4644
srcs = glob(["**/schema.json"]),
4745
)
4846

49-
baseline_browserslist(
50-
name = "angular_browserslist",
51-
out = ".browserslistrc",
52-
baseline = BASELINE_DATE,
53-
)
54-
5547
RUNTIME_ASSETS = glob(
5648
include = [
5749
"src/**/schema.json",
@@ -62,7 +54,6 @@ RUNTIME_ASSETS = glob(
6254
) + [
6355
"builders.json",
6456
"package.json",
65-
":angular_browserslist",
6657
]
6758

6859
ts_project(
@@ -343,6 +334,7 @@ npm_package(
343334
"src/utils/version.js",
344335
"src/tools/esbuild/utils.js",
345336
"src/utils/normalize-cache.js",
337+
"src/utils/supported-browsers.js",
346338
],
347339
tags = ["release-package"],
348340
deps = RUNTIME_ASSETS + [

packages/angular/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@inquirer/confirm": "5.1.18",
2727
"@vitejs/plugin-basic-ssl": "2.1.0",
2828
"beasties": "0.3.5",
29-
"browserslist": "^4.23.0",
29+
"browserslist": "^4.26.0",
3030
"esbuild": "0.25.9",
3131
"https-proxy-agent": "7.0.6",
3232
"istanbul-lib-instrument": "6.0.3",

packages/angular/build/src/utils/supported-browsers.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
import browserslist from 'browserslist';
1010

11+
// The below is replaced by bazel `npm_package`.
12+
const BASELINE_DATE = 'BASELINE-DATE-PLACEHOLDER';
13+
1114
export function getSupportedBrowsers(
1215
projectRoot: string,
1316
logger: { warn(message: string): void },
1417
): string[] {
1518
// Read the browserslist configuration containing Angular's browser support policy.
16-
const angularBrowserslist = browserslist(undefined, {
17-
path: require.resolve('../../.browserslistrc'),
18-
});
19+
const angularBrowserslist = browserslist(`baseline widely available on ${getBaselineDate()}`);
1920

2021
// Use Angular's configuration as the default.
2122
browserslist.defaults = angularBrowserslist;
@@ -60,3 +61,8 @@ export function getSupportedBrowsers(
6061

6162
return Array.from(browsersFromConfigOrDefault);
6263
}
64+
65+
function getBaselineDate(): string {
66+
// Unlike `npm_package`, `ts_project` which is used to run unit tests does not support substitutions.
67+
return BASELINE_DATE[0] === 'B' ? '2025-01-01' : BASELINE_DATE;
68+
}

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"ansi-colors": "4.1.3",
2626
"autoprefixer": "10.4.21",
2727
"babel-loader": "10.0.0",
28-
"browserslist": "^4.21.5",
28+
"browserslist": "^4.26.0",
2929
"copy-webpack-plugin": "13.0.1",
3030
"css-loader": "7.1.2",
3131
"esbuild-wasm": "0.25.9",

packages/schematics/angular/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
# found in the LICENSE file at https://angular.dev/license
55

66
load("@npm//:defs.bzl", "npm_link_all_packages")
7-
load("//:constants.bzl", "BASELINE_DATE")
87
load("//tools:defaults.bzl", "copy_to_bin", "jasmine_test", "npm_package", "ts_project")
98
load("//tools:ts_json_schema.bzl", "ts_json_schema")
10-
load("//tools/baseline_browserslist:baseline_browserslist.bzl", "baseline_browserslist")
119

1210
licenses(["notice"])
1311

@@ -44,18 +42,11 @@ copy_to_bin(
4442
srcs = glob(["**/schema.json"]),
4543
)
4644

47-
baseline_browserslist(
48-
name = "angular_browserslist",
49-
out = "config/.browserslistrc",
50-
baseline = BASELINE_DATE,
51-
)
52-
5345
RUNTIME_ASSETS = [
5446
"collection.json",
5547
"migrations/migration-collection.json",
5648
"package.json",
5749
"utility/latest-versions/package.json",
58-
":angular_browserslist",
5950
] + glob(
6051
include = [
6152
"*/schema.json",
@@ -156,6 +147,7 @@ npm_package(
156147
"//packages/angular_devkit/core:package.json",
157148
],
158149
stamp_files = [
150+
"config/index.js",
159151
"utility/latest-versions.js",
160152
],
161153
tags = ["release-package"],

packages/schematics/angular/config/files/.browserslistrc.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# You can see what browsers were selected by your queries by running:
99
# npx browserslist
1010

11-
<%= config %>
11+
baseline widely available on <%= baselineDate %>

packages/schematics/angular/config/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
strings,
1818
url,
1919
} from '@angular-devkit/schematics';
20-
import { readFile } from 'node:fs/promises';
2120
import { posix as path } from 'node:path';
2221
import { relativePathToWorkspaceRoot } from '../utility/paths';
2322
import { createProjectSchematic } from '../utility/project';
@@ -37,13 +36,11 @@ export default createProjectSchematic<ConfigOptions>((options, { project }) => {
3736
});
3837

3938
async function addBrowserslistConfig(projectRoot: string): Promise<Rule> {
40-
// Read Angular's default vendored `.browserslistrc` file.
41-
const config = await readFile(path.join(__dirname, '.browserslistrc'), 'utf8');
42-
4339
return mergeWith(
4440
apply(url('./files'), [
4541
filter((p) => p.endsWith('.browserslistrc.template')),
46-
applyTemplates({ config }),
42+
// The below is replaced by bazel `npm_package`.
43+
applyTemplates({ baselineDate: 'BASELINE-DATE-PLACEHOLDER' }),
4744
move(projectRoot),
4845
]),
4946
);

0 commit comments

Comments
 (0)