`Maximum call stack size exceeded` on large, minified JS file
#36 opened on 2025年4月24日
Repository metrics
- Stars
- (51 stars)
- PR merge metrics
- (PR metrics pending)
説明
Describe the bug
Running format-imports on a large (60k LOC), minified JS file causes a crash with Maximum call stack size exceeded
$ npx format-imports pdf.worker.min.js
Maximum call stack size exceeded
I think it has to do with the specific minified code that is generated for this file, because other 60k LOC JS files work with no crashes with format-imports... 🤔
I believe this online minifier service was used to generate the code, with this original code (https://app.unpkg.com/pdfjs-dist@3.11.174/files/build/pdf.worker.js):
Minified code generated by the latest version of Terser or SWC Minifier does not appear to have the same problem with causing format-imports crashes.
To Reproduce Is there a demo repo to reproduce the issue?
https://github.com/karlhorky/repro-format-imports-maximum-call-stack-size-exceeded
Steps to reproduce the behavior:
- Clone repository
- Run
npm run formatornpx format-imports pdf.worker.min.js
Expected behavior
format-imports doesn't crash
Actual behavior
format-imports crashes
Screenshots
--
OS (please complete the following information):
- OS: macOS
- Version: Sequoia 15.4.1 (24E263)
Editor (please complete the following information):
- Editor: VS Code
- Version: 1.99.3
package.json (please remove any sensitive info)
{
"name": "repro-format-imports-maximum-call-stack-size-exceeded",
"version": "1.0.0",
"author": "Karl Horky",
"scripts": {
"format": "format-imports pdf.worker.min.js"
},
"dependencies": {
"format-imports": "4.0.7"
}
}
tsconfig.json (if any)
none
.eslintrc.* (if any)
none
.prettierrc* (if any)
none
.editorconfig (if any)
none
Any more info
--