Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove is-plain-obj deps #248

Closed
4 tasks done
Jayllyz opened this issue Aug 6, 2024 · 9 comments
Closed
4 tasks done

remove is-plain-obj deps #248

Jayllyz opened this issue Aug 6, 2024 · 9 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@Jayllyz
Copy link

Jayllyz commented Aug 6, 2024

Initial checklist

Problem

https://e18e.dev/guide/cleanup.html
https://packages.ecosyste.ms/registries/npmjs.org/packages/is-plain-obj/dependent_packages?order=desc&sort=downloads
Unified is top 2 dependant of is-plain-obj

Solution

Replace by a oneline function :

function isPlainObject(v) {
	return v && typeof v === 'object' && (Object.getPrototypeOf(v) === null || Object.getPrototypeOf(v) === Object.prototype);
}

Alternatives

.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Aug 6, 2024
@wooorm
Copy link
Member

wooorm commented Aug 6, 2024

Hey Anthony!

And then?

Do you use unified?

How far do you want to go? Do you want to inline every dependency?


Please at least put some time in your issue and respect our time too. There are of course alternatives and trade offs.

@wooorm
Copy link
Member

wooorm commented Aug 6, 2024

How well does your code work? I’d assume it might break across realms, due to the Object.prototype?

@Jayllyz
Copy link
Author

Jayllyz commented Aug 6, 2024

Hello, thanks for the fast answer.

To be honest, no I don't use unified. I'm just trying to help clean up the js ecosystem even if my contribution is a grain of salt.

"Inline every dependency" isn't what we're trying to do, but some packages shouldn't exist. Take a look at this PR where a contributor saves tons of data by removing is-number as ex.
micromatch/to-regex-range#17

This oneline comes from :

https://github.com/es-tooling/module-replacements/blob/main/manifests/micro-utilities.json

If you don't want to change it that's fine, don't worries.

@remcohaszing
Copy link
Member

I personally don’t really think this check is very useful:

unified/lib/index.js

Lines 1254 to 1261 in 35e72b9

function assertNode(node) {
// `isPlainObj` unfortunately uses `any` instead of `unknown`.
// type-coverage:ignore-next-line
if (!isPlainObj(node) || typeof node.type !== 'string') {
throw new TypeError('Expected node, got `' + node + '`')
// Fine.
}
}

But I don’t think there’s a way around this check:

if (isPlainObj(currentPrimary) && isPlainObj(primary)) {

I agree removing useless dependencies is a good thing. I don’t necessarily think this is a completely useless dependency. You should look at why a dependency is used and come up with a proposal to replace it. A suggestion to “remove dependency X isn’t helpful.

@wooorm
Copy link
Member

wooorm commented Aug 6, 2024

It’s used in case 1 because the dep is already there. The dep is there because of case 2.

@ChristianMurphy
Copy link
Member

If there is a runtime performance reason, runtime correctness reason, or security reason to drop the dependency I'm all for it.

The premise of minifying code or documentation to save bandwidth downloading to a developer machine is not one I subscribe to.
Developers should have access to clear easy-to-understand code and documentation.
Code and documentation downloaded from a package manager is cached, it's a one time cost.

For folks who are concerned with the bandwidth, take it up with CI/CD providers and NPM itself to offer more tailored download options, rather than going after individual projects over a few kilobytes.

@Jayllyz
Copy link
Author

Jayllyz commented Aug 6, 2024

Thanks for your feedbacks, I see that we have different opinions about such packages (even within e18e)

I don't want to get into a drama/debate because that's not the aim of this initiative. If you want to help or suggest things, I recommend you go to the discord.

Thank you, all the best for your projects and sorry for the time lost.

@Jayllyz Jayllyz closed this as completed Aug 6, 2024

This comment was marked as resolved.

@wooorm wooorm added 🙅 no/wontfix This is not (enough of) an issue for this project and removed 🤞 phase/open Post is being triaged manually labels Aug 7, 2024

This comment was marked as resolved.

@wooorm wooorm added the 👎 phase/no Post cannot or will not be acted on label Aug 7, 2024
@unifiedjs unifiedjs deleted a comment from github-actions bot Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

4 participants