vercel/ncc

Regression: dynamic runtime `require` works in 0.38.1 but breaks in 0.38.2

Open

#1,312 创建于 2026年3月16日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)JavaScript (8,841 star) (273 fork)batch import
help wanted

描述

0.38.1

I have the following source code:

https://github.com/CatChen/eslint-suggestion-action/blob/930479a34a06bfa384291cc877f9d1ce21533ae1/src/getESLint.ts#L16-L19

The dynamic require is compiled into the following code:

https://github.com/CatChen/eslint-suggestion-action/blob/930479a34a06bfa384291cc877f9d1ce21533ae1/bundle/index.js#L37587

0.38.2

The same code is compiled into the following code since 0.38.2:

https://github.com/CatChen/eslint-suggestion-action/blob/bc0de7fa625de9daf56cca84b6084f4d6bcbaca4/bundle/index.js#L37702

Workaround

My current workaround is to use dynamic import inside a new Function() (because dynamic import isn't supported either). I have to change to code into this:

https://github.com/CatChen/eslint-suggestion-action/blob/927208b2e684b1a7c721f4a0e70d4f4e8c11c228/src/getESLint.ts#L15-L26

贡献者指南

Regression: dynamic runtime `require` works in 0.38.1 but breaks in 0.38.2 · vercel/ncc#1312 | Good First Issue