fix: delegate extensionless files to nextLoad instead of short-circui…#7
Open
fgiova wants to merge 1 commit into
Open
fix: delegate extensionless files to nextLoad instead of short-circui…#7fgiova wants to merge 1 commit into
fgiova wants to merge 1 commit into
Conversation
…ting
On Node >= 24.13 the sync `module.registerHooks({ load })` path strictly
validates the hook return: a `shortCircuit: true` result must carry a
`source`. The extensionless-file branch in both `loadSync` and `load`
returned `{ format: 'commonjs', shortCircuit: true }` with no `source`,
so any extensionless CommonJS bin (cdk, cdklocal, npx, ...) required
while the loader is active crashed with ERR_INVALID_RETURN_PROPERTY_VALUE.
Delegate to `nextLoad(url, { ...context, format: 'commonjs' })` instead:
this preserves the commonjs format hint while letting the default step
supply a valid `source`, satisfying strict validation. Behaviour on
Node < 24.13 (async register path) is unchanged.
Adds an integration test that require()s an extensionless bin through the
sync registerHooks path and asserts no strict-validation error.
Fixes tapjs#6
tapjs#6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the module loader hooks to ensure compatibility with Node.js strict validation (Node >= 24.13), particularly when handling extensionless files. The main change is to delegate extensionless file loading to
nextLoadwith acommonjsformat hint, instead of short-circuiting, which prevents validation errors. The tests have also been updated and expanded to verify this behavior in both sync and async load hooks.Loader hook improvements:
loadSync) and async (load) hooks to delegate tonextLoadwith{ format: 'commonjs' }instead of returning a short-circuit result. This avoidsERR_INVALID_RETURN_PROPERTY_VALUEerrors under Node.js strict validation. [1] [2]Testing updates:
test/hooks.mjsto expect delegation tonextLoadand to validate that the correct format and source are returned for extensionless files.test/hooks.ctsto specifically verify that extensionless files loaded via sync hooks (using--import) do not trigger strict validation errors in Node.js >= 24.13.