Skip to content

fix: Remove the deprecated intersection-observer dependency#2904

Open
Arktomson wants to merge 1 commit intoalibaba:masterfrom
Arktomson:fix/2870-remove-deprecated-intersection-observer
Open

fix: Remove the deprecated intersection-observer dependency#2904
Arktomson wants to merge 1 commit intoalibaba:masterfrom
Arktomson:fix/2870-remove-deprecated-intersection-observer

Conversation

@Arktomson
Copy link
Contributor

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

Fixes #2870

💡 需求背景和解决方案

问题:
项目依赖了已废弃的 intersection-observer@0.12.2 包。该包在 npm 上已被标记为 deprecated,官方说明:

The Intersection Observer polyfill is no longer needed and can safely be removed. Intersection Observer has been Baseline since 2019.

解决方案:

  1. 移除 packages/hooks/src/useInViewport/index.ts 中的 import 'intersection-observer' 语句
  2. packages/hooks/package.json 中删除 intersection-observer 依赖
  3. 更新 pnpm-lock.yaml

原因:

  • IntersectionObserver API 自 2019 年起已成为 W3C 标准
  • 所有现代浏览器都原生支持该 API(Chrome 58+, Firefox 55+, Safari 12.1+, Edge 16+)
  • ahooks 的目标用户是现代浏览器(React 16.8+),不需要此 polyfill

验证:

  • ✅ 所有测试通过(357 个测试用例)
  • useInViewport 功能正常
  • ✅ 无 breaking change

📝 更新日志

语言 更新描述
🇺🇸 英文 🗑 Remove deprecated intersection-observer dependency. Modern browsers support IntersectionObserver API natively.
🇨🇳 中文 🗑 移除已废弃的 intersection-observer 依赖。现代浏览器已原生支持 IntersectionObserver API。

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

- 移除 intersection-observer polyfill,因为它已不再需要
- IntersectionObserver 自 2019 年起已成为 Web 标准
- 所有现代浏览器都原生支持该 API
- 减少打包体积并移除废弃依赖

Fixes alibaba#2870
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

npm i https://pkg.pr.new/ahooks@2904
npm i https://pkg.pr.new/@ahooksjs/use-url-state@2904

commit: e0e2212

@Arktomson Arktomson changed the title fix: 移除已废弃的 intersection-observer 依赖 fix: Remove the deprecated intersection-observer dependency Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated subdependencies found: intersection-observer@0.12.2

2 participants