Distributing a minified version of passkit-generator #98
alexandercerutti
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was reasoning on the fact that currently passkit-generator ships with Joi support, which allows developers to validate data against schemas.
Said that, I think that out there, there could be some cases (if not every case) in which after the production deployment happened, passkit generation implementation doesn't even need any more schemas validation because developers are sure that it won't break.
So, running passkit-generator in a cloud function, in my opinion, might become heavy (in terms of running time) only due to schemas validation (which is actually not very light) and Joi dependency loading.
Bundlephobia shows current passkit-generator composition when it is bundled alone: https://bundlephobia.com/package/passkit-generator@3.1.1
Of course, the biggest part of the bundle is made from Node Forge, which sadly doesn't follow a project structure based on multiple atomic packages, as lodash does, and right now it seems to be the best solution for crypto things on npm.
But the second player is Joi.
So I made an attempt of a compilation through
@vercel/ncc
and the bundle (minified) file with Joi weights over 500KBs while the one without Joi weights about 330KBs. Of course, kilobytes might be considered nothing when talking about running code, but of course, if we can contribute to the acceleration of startup time of cloud functions (as an example), I think developers might be happy to save a few dollars.So, I'll leave this open for anyone who wants to share their scenario. I'd like to understand if the reasoning I made is valid and if it would be appreciated if we'll be moving in this direction.
I'm not quite sure how we could do this.
Maybe the best way to keep validation for development but removing it in production without passing through a compilation step with webpack or other bundlers or tools, would be to issue a different package that monkey-patches passkit-generator methods so validation can be applied transparently on runtime and the developers can choose whether to include this on development or at all.
Example:
What do you think about this? Any other ideas to share? Thank you for your contribution!
Beta Was this translation helpful? Give feedback.
All reactions