pilwon / node-yahoo-finance

Yahoo Finance historical quotes and snapshot data downloader written in Node.js
488 stars 123 forks source link

Bundling with Webpack #72

Open mikinty opened 3 years ago

mikinty commented 3 years ago

If anyone is trying to use this package with webpack, you might get some errors like

ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '...\node_modules\request\lib'

I think the error has to do with something Node specific and browsers not supporting Node's full capabilities.

A fix I found was to add the following to your webpack.config.js:

module.exports = {
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
  }
}

I'm actually not exactly sure what this does, but I'm assuming it just removes the need for these packages in the final bundle.

Unsure if this is the proper way to go about bundling this package in browser apps.

I still run into #34 CORS issues after getting this bundle to compile.