Closed hanoj-budime closed 2 years ago
This packages is actually very small and I take great care to make sure that it stays that way. See https://bundlephobia.com/package/@hyperjump/json-schema@0.18.3 for a more accurate assessment than what you see on npmjs.com. The current version is about 150KB raw, 79KB minified, and 13KB compressed.
The reason it appears to be so big is because I package several pre-built bundles in different formats for people who aren't using bundlers can include the package using unpkg: https://unpkg.com/browse/@hyperjump/json-schema@0.18.3/dist/. These builds will not be included when this code gets bundled into your app.
Hi @jdesrosiers,
Thanks for your response.
But we are using this package in our Node.js Project ( package version is @hyperjump/json-schema@0.11.1 ).
After deployment, this project in AWS lambda shows project size is more then 3.2 MB.
Because of this https://bundlephobia.com/package/@hyperjump/json-schema@0.11.1
Can please help me on this.
Ah, now it makes sense. It would be that large on disk. I never thought of that as an issue, but I assume AWS lambda has limits on how big a lambda can be.
I'm not sure what can be done about that other than removing the pre-built bundles, but I'm not sure I want to do that. I might be able to do something with a postinstall script that deletes the "dist" directory, but I don't know if that would work. I'll look into it and see if there's anything I can do.
I added a postinstall script to remove the dist directory and it seems to work. The pre-bundled distributions are still available on unpkg and the final size in node_modules including dependencies is under 600KB. The npm install
command will still download the whole thing, but will delete the files that aren't needed for a node application. I don't know if that ends up helping in you situation or not. It depends on how AWS lambda counts size.
Give it a try with version 0.18.4
and let me know if it works.
Thanks, @jdesrosiers.
Now I can see the Package size reduce.
But this works on pipeline & Linux, not in Windows right?
I added a postinstall script to remove the dist directory and it seems to work. The pre-bundled distributions are still available on unpkg and the final size in node_modules including dependencies is under 600KB. The
npm install
command will still download the whole thing, but will delete the files that aren't needed for a node application. I don't know if that ends up helping in you situation or not. It depends on how AWS lambda counts size.Give it a try with version
0.18.4
and let me know if it works.
Worked
Worked For Me ( in Linux, But not in Windows ).
Maybe it's fine if you just provide steps to write a post-install script in their owner project. instead of doing here.
Thanks for checking. I always forget windows exists. I'm pretty sure I know what I have to do to make it work everywhere.