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 unnecessary files from npm package #12

Closed

Conversation

darthmaim
Copy link
Contributor

@darthmaim darthmaim commented Sep 6, 2023

I've noticed a bunch of unnecessary files in the published npm package (.history directory, source files, travis/prettier/jest configs, ...) (see [email protected] / Code).

Instead of using .npmignore to ignore a bunch of files, I replaced it with files in package.json.

The build/src/ directory should be everything that is needed for this package (Licence, readme and package.json are always included).

This should drop the unpacked size from 137 kB down to 48.1 kB. This could be further improved by minifying/bundling.

@queicherius
Copy link
Member

I've noticed a bunch of unnecessary files in the published npm package (.history directory, source files, travis/prettier/jest configs, ...) (see [email protected] / Code).

While the .history directory should not be published (I added it to .gitignore but forgot to add it to .npmignore) I always publish the source itself and I hate when packages don't do that. (This is to make debugging easier, you can just go through the files in node_modules than having to pull up the repository.)

This should drop the unpacked size from 137 kB down to 48.1 kB. This could be further improved by minifying/bundling.

IMHO download size of unpackaged packages is basically irrelevant at this size level, and minification/bundling should happen on the consumer-level. Minified + gzipped this package turns into 2.9kB which is fair I feel. 🙂

@queicherius queicherius closed this Sep 6, 2023
@darthmaim
Copy link
Contributor Author

While the .history directory should not be published (I added it to .gitignore but forgot to add it to .npmignore) I always publish the source itself and I hate when packages don't do that. (This is to make debugging easier, you can just go through the files in node_modules than having to pull up the repository.)

Thats fair. I still prefer files over .npmignore, because who knows what directories IDEs will add in the future that might get published without anyone noticing.

@queicherius
Copy link
Member

queicherius commented Sep 6, 2023

Thats fair. I still prefer files over .npmignore, because who knows what directories IDEs will add in the future that might get published without anyone noticing.

I think that's just a personal preference of me - I prefer the ignore file to be the same as .gitignore minus the "build" / "dist" directories. (I would love for them to actually support inheritance but oh well). That way you can generally think of it as "what's in the repo gets published".

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