calvinmetcalf / rollup-plugin-node-builtins

138 stars 40 forks source link

TypeError: global$1.XMLHttpRequest is not a function #25

Closed denneulin closed 7 years ago

denneulin commented 7 years ago

Hi,

I am using you plugin to bundle my project. I am trying to include node_modules into bundle in order to deploy on AWS Lambda.

When I use rollup-plugin-node-builtins with rollup-plugin-node-globals, my bundle.js can not be used because of the line 20 of es6/http-lib/capability.js : xhr = new global.XMLHttpRequest()

XMLHttpRequest does not exist on Node.js API.

What have I missed ?

calvinmetcalf commented 7 years ago

this is intended to provide the node libraries in the browser where they are not available. just do a regular require for the node builtins you need, rollup should ignore it and lambda has the built in modules

denneulin commented 7 years ago

thanks for your help ;)

vasiliulaura15 commented 6 years ago

Hi! I am hitting the same issue. In the code I don't have any imports for node builtins and I am still seeing this. How can I by pass this error?

zingi commented 5 years ago

I was able to fix the problem by swapping this:

import got from 'got'

with that:

const got = require('got')