GithubHelp home page GithubHelp logo

Node-fetch & webpack about dwolla-v2-node HOT 7 CLOSED

dwolla avatar dwolla commented on June 9, 2024
Node-fetch & webpack

from dwolla-v2-node.

Comments (7)

shellscape avatar shellscape commented on June 9, 2024

@sausman please put some eyeballs on this. just ran into this today myself.

from dwolla-v2-node.

sausman avatar sausman commented on June 9, 2024

Hey @shellscape,

Yeah I’ll take a look at this. Any info you can provide on your setup to help reproduce would be great!

Are you using Webpack as well?

from dwolla-v2-node.

shellscape avatar shellscape commented on June 9, 2024

@sausman yeah I actually work with @brianschardt but I was on another project with a similar setup. Typically shows up when node-fetch >= 2.0.0 gets the module resolution while bundling. Any version less than 2.0.0 doesn't have the issue. This is caused by a breaking change in 2.0.0 that didn't get much fanfare. See https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md#v200 and the last point under General changes.

https://www.npmjs.com/package/isomorphic-fetch might be a good option. should tree shake properly for bundlers. or, if the global scope of fetch doesn't sit well in Node, axios is a fine alternative which plays very nicely with bundlers and Node alike, with a similar syntax.

from dwolla-v2-node.

sausman avatar sausman commented on June 9, 2024

@shellscape Thanks that helps!

One thing I came across you may be able to use is https://www.npmjs.com/package/webpack-node-externals

It was apparently inspired by this blog post which mentions:

Webpack will load modules from the node_modules folder and bundle them in. This is fine for frontend code, but backend modules typically aren't prepared for this (i.e. using require in weird ways) or even worse are binary dependencies. We simply don't want to bundle in anything from node_modules.

from dwolla-v2-node.

shellscape avatar shellscape commented on June 9, 2024

The one thing we do want to avoid is using externals. We're shipping to Lambda (serverless) and tree shaking the bajeezus out of the bundle to reduce the size of the archive. Avoiding shipping a node_modules directory is key.

from dwolla-v2-node.

sausman avatar sausman commented on June 9, 2024

Hey @shellscape,

We just published 3.1.2 which should fix this!

from dwolla-v2-node.

shellscape avatar shellscape commented on June 9, 2024

🙌 and on your day off no less! Very much appreciated!

from dwolla-v2-node.

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.