├── .editorconfig ├── .github └── workflows │ └── release.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── 2016.js ├── 2017.js ├── 2018.js ├── 2019.js ├── 2020.js ├── 2021.js ├── 2022.js ├── 2023.js ├── 2024.js ├── LICENSE.txt ├── README.md ├── assets ├── icon.svg └── icon.svg.license.txt ├── bun.lockb ├── index.js ├── package.json ├── scripts ├── compare-versions-warning.js ├── get-baseline-versions.js └── update-last-updated.js ├── test.mjs └── with-downstream ├── 2016.js ├── 2017.js ├── 2018.js ├── 2019.js ├── 2020.js ├── 2021.js ├── 2022.js ├── 2023.js ├── 2024.js └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{package.json,**/package.json,*.yml,.eslintrc.json,*.md}] 12 | indent_style = space 13 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: ['*'] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | 15 | - name: Set up Bun 16 | uses: oven-sh/setup-bun@v2 17 | with: 18 | bun-version: latest 19 | 20 | - name: Publish package 21 | env: 22 | NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }} 23 | run: bun publish --access public 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # NPM package lock 14 | package-lock.json 15 | 16 | # Caches 17 | 18 | .cache 19 | 20 | # Diagnostic reports (https://nodejs.org/api/report.html) 21 | 22 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 23 | 24 | # Runtime data 25 | 26 | pids 27 | _.pid 28 | _.seed 29 | *.pid.lock 30 | 31 | # Directory for instrumented libs generated by jscoverage/JSCover 32 | 33 | lib-cov 34 | 35 | # Coverage directory used by tools like istanbul 36 | 37 | coverage 38 | *.lcov 39 | 40 | # nyc test coverage 41 | 42 | .nyc_output 43 | 44 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 45 | 46 | .grunt 47 | 48 | # Bower dependency directory (https://bower.io/) 49 | 50 | bower_components 51 | 52 | # node-waf configuration 53 | 54 | .lock-wscript 55 | 56 | # Compiled binary addons (https://nodejs.org/api/addons.html) 57 | 58 | build/Release 59 | 60 | # Dependency directories 61 | 62 | node_modules/ 63 | jspm_packages/ 64 | 65 | # Snowpack dependency directory (https://snowpack.dev/) 66 | 67 | web_modules/ 68 | 69 | # TypeScript cache 70 | 71 | *.tsbuildinfo 72 | 73 | # Optional npm cache directory 74 | 75 | .npm 76 | 77 | # Optional eslint cache 78 | 79 | .eslintcache 80 | 81 | # Optional stylelint cache 82 | 83 | .stylelintcache 84 | 85 | # Microbundle cache 86 | 87 | .rpt2_cache/ 88 | .rts2_cache_cjs/ 89 | .rts2_cache_es/ 90 | .rts2_cache_umd/ 91 | 92 | # Optional REPL history 93 | 94 | .node_repl_history 95 | 96 | # Output of 'npm pack' 97 | 98 | *.tgz 99 | 100 | # Yarn Integrity file 101 | 102 | .yarn-integrity 103 | 104 | # dotenv environment variable files 105 | 106 | .env 107 | .env.development.local 108 | .env.test.local 109 | .env.production.local 110 | .env.local 111 | 112 | # parcel-bundler cache (https://parceljs.org/) 113 | 114 | .parcel-cache 115 | 116 | # Next.js build output 117 | 118 | .next 119 | out 120 | 121 | # Nuxt.js build / generate output 122 | 123 | .nuxt 124 | dist 125 | 126 | # Gatsby files 127 | 128 | # Comment in the public line in if your project uses Gatsby and not Next.js 129 | 130 | # https://nextjs.org/blog/next-9-1#public-directory-support 131 | 132 | # public 133 | 134 | # vuepress build output 135 | 136 | .vuepress/dist 137 | 138 | # vuepress v2.x temp and cache directory 139 | 140 | .temp 141 | 142 | # Docusaurus cache and generated files 143 | 144 | .docusaurus 145 | 146 | # Serverless directories 147 | 148 | .serverless/ 149 | 150 | # FuseBox cache 151 | 152 | .fusebox/ 153 | 154 | # DynamoDB Local files 155 | 156 | .dynamodb/ 157 | 158 | # TernJS port file 159 | 160 | .tern-port 161 | 162 | # Stores VSCode versions used for testing VSCode extensions 163 | 164 | .vscode-test 165 | 166 | # yarn v2 167 | 168 | .yarn/cache 169 | .yarn/unplugged 170 | .yarn/build-state.yml 171 | .yarn/install-state.gz 172 | .pnp.* 173 | 174 | # IntelliJ based IDEs 175 | .idea 176 | 177 | # Finder (MacOS) folder config 178 | .DS_Store 179 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | bun.lockb 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": false, 3 | "quoteProps": "preserve", 4 | "trailingComma": "all" 5 | } 6 | -------------------------------------------------------------------------------- /2016.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2016 }); 3 | -------------------------------------------------------------------------------- /2017.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2017 }); 3 | -------------------------------------------------------------------------------- /2018.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2018 }); 3 | -------------------------------------------------------------------------------- /2019.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2019 }); 3 | -------------------------------------------------------------------------------- /2020.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2020 }); 3 | -------------------------------------------------------------------------------- /2021.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2021 }); 3 | -------------------------------------------------------------------------------- /2022.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2022 }); 3 | -------------------------------------------------------------------------------- /2023.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2023 }); 3 | -------------------------------------------------------------------------------- /2024.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ baselineYear: 2024 }); 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Baseline Widely Available logo browserslist-config-baseline 2 | 3 | A [browserslist](https://www.npmjs.com/package/browserslist) config based on [Web Platform Baseline](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility). 4 | 5 | Baseline identifies web platform features that work across browsers. Baseline helps you decide when to use a feature by telling you when it is less likely to cause compatibility problems for your site's visitors. There are two ways of targeting a Baseline feature set: 6 | 7 | 1. [Baseline Widely Available](#baseline-widely-available) - includes all features that were fully supported in Chrome, Edge, Firefox and Safari **30 months before the current date**. 8 | 2. [Baseline year feature sets](#baseline-year-feature-sets) - includes all features that were fully supported in Chrome, Edge, Firefox and Safari **at the end of a given calendar year**. 9 | 10 | You should check your analytics to see which browser versions are prevalent in your userbase before selecting a Baseline target. 11 | 12 | ## Installation 13 | 14 | To add `browserslist-config-baseline` to your project, use one of the following commands: 15 | 16 | ```sh 17 | # npm 18 | npm i browserslist-config-baseline 19 | # yarn 20 | yarn add browserslist-config-baseline 21 | # bun 22 | bun add browserslist-config-baseline 23 | ``` 24 | 25 | ## Baseline Widely Available 26 | 27 | To target Baseline Widely Available, add the following to your `package.json`: 28 | 29 | 30 | ```json 31 | { 32 | "browserslist": [ 33 | "extends browserslist-config-baseline" 34 | ] 35 | } 36 | ``` 37 | 38 | If you want to see your list of chosen browsers every time `browserslist` calls `browserslist-baseline-config`, add a `browserslist-config-baseline` object to your `package.json` with `logConfigToConsole` set to `true`: 39 | 40 | 41 | ```json 42 | { 43 | "browserslist": [ 44 | "extends browserslist-config-baseline" 45 | ], 46 | "browserslist-config-baseline": { 47 | "logConfigToConsole": true 48 | } 49 | } 50 | ``` 51 | 52 | The `logConfigToConsole` option works with both of the target configuration options mentioned below. 53 | 54 | The data in this package changes frequently as new browser versions are released and new web-features become interoperable. Consider updating this module regularly by adding one of these commands to your build scripts: 55 | 56 | ```sh 57 | # npm 58 | npm i browserslist-config-baseline@latest 59 | 60 | # yarn 61 | yarn upgrade --latest browserslist-config-baseline 62 | 63 | # bun 64 | bun update browserslist-config-baseline@latest 65 | ``` 66 | 67 | If you haven't updated `browserslist-config-baseline` in the last month and you are targeting Widely Available, the package will check for updates whenever you run a `browserslist`-compatible tool and prompt you to upgrade if there is a new version available. 68 | 69 | ## Configuring `browserslist-config-baseline` 70 | 71 | There are two ways to configure `browserslist-config-basesline`: 72 | 73 | - [Add options to the end of your `extends` statement](#configuring-targets-using-the-extends-statement). 74 | - Using a `browserslist-config-baseline` configuration object in your `package.json`. 75 | 76 | ## Configuring targets using the `extends` statement 77 | 78 | ### Baseline year feature sets 79 | 80 | Baseline year feature sets include all the web platform features that were fully supported in the core browser set at the end of a given calendar year. To use a Baseline year feature set, add the year in the format `/YYYY` to the end of your `extends` statement: 81 | 82 | 83 | ```json 84 | { 85 | "browserslist": [ 86 | "extends browserslist-config-baseline/2020" 87 | ] 88 | } 89 | ``` 90 | 91 | This equates to the following `browserslist` config: 92 | 93 | ```json 94 | { 95 | "browserslist": [ 96 | "Chrome >= 87", 97 | "ChromeAndroid >= 87", 98 | "Edge >= 87", 99 | "Firefox >= 83", 100 | "FirefoxAndroid >= 83", 101 | "Safari >= 14", 102 | "iOS >= 14" 103 | ] 104 | } 105 | ``` 106 | 107 | The minimum browser versions that support these feature sets are usually the last version released in that year or a few versions earlier. The feature set > browser version mappings in this module were determined using [`baseline-browser-mapping`](https://npmjs.org/baseline-browser-mapping). 108 | 109 | ### Include Chromium downstream browsers 110 | 111 | To include browsers that implement Chromium where possible, insert `/with-downstream` into your `extends` statement immediately after the package name: 112 | 113 | 114 | ```json 115 | { 116 | "browserslist": [ 117 | "extends browserslist-config-baseline/with-downstream/2020" 118 | ] 119 | } 120 | ``` 121 | 122 | This equates to the following `browserslist` config: 123 | 124 | ```json 125 | { 126 | "browserslist": [ 127 | "Chrome >= 87", 128 | "ChromeAndroid >= 87", 129 | "Edge >= 87", 130 | "Firefox >= 83", 131 | "FirefoxAndroid >= 83", 132 | "Safari >= 14", 133 | "iOS >= 14", 134 | "Opera >= 73", 135 | "op_mob >= 62", 136 | "Samsung >= 14.0", 137 | "Android >= 87", 138 | "and_uc >= 15.3", 139 | "and_qq >= 11.7" 140 | ] 141 | } 142 | ``` 143 | 144 | The minimum browser versions of non-core browsers are provided by `baseline-browser-mapping` based on two sources: [`@mdn/browser-compat-data`](https://npmjs.org/@mdn/browsers-compat-data) where those engine version mappings exist, and parsed user agents from [`useragents.io`](https://useragents.io) where necessary. For more information on these mappings, please see [`baseline-browser-mapping`'s README](https://www.npmjs.com/package/baseline-browser-mapping#downstream-browsers). 145 | 146 | ## Configuring targets using a `browserslist-config-baseline` object in `package.json` 147 | 148 | You can add a `browserslist-config-baseline` object to your `package.json` to set your Baseline target. 149 | 150 | > **NOTE** 151 | > The `browserslist-config-baseline` config in `package.json` only works if you use the basic `extends` statement. If you add a `YYYY` year and/or `with-downstream` to your `extends` statement, that will take precedence over the target settings in your `browserslist-config-baseline` object. The `logConfigToConsole` option works with both config methods. 152 | 153 | ### Target Baseline year feature sets 154 | 155 | To target a Baseline year, set the `baselineYear` property to the desired year: 156 | 157 | 158 | ```json 159 | { 160 | "browserslist": [ 161 | "extends browserslist-config-baseline" 162 | ], 163 | "browserslist-config-baseline": { 164 | "baselineYear": 2020 165 | } 166 | } 167 | ``` 168 | 169 | > **NOTE** 170 | > You cannot use the `baselineYear` and `widelyAvailableOnDate` options together. The `baseline-browser-mapping` module that supplies data to `browserslist-config-baseline` will throw an error. 171 | 172 | ### Target Baseline Widely available on a particular date 173 | 174 | To target Baseline Widely available on a particular date, set the `widelyAvailableOnDate` property to the desired date in the format `YYYY-MM-DD`: 175 | 176 | 177 | ```json 178 | { 179 | "browserslist": [ 180 | "extends browserslist-config-baseline" 181 | ], 182 | "browserslist-config-baseline": { 183 | "widelyAvailableOnDate": "2020-06-01" 184 | } 185 | } 186 | ``` 187 | 188 | > **NOTE** 189 | > You cannot use the `baselineYear` and `widelyAvailableOnDate` options together. The `baseline-browser-mapping` module that supplies data to `browserslist-config-baseline` will throw an error. 190 | 191 | ### Include downstream browsers 192 | 193 | To include browsers the implement Chromium, set the `includeDownstreamBrowsers` property to `true`: 194 | 195 | 196 | ```json 197 | { 198 | "browserslist": [ 199 | "extends browserslist-config-baseline" 200 | ], 201 | "browserslist-config-baseline": { 202 | "includeDownstreamBrowsers": true 203 | } 204 | } 205 | ``` 206 | 207 | ## Logging your config to the console 208 | 209 | To see the array of minimum browser versions that you are passing to `browserslist`, add `logConfigToConsole: true` to your `package.json` config: 210 | 211 | ```json 212 | { 213 | "browserslist-config-baseline": { 214 | "logConfigToConsole": true 215 | } 216 | } 217 | ``` 218 | 219 | This works with both methods of setting your target browsers. 220 | 221 | ## See also 222 | 223 | - [WebDX Baseline specification](https://github.com/web-platform-dx/web-features/blob/main/docs/baseline.md) 224 | - [Web Platform Status dashboard](https://webstatus.dev/) - a dashboard for checking the Baseline status of web platform features. 225 | -------------------------------------------------------------------------------- /assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /assets/icon.svg.license.txt: -------------------------------------------------------------------------------- 1 | icon.svg comes from MDN Web Docs frontend: 2 | https://github.com/mdn/yari/blob/b68eb39140aeb94aef9063eef868d0fcff5af060/client/src/assets/icons/baseline/high.svg 3 | 4 | SPDX-FileCopyrightText: 2023 Mozila Corporation and/or contributors 5 | SPDX-License-Identifier: MPL-2.0 6 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/web-platform-dx/browserslist-config-baseline/c741ccb7694b2dc39f5f467d653b16092afa22a1/bun.lockb -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("./scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions(); 3 | 4 | const compareVersions = require("./scripts/compare-versions-warning"); 5 | compareVersions(); 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "browserslist-config-baseline", 3 | "version": "0.4.0", 4 | "description": "A browserslist config based on Web Platform Baseline.", 5 | "license": "Apache-2.0", 6 | "author": { 7 | "name": "Alexander Pushkov", 8 | "email": "browserslist-config-baseline@ale.sh" 9 | }, 10 | "main": "index.js", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/web-platform-dx/browserslist-config-baseline.git" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/web-platform-dx/browserslist-config-baseline/issues" 17 | }, 18 | "scripts": { 19 | "test": "node test.mjs", 20 | "prepare-release": "node scripts/update-last-updated.js; npm version patch" 21 | }, 22 | "keywords": [ 23 | "browserslist", 24 | "browserslist-config", 25 | "mozilla", 26 | "baseline" 27 | ], 28 | "devDependencies": { 29 | "browserslist": "^4.23.1", 30 | "prettier": "^3.3.2" 31 | }, 32 | "dependencies": { 33 | "@httptoolkit/esm": "^3.3.1", 34 | "baseline-browser-mapping": "^2.2.0", 35 | "compare-versions": "^6.1.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /scripts/compare-versions-warning.js: -------------------------------------------------------------------------------- 1 | module.exports = function () { 2 | const lastUpdated = "2025-04-10"; 3 | 4 | const cv = require("compare-versions"); 5 | 6 | let dateOneMonthAgo = new Date(); 7 | dateOneMonthAgo.setMonth(new Date().getMonth() - 1); 8 | 9 | if (new Date(lastUpdated) < dateOneMonthAgo) { 10 | fetch("https://registry.npmjs.org/browserslist-config-baseline") 11 | .then((response) => response.json()) 12 | .then((data) => { 13 | const packageJson = require("../package.json"); 14 | const localVersion = packageJson.version; 15 | const remoteVersion = data["dist-tags"].latest; 16 | if (cv.compare(localVersion, remoteVersion, "<")) { 17 | console.warn( 18 | `\nYou are using browserlist-config-baseline version: ${localVersion}\n` + 19 | `The latest available version is: ${remoteVersion}\n` + 20 | "You may be using stale data. Please update browserslist-config-baseline\n" + 21 | "to ensure your config is accurate.\n\n" + 22 | " # If using npm, please run:\n" + 23 | " npm i browserslist-config-baseline@latest\n\n" + 24 | " # If using yarn, please run:\n" + 25 | " yarn upgrade --latest browserslist-config-baseline\n\n" + 26 | " # If using bun, please run:\n" + 27 | " bun update browserslist-config-baseline@latest\n\n" + 28 | "Consider adding whichever command is appropriate to your\n" + 29 | "build scripts to avoid seeing this message in future.\n", 30 | ); 31 | } 32 | }) 33 | .catch((err) => { 34 | console.log( 35 | `browserslist-config-basline encountered an error when trying to check your package version against the NPM registry.`, 36 | err, 37 | ); 38 | }); 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /scripts/get-baseline-versions.js: -------------------------------------------------------------------------------- 1 | require = require("@httptoolkit/esm")(module); 2 | bbm = require("baseline-browser-mapping"); 3 | 4 | const fs = require("fs"); 5 | const path = require("path"); 6 | 7 | function readConfig(loc, name) { 8 | do { 9 | try { 10 | const pkg = require(path.join(loc, "package.json")); 11 | if (pkg.hasOwnProperty(name)) return pkg[name]; 12 | } catch { } 13 | } while (loc !== (loc = path.dirname(loc))); 14 | 15 | return null; 16 | } 17 | 18 | function transform(bbm_versions) { 19 | const browsers = { 20 | chrome: "Chrome", 21 | chrome_android: "ChromeAndroid", 22 | edge: "Edge", 23 | firefox: "Firefox", 24 | firefox_android: "FirefoxAndroid", 25 | safari: "Safari", 26 | safari_ios: "iOS", 27 | webview_android: "Android", 28 | samsunginternet_android: "Samsung", 29 | opera_android: "op_mob", 30 | opera: "Opera", 31 | qq_android: "and_qq", 32 | uc_android: "and_uc", 33 | }; 34 | 35 | return bbm_versions 36 | .filter((version) => Object.keys(browsers).includes(version.browser)) 37 | .map((version) => `${browsers[version.browser]} >= ${version.version}`); 38 | } 39 | 40 | function reconcileConfigs(extendsConfig) { 41 | const bbmConfig = {}; 42 | 43 | const pkgConfig = 44 | readConfig(process.cwd(), "browserslist-config-baseline") ?? {}; 45 | 46 | // Handle correct configurations 47 | if (pkgConfig.widelyAvailableOnDate && !extendsConfig.baselineYear) 48 | bbmConfig.widelyAvailableOnDate = pkgConfig.widelyAvailableOnDate; 49 | 50 | if (pkgConfig.baselineYear && !extendsConfig.baselineYear) 51 | bbmConfig.targetYear = pkgConfig.baselineYear; 52 | 53 | if (extendsConfig.baselineYear && !pkgConfig.baselineYear) 54 | bbmConfig.targetYear = extendsConfig.baselineYear; 55 | 56 | if ( 57 | (extendsConfig.includeDownstreamBrowsers && 58 | !pkgConfig.includeDownstreamBrowsers) || 59 | (!extendsConfig.includeDownstreamBrowsers && 60 | pkgConfig.includeDownstreamBrowsers) || 61 | (extendsConfig.includeDownstreamBrowsers && 62 | pkgConfig.includeDownstreamBrowsers) 63 | ) 64 | bbmConfig.includeDownstreamBrowsers = true; 65 | 66 | // Check to see if there are two configured target years 67 | if (pkgConfig.baselineYear && extendsConfig.baselineYear) { 68 | bbmConfig.targetYear = Math.min( 69 | pkgConfig.baselineYear, 70 | extendsConfig.baselineYear, 71 | ); 72 | 73 | console.warn( 74 | `[browserslist-config-baseline] You’ve set baselineYear: ` + 75 | `${pkgConfig.baselineYear} in your package.json, but extended this ` + 76 | `config as \`browserslist-config-baseline/${extendsConfig.baselineYear}\`.\n` + 77 | `Proceeding with the lower option, baselineYear: ${bbmConfig.targetYear}.\n` + 78 | `Remove baselineYear in package.json or use \`extend browserslist-config-baseline\` ` + 79 | `to suppress this warning.`, 80 | ); 81 | } 82 | 83 | // Check to see if widelyAvailableOnDate is being used alongside extends .../YYYY 84 | if (pkgConfig.widelyAvailableOnDate && extendsConfig.baselineYear) { 85 | const widelyAvailableOnDate = new Date(pkgConfig.widelyAvailableOnDate); 86 | const baselineYearDate = new Date(extendsConfig.baselineYear + "-12-31"); 87 | 88 | let stringFragment = ""; 89 | 90 | if (widelyAvailableOnDate < baselineYearDate) { 91 | bbmConfig.widelyAvailableOnDate = pkgConfig.widelyAvailableOnDate; 92 | stringFragment += `Proceeding with the lower option, widelyAvailableOnDate: ${pkgConfig.widelyAvailableOnDate}.\n`; 93 | } else { 94 | bbmConfig.targetYear = extendsConfig.baselineYear; 95 | stringFragment += `Proceeding with the lower option, baselineYear: ${extendsConfig.baselineYear}.\n`; 96 | } 97 | 98 | console.warn( 99 | `[browserslist-config-baseline] You’ve set widelyAvailableOnDate: ` + 100 | `"${pkgConfig.widelyAvailableOnDate}" in your package.json, but extended this ` + 101 | `config as \`browserslist-config-baseline/${extendsConfig.baselineYear}\`.\n` + 102 | stringFragment + 103 | `Remove widelyAvailableOnDate in package.json or use \`extend browserslist-config-baseline\` ` + 104 | `to suppress this warning.`, 105 | ); 106 | } 107 | 108 | // Check to see if extends and package have conflicting includeDownstreamBrowsers 109 | if ( 110 | extendsConfig.includeDownstreamBrowsers && 111 | pkgConfig.includeDownstreamBrowsers === false 112 | ) { 113 | bbmConfig.includeDownstreamBrowsers = false; 114 | console.warn( 115 | `[browserslist-config-baseline]` + 116 | `You've extended your browserslist config using \`/with-downstream\` ` + 117 | `but set includeDownstreamBrowsers: false in package.json.\n` + 118 | `Proceeding with includeDownstreamBrowsers: false.\n` + 119 | `Remove includeDownstreamBrowsers: false in package.json or use` + 120 | `\`extend browserslist-config-baseline\` to suppress this warning.`, 121 | ); 122 | } 123 | 124 | return { 125 | bbmConfig: bbmConfig, 126 | logConfigToConsole: pkgConfig.logConfigToConsole ?? false, 127 | }; 128 | } 129 | 130 | module.exports = function (extendsConfig = {}) { 131 | const config = reconcileConfigs(extendsConfig); 132 | 133 | const versions = bbm.getCompatibleVersions(config.bbmConfig); 134 | const listToReturn = transform(versions); 135 | 136 | if (config.logConfigToConsole) { 137 | console.log( 138 | "Your browserslist config from browserslist-config-baseline is:\n", 139 | listToReturn, 140 | ); 141 | } 142 | 143 | return listToReturn; 144 | }; 145 | -------------------------------------------------------------------------------- /scripts/update-last-updated.js: -------------------------------------------------------------------------------- 1 | const fs = require("node:fs"); 2 | fs.readFile("./scripts/compare-versions-warning.js", "utf8", (err, data) => { 3 | if (err) { 4 | console.error(err); 5 | return; 6 | } 7 | const searchString = 'lastUpdated = "'; 8 | const replaceIndex = data.indexOf(searchString) + searchString.length; 9 | const todayDateString = new Date().toISOString().slice(0, 10); 10 | const outputString = 11 | data.substring(0, replaceIndex) + 12 | todayDateString + 13 | data.substring(replaceIndex + 10); 14 | fs.writeFileSync("./scripts/compare-versions-warning.js", outputString, { 15 | encoding: "utf8", 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /test.mjs: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import browserslist from "browserslist"; 3 | import config from "./index.js"; 4 | 5 | /** @type {{ [name: string]: string[] }} */ 6 | const browsers = browserslist(config).reduce((acc, current) => { 7 | const [name, version] = current.split(" ", 2); 8 | acc[name] ??= []; 9 | acc[name].push(version); 10 | return acc; 11 | }, {}); 12 | 13 | const wanted = [ 14 | "and_chr", 15 | "and_ff", 16 | "chrome", 17 | "edge", 18 | "firefox", 19 | "ios_saf", 20 | "safari", 21 | ]; 22 | 23 | for (const name of wanted) { 24 | assert(Object.hasOwn(browsers, name), `Should include ${name}`); 25 | } 26 | 27 | console.log(browsers); 28 | -------------------------------------------------------------------------------- /with-downstream/2016.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2016, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2017.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2017, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2018.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2018, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2019.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2019, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2020.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2020, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2021.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2021, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2022.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2022, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2023.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2023, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/2024.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ 3 | baselineYear: 2024, 4 | includeDownstreamBrowsers: true, 5 | }); 6 | -------------------------------------------------------------------------------- /with-downstream/index.js: -------------------------------------------------------------------------------- 1 | const getBaselineVersions = require("../scripts/get-baseline-versions"); 2 | module.exports = getBaselineVersions({ includeDownstreamBrowsers: true }); 3 | 4 | const compareVersions = require("../scripts/compare-versions-warning"); 5 | compareVersions(); 6 | --------------------------------------------------------------------------------