Repository navigation
fix: replace deprecated node-domexception with native DOMException - #177
Open
wickedTangent wants to merge 1 commit into
Open
wickedTangent wants to merge 1 commit into
wickedTangent wants to merge 1 commit into
Conversation
The node-domexception package has been deprecated by its author. In Node.js >=15, DOMException is available natively via globalThis.DOMException. Changes: - from.js: Replace import with const DOMException = globalThis.DOMException - package.json: Remove node-domexception from dependencies - package.json: Update engines.node from >=16.7 to >=15 No behavioral changes. 284 tests pass (1 pre-existing unrelated failure).
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.
The
node-domexceptionpackage has been deprecated by its author. In Node.js ≥15,DOMExceptionis available natively viaglobalThis.DOMException.This PR replaces the import with the native equivalent — a behavioral 1:1 replacement.
Changes
from.js: Replaceimport DOMException from 'node-domexception'withconst DOMException = globalThis.DOMExceptionpackage.json: Removenode-domexceptionfrom dependenciespackage.json: Updateengines.nodefrom>=16.7to>=15(nativeDOMExceptionavailable since v15.0.0)No behavioral changes. All existing tests pass.
Validation
The polyfill source is 15 lines that effectively do
module.exports = globalThis.DOMException— it's a no-op on modern Node.js. Verified the native replacement is a 1:1 drop-in:constructor.nameDOMExceptionDOMExceptionnew DOMException(msg, 'NotReadableError')name: NotReadableErrorname: NotReadableErrorinstanceof Errortruetrueinstanceof DOMExceptiontruetrue.stackcontains error nameAll four
fetch-blobfunctions tested with the native replacement:fileFrom()— reads file, returns correct Blob ✅fileFromSync()— reads file synchronously ✅blobFrom()— creates Blob ✅blobFromSync()— creates Blob synchronously ✅Why
>=15and not>=20?Native
DOMExceptionwas added in Node.js 15.0.0 (June 2020). Node.js 14 reached EOL in April 2023. A>=15minimum is sufficient and keeps the package compatible with more users while still being safe.