acquia / waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
https://github.com/acquia/waterwheel.js
233 stars 26 forks source link

Publish modules for easier integration with other projects #64

Closed jeremdow closed 6 years ago

jeremdow commented 6 years ago

I've been using create-react-app to scaffold React projects that I'm working on, but was having trouble including waterwheel.js in their default production build.

For completeness sake, here is the actual error output:

Creating an optimized production build...
Failed to compile.

static/js/main.11fa2008.js from UglifyJs
Unexpected token: name (Base) [./~/waterwheel/lib/helpers/base.js:1,0][static/js/main.
11fa2008.js:16265,23] 

I suspect this is pretty meaningless in this context, but looking into it, basically react-scripts can't process waterwheel without first running it through Babel, which shouldn't need transpiling to ES5 per se, but for some obscure Uglify/Webpack 2 reasons, it still does.

I could just "eject" my project from the default configuration to modify the build scripts, or open what may be underlying issues with Uglify, Webpack 2 or react-scripts, but given the primary benefit of create-react-app is to abstract away exactly these kind of arcane configuration issues, which Drupal developers (like myself) would tend to be less familiar with, it would seem to benefit this library to make itself as compatible as it possibly can be.

To that end, I tried converting waterwheel to use ES6 modules internally, and publish prebuilt ES6 and UMD modules using Rollup, adapting a process I have seen in other libraries.

The result, which I am able to use without issue, is here #63.

jeremdow commented 6 years ago

Never mind, #65 works just as well, requires fewer changes, and doesn't break testing.

mattgrill commented 6 years ago

Looks like this could be closed now. Thanks again.