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
232 stars 26 forks source link

postinstall hook does not work properly #27

Closed infiniteluke closed 8 years ago

infiniteluke commented 8 years ago

The postinstall hook for waterwheel attempts to run npm run build. I realize now that in my testing, I had already manually run npm i directly on the package... When installing waterwheel from your project, the dev dependencies are not installed and therefore the post install hook fails (since webpack etc.. are dev dependencies).

A couple options:

  1. Use the prepublish hook to publish waterwheel with it's build:
    • Con: prepublish doesn't run on npm i --save waterwheel only on npm i
  2. Commit the dist dir to the repo
    • Con: Dirty 💩
  3. Continue using postinstall and add dependencies needed for building to production dependencies
    • Con: Longer install times for everyone 🕙
  4. Use something like postinstall-build to handle install dev dependencies on postinstall and pruning them out after.
    • Con: Idk
infiniteluke commented 8 years ago

Addressed in https://github.com/acquia/waterwheel/commit/aa62af2066ea07d11aaae28bd6186a138714c475 and https://github.com/acquia/waterwheel/commit/4d026bfa18f7dabb8d1803235ccf3c470f6c683b

For the record, we decided to do building manually before publishing to NPM. This could be wrapped up in a script that 1) does the build then 2) runs npm publish, but for now it's a pragmatic approach that avoids the cons of the above approaches. The underlying issue of the built code not being available without devs manually building is solved.

I'm using import '../../path/to/node_modules/waterwheel/dist/waterwheel.js'; which adds Waterwheel to window.

Thanks @mattgrill!