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

Update bundle/package process as fitting for an npm package #23

Closed
ejizba opened this issue Sep 14, 2022 · 0 comments · Fixed by #26
Closed

Update bundle/package process as fitting for an npm package #23

ejizba opened this issue Sep 14, 2022 · 0 comments · Fixed by #26

Comments

@ejizba
Copy link
Contributor

ejizba commented Sep 14, 2022

We pulled this code out of the nodejs worker which is essentially a server side app, but haven't updated the bundle/package process to reflect the fact that this is now an npm package. Here are the main changes I think are necessary

Very obvious - don't ship dependencies

This repo should not ship its dependencies in its own package. Each npm package should only ship its own code and npm will handle installing any dependencies in the user's "node_modules" folder. Currently the dependencies are being bundled into the "index-bundle.js" file and we should remove that.

Somewhat obvious - ship files that help with debuggability

Right now if the user tried to "step into" the @azure/functions package they will be taken to a minified mess of a file with no chance of debugging it at all. Instead, I think npm packages should ship their original *.ts files and source map files so that users can debug through the package much more easily.

The main downside is that this increases the size of the package, but honestly it's a pretty minimal difference and the user should get rid of these files in their own bundling process before deploying their app to prod.

More debatable - should the code be bundled/minified

As stated above, we shouldn't use webpack to bundle our dependencies. However, should we use webpack to bundle our own source files into one file? And should it be minified (or "uglified") to make it the most performant as possible? There's no clear answer online, but a few places where people discuss this (example one, example two). The main argument for this is that sadly many user's don't use a bundling process before deploying to prod (even though they should), so we should bundle to improve performance as much as possible. I took a look at some other packages (including azure sdks like @azure/storage-blob) and many appear to ship both a bundled file (storage-blob.js) and a bundled/minified file (storage-blob.min.js). The user can choose which one to use hypothetically, but they use the bundled (and not minified) one by default. I think this makes sense because the bundling process probably makes a way bigger difference on performance than minification, and minification drastically reduces readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant