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:
- Use the
prepublish
hook to publish waterwheel with it's build:- Con:
prepublish
doesn't run onnpm i --save waterwheel
only onnpm i
- Con:
- Commit the dist dir to the repo
- Con: Dirty 💩
- Continue using
postinstall
and add dependencies needed for building to production dependencies- Con: Longer install times for everyone 🕙
- 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!