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

Improve npm package size #2172

Closed
elsassph opened this issue Oct 4, 2019 · 7 comments · Fixed by #5955
Closed

Improve npm package size #2172

elsassph opened this issue Oct 4, 2019 · 7 comments · Fixed by #5955
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@elsassph
Copy link
Contributor

elsassph commented Oct 4, 2019

Have you read the FAQ and checked for duplicate open issues?
Yes

Is your feature request related to a problem? Please describe.
npm install shaka-player adds 22+Mb under node_modules. This is the entire content of the git repository plus the compiled JS files.
I note that there is a .npmignore which is only omiting a few compilation artefacts.

Describe the solution you'd like
Modify .npmignore to only include relevant dist files (e.g. demos aren't presumably needed) and the sources needed for the .map files (lib, ui); this will reduce the disk size to about 8Mb.

Describe alternatives you've considered

Additional context

@joeyparrish
Copy link
Member

If I understand correctly, this would exclude build, demo, docs, test, and third_party/closure, for a total savings of about 13.6MB.

$ du -sh build/ demo/ docs/ test/ third_party/closure/
236K    build/
560K    demo/
2.1M    docs/
3.2M    test/
7.5M    third_party/closure/

There are a few other small things that could be excluded, like .github, which we failed to add to .npmignore when we created it, and some markdown docs (outside of README.md, which should stay). Those markdown docs are probably not worth excluding one-by-one, and you can't do *.md without losing README.md.

You could possibly omit the externs (224K), but that would prevent other closure-based projects from referring to prebuilt, npm-installed copies of Shaka Player in their own compilation steps. So I'd prefer not to do that.

Did I miss anything?

Excluding these things would prevent users of shaka-player through npm from being able to modify and rebuild it without separately cloning the sources from github. This seems pretty reasonable to me, though. If you're reading this, and this change would break your workflow, please speak up!

If nobody objects, I'd be happy to take a PR for this. Thanks for suggesting it!

@joeyparrish joeyparrish added type: enhancement New feature or request flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this and removed needs triage labels Oct 4, 2019
@shaka-bot shaka-bot added this to the Backlog milestone Oct 4, 2019
@elsassph
Copy link
Contributor Author

elsassph commented Oct 5, 2019

I don't think it should/needs to be possible to rebuild the project from the package. At least I've never done that for my packages...

For the externs - maybe there is a legitimate reason to keep them but I'm not familiar with it.

I've tried the change ony end (excluding .github as well as you noted) and can do a PR tomorrow.

@joeyparrish joeyparrish modified the milestones: Backlog, Backlog 2 Jan 28, 2020
@lumbridge01
Copy link

👋 Hello @joeyparrish!

To avoid removing every .md file one-by-one (and having to add new exceptions in the future), we could exclude all markdown files using *.md and negate the pattern exclusively for README.md with !.

Considering all the directories mentioned before, the final .npmignore would look as follows:

# exclude core
!core

# github
.git
.gitattributes
.gitignore
.github

# python
*.pyc

# directories
coverage/
build/
demo/
docs/
test/
third_party/closure/

# markdown
*.md
!README.md

Note that this also includes the removal of repeating patterns. For example, test/test/assets/screenshots/ is no longer considered as test/ already excludes it.

This achieves a 26% decrease in the size of node_modules, from 23MB to 17MB!

Finally, as this issue was opened over a year ago, I wanted to make sure it was discussed here before opening a pull request.

Are there any other files or directories that should also be excluded?

@joeyparrish
Copy link
Member

That looks good to me, with one exception: third_party/closure/ doesn't exist any more in v3.0+.

I just checked the current size of dist/, and if we're excluding demo/, I see some outputs in dist/ that could also be dropped:

  • dist/demo.*
  • dist/receiver.*

Uncompressed, those occupy another 1.6MB.

One more question:

If we don't need to be able to rebuild the source from the NPM package, do we still need the uncompiled sources in the package? Do people use the NPM version of Shaka Player and load it in uncompiled mode?

@joeyparrish
Copy link
Member

Oh, and we can also drop karma.conf.js, which is related to the tests we're excluding.

@lumbridge01
Copy link

third_party/closure/ doesn't exist any more in v3.0+

My apologies, I was checking on my local npm installation which is still in 2.5.20!

If we don't need to be able to rebuild the source from the NPM package, do we still need the uncompiled sources in the package? Do people use the NPM version of Shaka Player and load it in uncompiled mode?

Although I haven't done this myself, I'm not sure if I can speak for everyone as I'm not familiar with the process - I would suggest that we avoid excluding them for now.

I just checked the current size of dist/, and if we're excluding demo/, I see some outputs in dist/ that could also be dropped:
dist/demo.*
dist/receiver.*
Oh, and we can also drop karma.conf.js, which is related to the tests we're excluding.

Considering the mentioned changes, the final .npmignore would look as follows:

# exclude core
!core

# github
.git
.gitattributes
.gitignore
.github

# python
*.pyc

# directories
coverage/
build/
demo/
docs/

# tests
test/
karma.conf.js

# dist
dist/demo.*
dist/receiver.*

# markdown
*.md
!README.md

@joeyparrish, please let me know what would the best course of action be regarding the uncompiled sources - I will be checking back on this issue to see if I can follow it with a pull request of the proposed changes.

@joeyparrish
Copy link
Member

Sounds good. A PR would be appreciated. Thanks!

@joeyparrish joeyparrish added the priority: P3 Useful but not urgent label Sep 29, 2021
@avelad avelad removed the flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this label Nov 29, 2023
avelad added a commit that referenced this issue Nov 29, 2023
@avelad avelad modified the milestones: Backlog, v4.7 Nov 30, 2023
Robloche pushed a commit to Robloche/shaka-player that referenced this issue Nov 30, 2023
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Jan 28, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
5 participants