Skip to content

Remove unneeded dependencies in favor of native varients - #23

Closed
james-pre wants to merge 2 commits into
ljharb:mainfrom
james-pre:fix-deps
Closed

Remove unneeded dependencies in favor of native varients#23
james-pre wants to merge 2 commits into
ljharb:mainfrom
james-pre:fix-deps

Conversation

@james-pre

Copy link
Copy Markdown

This PR significantly improves supply chain security by replacing usage of multiple dependencies with native equivalents. This results in the removal of 22 dependencies (4 direct). The bundle size is now 21.7% of what is was before, an almost 5x reduction in package size. Performance has not changed at all, I ran multiple perfomance tests.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing dependencies does not inherently improve supply chain security, first of all.

Second, a breaking change is insanely unacceptable, and this entire PR eliminates a very intentional category of robustness. I'm literally never going to accept changes like this in virtually any project I maintain.

Comment thread index.js
/** @type {typeof defaultReplacer} */
var replacer = opts && opts.replacer
// eslint-disable-next-line no-extra-parens
? /** @type {typeof defaultReplacer} */ (Function.call.bind(/** @type {any} */ (opts.replacer)))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the call-bind package is more robust than Function.call.bind, and its use is intentional to support browsers that don't have .bind.

Comment thread index.js
};

if (isArray(node)) {
if (Array.isArray(node)) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we support browsers that don't have Array.isArray.

Comment thread index.js
}

if ($indexOf(seen, node) !== -1) {
if (seen.indexOf(node) !== -1) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this violates robustness; we shouldn't break if someone deletes indexOf off the builtin prototype.

@ljharb

ljharb commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Removing dependencies does not inherently improve supply chain security, first of all.

Second, a breaking change is insanely unacceptable.

@ljharb ljharb closed this Apr 28, 2026
@james-pre
james-pre deleted the fix-deps branch April 28, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants