waterwheel.js
waterwheel.js copied to clipboard
Server-side requests are broken
When attempting to make requests using Node.js on the server side, Waterwheel throws this error:
ReferenceError: XMLHttpRequest is not defined
I believe this is because the module is exporting the Webpack bundle from the dist
directory, and something about the bundle is tricking Axios into incorrectly believing that it is being run from the browser and not the server.
A workaround is to import Waterwheel directly from the lib
folder:
const waterwheel = require('./node_modules/waterwheel/lib/waterwheel')
This is not ideal, but it solves the problem.
@beejunk Thank you, I was struggling with this and couldn't figure out what's happening
@beejunk Thank you, this worked for us as well.
import Waterwheel from 'waterwheel/lib/waterwheel'
This also appears to be a problem specifically with 1.3.7
now pointing at the dist
file (as of this commit)
In 1.3.6
, the main export was "lib/waterwheel.js" which just worked. So either roll back or use the explicit
'waterwheel/lib/waterwheel'` path in your projects...
In 1.3.6, the main export was "lib/waterwheel.js" which just worked. So either roll back or use the explicit'waterwheel/lib/waterwheel'` path in your projects...
The problem is that using 'lib/whaterwheel.js' doesn't just work in all situations. For instance, the create-react-app build process fails when using 'lib/waterwheel.js', because the build script will not minify any third-party library that is not compiled to ES5 (see here for details.) This was previously the case with Waterwheel, and the change to exporting the 'dist' folder fixed that issue. Unfortunately, it created this issue as a result. So I don't think that rolling back would necessarily be a good idea.
It may be better if the module exported code that has only been compiled from the source to ES5, instead of exporting code that has been completely bundled and uglified by Webpack.
The same cannot import this lib in polymer 3