From e30d329eda32e1e7843f26e3f081025d34d48e7a Mon Sep 17 00:00:00 2001 From: qwqcode Date: Mon, 10 Jun 2024 16:56:57 +0800 Subject: [PATCH] refactor(ui/deps): remove `abortcontroller-polyfill` --- docs/docs/.vitepress/config.ts | 1 + docs/docs/develop/compatibility.md | 18 ++++++++++++++++++ eslint.config.mjs | 1 - pnpm-lock.yaml | 3 --- ui/artalk/package.json | 1 - ui/artalk/src/api/fetch.ts | 2 -- 6 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 docs/docs/develop/compatibility.md diff --git a/docs/docs/.vitepress/config.ts b/docs/docs/.vitepress/config.ts index 751f0001..05ba50a0 100644 --- a/docs/docs/.vitepress/config.ts +++ b/docs/docs/.vitepress/config.ts @@ -163,6 +163,7 @@ export default defineConfig({ { text: '前端 API', link: '/develop/fe-api.md' }, { text: '前端 Event', link: '/develop/event.md' }, { text: '插件开发', link: '/develop/plugin.md' }, + { text: '兼容性', link: '/develop/compatibility.md' }, { text: 'HTTP API', link: 'https://artalk.js.org/http-api.html', diff --git a/docs/docs/develop/compatibility.md b/docs/docs/develop/compatibility.md new file mode 100644 index 00000000..4e50609d --- /dev/null +++ b/docs/docs/develop/compatibility.md @@ -0,0 +1,18 @@ +# 兼容性 + +## 浏览器兼容性 + +Artalk 客户端生产环境代码的构建通过 esbuild 执行,构建目标为 `es2015`。但请注意,构建仅会处理语法转义遵循 `es2015` 标准,不会处理 API 的兼容性(不包含任何 polyfill)。 + +如果你的项目需要支持较旧的浏览器和设备,请考虑在捆绑应用程序中包含全局 polyfill。我们推荐使用 [Polyfill.io](https://polyfill.io/) 服务,它会根据用户的 User-Agent 动态返回所需的 polyfill。另外,你也可以使用 [core-js](https://github.com/zloirock/core-js) 或 [Babel](https://babeljs.io/) 来手动添加 polyfill。 + +以下是 Artalk 使用的现代功能的列表: + +- [All ECMAScript 2015 (ES6) features](https://compat-table.github.io/compat-table/es6/) +- [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) +- [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) +- [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) + +## 服务器兼容性 + +Artalk 服务端程序基于 Golang 开发,支持 Linux、Windows 和 macOS 等操作系统。当前 Artalk 的 Golang 版本可通过 [go.mod](https://github.com/ArtalkJS/Artalk/blob/master/go.mod#L3) 查看。关于 Golang 的最低操作系统要求,可参考 [Go Wiki](https://go.dev/wiki/MinimumRequirements)。 diff --git a/eslint.config.mjs b/eslint.config.mjs index 77c7cf89..0bd95785 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -105,7 +105,6 @@ export default eslintTs.config( }, node: true, }, - polyfills: ['AbortController'], }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c4c2fa03..9da769b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -243,9 +243,6 @@ importers: ui/artalk: dependencies: - abortcontroller-polyfill: - specifier: ^1.7.5 - version: 1.7.5 hanabi: specifier: ^0.4.0 version: 0.4.0 diff --git a/ui/artalk/package.json b/ui/artalk/package.json index 6c4518ba..48d71cef 100644 --- a/ui/artalk/package.json +++ b/ui/artalk/package.json @@ -116,7 +116,6 @@ "lint": "eslint ." }, "dependencies": { - "abortcontroller-polyfill": "^1.7.5", "hanabi": "^0.4.0", "insane": "^2.6.2", "marked": "^12.0.2" diff --git a/ui/artalk/src/api/fetch.ts b/ui/artalk/src/api/fetch.ts index a1194ef9..c93e127c 100644 --- a/ui/artalk/src/api/fetch.ts +++ b/ui/artalk/src/api/fetch.ts @@ -1,5 +1,3 @@ -import 'abortcontroller-polyfill/dist/polyfill-patch-fetch' - import { ApiOptions } from './options' import { FetchError } from '@/types'