-
Notifications
You must be signed in to change notification settings - Fork 12k
Update .browserslistrc
to use Baseline
#30036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good to me although I am curious why we used this approach instead of extended the browserslist configuration.
Note: we also need to do the same in ng-packagr.
packages/angular/build/src/builders/application/tests/behavior/browser-support_spec.ts
Outdated
Show resolved
Hide resolved
Based on the feedback in angular/angular#60754 (comment) it looks like the used package is going away and instead extending the browserslist configuration is the preferred approach. |
I'm not sure
@alan-agius4 @tonypconway, do either of you see a better way to achieve this with |
We could adopt Looking at the code, both import bbm from 'baseline-browser-mapping';
const browsers = {
chrome: "Chrome",
chrome_android: "ChromeAndroid",
edge: "Edge",
firefox: "Firefox",
firefox_android: "FirefoxAndroid",
safari: "Safari",
safari_ios: "iOS",
};
const baselineBrowserslistConfig = bbm.getCompatibleVersions({
widelyAvailableOnDate: '2025-01-01',
includeDownstreamBrowsers: false,
logConfigToConsole: false,
})
.filter((version) => browsers[version.browser])
.map((version) => `${browsers[version.browser]} >= ${version.version}`); This approach can be used with For We could also use the above to generate a static configuration. However, it might not be worth the extra complexities in the build process. |
If the end goal is absolutely a static
import { getCompatibleVersions } from `baseline-browser-mapping`; We have to use |
FYI, we've just released the latest version of |
df61433
to
46f963b
Compare
I started looking into
My reasoning for this is because AIUI (feel free to correct me), a strict interpretation of Baseline does not cover downstream browsers. Therefore Angular's support policy would not cover them and I'd like the implementation here to be as close to the stated policy as reasonably possible. I'm certainly open to including those or having the CLI slightly diverge from stated policy if there's a compelling reason to do so. My immediate thinking is that it doesn't actually matter for the CLI if we're assuming that downstream browsers are functionally equivalent to their upstream versions (not sure how entirely true that is, but likely mostly true?). If so, then adding QQ or UC wouldn't actually change the behavior of Angular CLI's build process, since an equivalent upstream browser would already be present.
This is a good point, I like the idea of Updated the schematic to generate this. I ended up dropping That also means that this config needs to install |
384eb6f
to
6c8b37d
Compare
Resolved the build issues and updated to use |
This commit updates the `browserslist` configuration to use browsers generated by Baseline. The exact list is pulled from angular/angular-cli#30036. Ideally this should be generated at build time from a raw date string like the Angular CLI repo does, however this would duplicate the tooling and isn't strictly necessary anyways as the release process already requires extracting the generated browser versions purely for documentation. Also copying that configuration to `ng-packagr` is not significantly more toil.
packages/angular/build/tools/baseline_browserslist/generate_browserslist.mts
Outdated
Show resolved
Hide resolved
packages/angular/build/tools/baseline_browserslist/generate_browserslist.mts
Outdated
Show resolved
Hide resolved
packages/angular/build/tools/baseline_browserslist/baseline_browserslist.bzl
Outdated
Show resolved
Hide resolved
packages/angular/build/tools/baseline_browserslist/tsconfig-build.json
Outdated
Show resolved
Hide resolved
visibility = ["//packages/angular/build:__subpackages__"], | ||
) | ||
|
||
ts_project( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unnecessarily, we shouldn't need two ts_projects
here to build the script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just being extra fine-grained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a bit of overkill to create two separate projects for just two files especially when one file depends on the other.
618fe19
to
e5a962f
Compare
Strict deps test failures seem to be a bug in the upstream infra: angular/dev-infra#2738. |
9ff69f6
to
7a138f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @dgp1130, happy to see that we finally got there. Good work!
Just 3 optional NITs.
- Remove extra fields from package.json
- Reduce ts_projects
- Node.js Promise imports.
- Update renovate config to include the new package.json
This tool uses `baseline-browser-mapping` to generate a `browserslist` configuration at build time from a given widely-available Baseline date. I opted _not_ to use "downstream browsers". This refers to browsers like Opera, which technically uses Blink and shares the same featureset as Chrome for a particular version. I decided against this to maintain a stricter interpretation of Baseline, given that those browsers are not included in Baseline today. Developers can manually widen their own `.browserslistrc` if they really want to and are comfortable accepting the risks that brings. Using `baseline-browser-mapping` as part of the build process means there is a potential risk that a bugfix in the package generates a different browserslist file which leads to a different build configuration that causes a problem for existing users. However, it's also just as likely (if not moreso) to fix a problem than cause one, so I'm inclined to call that WAI. If it becomes an issue in the future, we can potentially check in the generated `.browserslistrc` file itself rather than the Baseline date, meaning the list of browsers would be frozen until we explicitly update it between majors.
…le Baseline This commit includes a Baseline widely-available date which is hard-coded in `buid_vars.bzl` and used to generate a `.browserslistrc` file at build-time. Using a browser outside of Angular's minimum defined browser set is still allowed as we expect that _most_ of the time this will work just fine. However, we log a warning to be clear to users that they are outside Angular's supported browserset. I've currently pinned Angular to the March 31st baseline, but this will likely be updated again as we get closer to the v20 release. The current set of browsers generated are: ``` Chrome >= 107 ChromeAndroid >= 107 Edge >= 107 Firefox >= 104 FirefoxAndroid >= 104 Safari >= 16 iOS >= 16 ```
… config browserslist` This changes `ng generate config browserslist` to no longer generate a list of browsers used by Angular, but instead generate a dependency on `browserslist-config-baseline` and configures the date to match Angular. This used to generate a `.browserslistrc` file, however since the config is a single line and `browserslist-config-baseline` requires a separate config in the `package.json`, it feels a little more ergonomic to put both in the `package.json` file instead.
Done.
Done.
Done.
I think it's already covered by the |
This changes the default
.browserslistrc
file to one generated from a Baseline "widely available" date usingbaseline-browser-mapping
, codifying the policy change from angular/angular#60754 into the Angular CLI.This effectively pins the
.browserslistrc
file to a hard-coded Baseline date, preventing it from automatically updating based oncaniuse-lite
versions managed in user workspaces, which should make Angular's tooling much more stable. Prior to this, expressions like "last 2 Chrome versions" were relative to the installedcaniuse-lite
version and could update at any time. By pinning.browserslistrc
, we're ensuring that supported browsers only change during Angular major version updates, not arbitrarycaniuse-lite
updates.Angular CLI now warns if users define a custom
.browserslistrc
which includes browsers beyond Angular's support policy, however we do not error or prevent it, given that Angular is pretty stable as a framework and generally does not require newly released web features, so targeting older browser versions is very likely to work. However we still warn in this case because it is explicitly outside Angular's support policy and is not guaranteed to work.baseline-browser-mapping
is used as a dev dependency which generates a.browserslistrc
that is vendored in the NPM package. This reduces proliferation of the dependency where not needed. Shout out to @tonypconway for buildingbaseline-browser-mapping
, which makes managing this configuration significantly easier.See individual commits for notes on the implementation.
ng-packagr/ng-packagr#3034 makes a similar update for
ng-packagr
.