Code Monkey home page Code Monkey logo

Comments (4)

jaydenseric avatar jaydenseric commented on May 20, 2024 1

The runtime dependency has nothing to do with .mjs or ESM.

Only two imports in the dist files depend on the runtime dep:

screen shot 2018-02-12 at 3 52 20 pm

The first _asyncToGenerator import is because the koa middleware uses async/await. This could be refactored to just return a promise. The second core-js/modules/es7.object.entries import is because Object.entries() is used here. It could be refactored too.

A downside to making changes like this is that when we want to increase Node.js support to something more recent, we will not easily know what can now be refactored to modern syntax.

The best way to maintain a fleet of packages is to use current ES in the source and set up transpilation with @babel/preset-env, defining the level of support using package.json engines.node and browserslist. Simply adjust these values for the dist files to magically transpile with the minimum required runtimes/polyfills, etc.

While we could manually audit builds and work backwards to remove the need for the runtime dep, this is risky because updating deps, merging PRs, adding features, etc. would require fresh audits.

huge @babel/runtime module (1.2MB)

This is the first I have heard of our install size being a practical issue; are you sure it's a problem? I just installed the dependencies for a minimal server (npm install apollo-server-express express graphql) and the folder is over 7 MB:

screen shot 2018-02-12 at 4 21 29 pm

Add in a few other dependencies typically used in resolvers (moment, mongodb, etc.) and you can expect many more MB. Proportionally our dependencies are modest, and as more people update to babel@7 lots of packages will be sharing the runtime dep so the overhead due to using it here will be zero.

AWS Lambda is horrifically behind the times, by the looks of it even their own SDK is outdated. Ideally they will update their environment to a recent Node.js version sometime soon, then we could move Node.js support right up to v7.6+ or even greater. Then the chances of needing the runtime are small enough to justify removing it from dependencies and transpilation.

from graphql-upload.

koresar avatar koresar commented on May 20, 2024 1

Thank you for the opinion.

from graphql-upload.

jaydenseric avatar jaydenseric commented on May 20, 2024

The whole runtime does not load and run, only the minimal helpers necessary for our level of node support (via @babel/preset-env) are imported. The helpers can be shared across dependencies instead of being repeatedly inlined in each package.

from graphql-upload.

koresar avatar koresar commented on May 20, 2024

I see.

Still, I wonder why downloading those megabytes is that necessary. Sounds like a small module with just a 100 lines of code, but it brings too much with it.

.mjs is not yet LTS. Thus, majority of people would be using your module from node 6 and 8. All will now depend on huge @babel/runtime module (1.2MB). I know that new cool import/export syntax is awesome. But, for compatibility sake, should this module depend on busboy and object-path only?

Usually, small modules try to depend on as less as possible. That's a common practice.
I can help with a PR if any.

from graphql-upload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.