Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Server-side requests are broken #77

Open
beejunk opened this issue Mar 6, 2018 · 5 comments
Open

Server-side requests are broken #77

beejunk opened this issue Mar 6, 2018 · 5 comments

Comments

@beejunk
Copy link

beejunk commented Mar 6, 2018

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.

@drupalshift
Copy link

@beejunk Thank you, I was struggling with this and couldn't figure out what's happening

@danlaush
Copy link

danlaush commented Apr 13, 2018

@beejunk Thank you, this worked for us as well.

import Waterwheel from 'waterwheel/lib/waterwheel'

@geelen
Copy link

geelen commented Apr 13, 2018

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...

@beejunk
Copy link
Author

beejunk commented Apr 13, 2018

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.

@dravenk
Copy link

dravenk commented Oct 10, 2018

The same cannot import this lib in polymer 3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants