Skip to content

feat(pack): support enable node polyfills#2257

Merged
xusd320 merged 1 commit intonextfrom
fix-2429
Oct 24, 2025
Merged

feat(pack): support enable node polyfills#2257
xusd320 merged 1 commit intonextfrom
fix-2429

Conversation

@fireairforce
Copy link
Contributor

@fireairforce fireairforce commented Oct 20, 2025

Summary

closes: #2249

支持一个 enableNodePolyfills 的配置,类似于 https://github.com/rspack-contrib/rsbuild-plugin-node-polyfill

使用了 next.js 的预构建好的 polyfills 产物,处理一下 resolve_fallback 的 import_map alias 配置即可。

  • 增加 enableNodePolyfills 用于开启 node polyfills 的注入
  • 运行时代码的注入

使用方式:

{
    "config": {
        "entry": [
            {
                "import": "input/index.ts",
                "name": "main"
            }
        ],
        "nodePolyfill": true
    }
}

参考:

image

Test Plan

参考快照测试,fallback 的逻辑是只会把用户使用到的 polyfill alias bundle 进产物,不会把所有的 node polyfill 一次性打包进来。

@fireairforce fireairforce force-pushed the fix-2429 branch 3 times, most recently from 0cdd1b7 to ec5e53a Compare October 23, 2025 18:07
@fireairforce fireairforce marked this pull request as ready for review October 23, 2025 18:07
@xusd320 xusd320 merged commit d74307c into next Oct 24, 2025
17 checks passed
@xusd320 xusd320 deleted the fix-2429 branch October 24, 2025 03:06
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.

[Utoopack] client 构建支持 node polyfill 注入

2 participants