Repository navigation
fix: Node 22 compatibility for source maps and import assertions - #5503
Conversation
|
@GeoffreyBooth could you please trigger the workflow on this PR when you get time? Thank you! |
|
I noticed the CI build failed with |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi @GeoffreyBooth, I've pushed an update to |
|
Hi @GeoffreyBooth, just a gentle check-in on this PR. |
Node 22 sets its own internal
Error.prepareStackTracehandler (ErrorPrepareStackTrace) before any user code runs, which broke CoffeeScript in three ways.register.jssaw a truthyError.prepareStackTraceand skipped callingpatchStackTrace(), so CoffeeScript's source-map translator was never installed. Stack traces reported raw JS line numbers instead of original CoffeeScript line numbers, breaking tests#4418and#4558.The dynamic
import()assert: { type: 'json' }syntax was removed in Node 22 withERR_IMPORT_ATTRIBUTE_MISSING. Replaced with the currentwith: { type: 'json' }syntax intest/import_assertions.coffee.The test
"requiring 'CoffeeScript' doesn't change Error.prepareStackTrace"expectedError.prepareStackTrace === undefinedin a fresh Node process, which is no longer true on Node 22 since Node pre sets it internally. Updated the assertion to check that requiringcoffeescript.jsleaves it unchanged, which is the correct invariant.src/register.coffeeandlib/coffeescript/register.jsare updated to detect and ignore Node's own internal handler sopatchStackTrace()installs correctly.test/import_assertions.coffeereplacesassert:withwith:in two dynamicimport()calls.test/sourcemap.coffeechecks thatprepareStackTraceis unchanged rather than undefined.Test result(Before):
Test result (After):