acquia / waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API

Home Page:https://github.com/acquia/waterwheel.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postinstall hook does not work properly

infiniteluke opened this issue · comments

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

Addressed in aa62af2 and 4d026bf

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!