MDN 浏览器兼容数据打包进 SQLite

Simon Willison··作者 Simon Willison

关键信息

底层的 MDN browser-compat-data 项目规模很大,数据集中有超过 15,000 个特性。Willison 说这个数据库大约有 66 MB,而且他选择普通的 GitHub 仓库分支而不是 GitHub Releases,因为仓库文件可以带着开放的 CORS 头提供服务。

资讯摘要

Simon Willison 介绍了一个规模不大但很实用的基础设施项目,核心是 MDN 的浏览器兼容性数据集。受 Mozilla 新推出的 MDN MCP 服务启发,他决定把 mdn/browser-compat-data 仓库转换成一个 SQLite 数据库。这个仓库里包含一个由 Claude Code for web 生成的构建脚本,用 sqlite-utils 来完成转换。Willison 说生成出来的数据库大约有 66 MB。

为了让这个文件更方便地在浏览器中访问,他希望它能通过 GitHub 并带着开放的 CORS 头提供服务。由于 GitHub Releases 不会提供这种头信息,他改用 Codex Desktop 编写了一个 GitHub Actions 工作流,用来生成数据库并强制推送到名为 db 的孤立分支。最终生成的数据库可以直接从仓库下载,并且因为托管方式允许跨域访问,所以还能在浏览器里通过 Datasette Lite 直接浏览。

资讯正文

<p><strong><a href="https://github.com/simonw/browser-compat-db">simonw/browser-compat-db</a></strong></p>

受 Mozilla 新推出的 <a href="https://developer.mozilla.org/en-US/blog/introducing-mdn-mcp-server/">MDN MCP 服务</a> 启发——<a href="https://github.com/mdn/mcp">源代码在这里</a>——我决定尝试把他们那个包含浏览器兼容性数据的完整 <a href="https://github.com/mdn/browser-compat-data">mdn/browser-compat-data</a> 仓库转换成一个 SQLite 数据库。</p>

<p>这个新的 GitHub 仓库包含一个由 Claude Code for web(Opus 4.8)<a href="https://github.com/simonw/browser-compat-db/blob/main/build_db.py">生成的脚本</a>,用于借助 <a href="https://github.com/simonw/sqlite-utils">sqlite-utils</a> 完成这项转换。</p>

<p>我希望最终生成的约 66MB SQLite 数据库能够通过 GitHub CDN 提供,并带有开放的 CORS 头。GitHub Releases 不支持这一点,但普通 GitHub 仓库中的任何文件都可以——所以我让 Codex Desktop(GPT-5.5)构建了一个 <a href="https://github.com/simonw/browser-compat-db/blob/main/.github/workflows/build-db.yml">GitHub Actions 工作流</a>,先生成数据库,然后把它强制推送到名为 <code>db</code> 的“孤立”分支。</p>

<p>你可以<a href="https://github.com/simonw/browser-compat-db/blob/db/browser-compat.db">在这里</a>下载生成的数据库,而且由于它以开放的 CORS 头托管,你也可以<a href="https://lite.datasette.io/?url=https://github.com/simonw/browser-compat-db/blob/db/browser-compat.db#/browser-compat/releases_tree">用 Datasette Lite 浏览它</a>。

<p>标签:<a href="https://simonwillison.net/tags/github">github</a>、<a href="https://simonwillison.net/tags/mozilla">mozilla</a>、<a href="https://simonwillison.net/tags/projects">projects</a>、<a href="https://simonwillison.net/tags/github-actions">github-actions</a>、<a href="https://simonwillison.net/tags/datasette-lite">datasette-lite</a>、<a href="https://simonwillison.net/tags/ai-assisted-programming">ai-assisted-programming</a>、<a href="https://simonwillison.net/tags/model-context-protocol">model-context-protocol</a>、<a href="https://simonwillison.net/tags/mdn">mdn</a></p>

来源与参考

  1. 原始链接
  2. simonw/browser-compat-db

收录于 2026-06-26