-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
This was originally observed when trying to build something with vite, which minifies with esbuild by default. I've reduced the chunk and captured the bundle it's trying to minify.
esbuild 0.25.9
❯ npx esbuild --minify problematic-chunk.mjs
✘ [ERROR] panic: Unexpected expression of type <nil> (while printing "problematic-chunk.mjs")
debug.Stack (runtime/debug/stack.go:26)
helpers.PrettyPrintedStack (internal/helpers/stack.go:9)
linker.(*linkerContext).recoverInternalError (internal/linker/linker.go:7248)
panic (runtime/panic.go:791)
js_printer.(*printer).printExpr (internal/js_printer/js_printer.go:3347)
js_printer.(*printer).printExpr (internal/js_printer/js_printer.go:2337)
js_printer.(*printer).printStmt (internal/js_printer/js_printer.go:4899)
js_printer.Print (internal/js_printer/js_printer.go:5005)
linker.(*linkerContext).generateCodeForFileInChunkJS (internal/linker/linker.go:4973)
linker.(*linkerContext).generateChunkJS in goroutine 11 (internal/linker/linker.go:5600)
1 error
https://esbuild.github.io/try/ doesn't produce a URL because the panic.
Here is the input: https://gist.github.com/etrepum/ca202aac6cf20c0181a8ff3ad49dd89f
Interestingly this problem requires a combination of separate modules to reproduce. It didn't happen when putting them each in separate chunks or when trying to use esbuild to minify the inputs directly. The smallest combination had two modules, which is attached. These are otherwise unmodified from the code I was trying to build.
I have not yet had the time to try and pare down the file to see what syntax exactly is the issue, and of course the go panic isn't very helpful. IIRC the inputs here are mostly already minified by terser, but might have gone through tree shaking.