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

chore(package): remove sourcemaps from npm #907

Closed
wants to merge 1 commit into from

Conversation

sapphi-red
Copy link
Contributor

v4 has 4 times larger file size than v3 (v4: 716kB, v3: 168kB, packagephobia). Although it does not affect the final bundle size of app's using this package, I think smaller is better for file disk usage and install times.

This is because of a) sourcemap is now published and b) ESM support which doubles the files.

This PR removes sourcemaps from npm by the same approach with inikulin/parse5#516.
This reduces the package size to 295 kB. (-58.8%)

Since this package uses typescript (that doesn't have ugly outputs) and doesn't run minify, I think the output is readable without sourcemaps and can be removed. Also it seems there are some problems with Webpack (#785).

This PR completely removes sourcemaps. But because most of the size is coming from lib/generated/*.map, an alternative approach is to remove only them. (I think these sourcemaps are not much important because it's a generated code.)
This way the package size will be 328 kB.

diff for the alternative approach
  • remove files field from package.json
  • add the following .npmignore
    **/*
    !lib/**/*
    lib/generated/*.map
    lib/esm/generated/*.map
    

@fb55
Copy link
Owner

fb55 commented Aug 20, 2022

I removed source maps from parse5 because I couldn't figure out how to make them be valid, without checking in the original source code. entities works around that by linking to the source files hosted on GitHub.

I don't see a reason not to add them, as they can help users and don't take up too much space. Hope that makes sense!

@fb55
Copy link
Owner

fb55 commented Aug 20, 2022

About removing them for generated content: Definitely a better option, but I still don't see the need for this. If you want to save all the bytes, one of the online bundlers (esm.sh etc) will do so happily.

@fb55 fb55 closed this Aug 20, 2022
@sapphi-red
Copy link
Contributor Author

It's kind of my personal preference, so I understand. Thanks for taking a look!

@sapphi-red sapphi-red deleted the remove-sourcemap branch August 21, 2022 11:02
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