Build when installed from GitHub #785
Description
After seeing that the graphql-ws
package is now a supported fetcher option merged in with PR #755, I was excited to try this functionality.
I want to use this new functionality that isn't yet offered in the NPM package, and I know that the volunteer team is waiting until another PR in graphql/graphql-js is merged before publishing another version of this package to NPM. I'm not arguing against this decision.
A mitigation that might help users waiting for this functionality is to better support git-based installs of this library. The two most popular package managers, NPM and Yarn, both offer ways to install packages from a git repository. However, this repository is configured in a way that does not conventionally build. The entry point to this package is not dist/index,js
, and the built files are saved in a folder at ./resources/npmDist
.
I do not know why the package does not build to a root-level ./dist
folder, and upon publish, uses a .npmignore
file to ignore ./src
, but it makes supporting git-based installs a bit more difficult. Is there any reason to using the arbitrary directory ./resources/npmDist
? Couldn't the custom-build script instead build to ./dist
? That would eliminate the need to copy some files in the build script anyways.
With some ignore files in a particular configuration, NPM will only see build artifacts, and GitHub will only see source artifacts.
.gitignore
# ... Current ignores
dist
.npmignore
src
# Any other src files you don't want to distribute with the NPM package
Using a prepare
script in the package.json
will tell NPM what to do when being installed from a git repository. However, this script is also ran before some other hooks:
- Runs any time before the package is packed, i.e. during
npm publish
andnpm pack
- Runs BEFORE the package is packed
- Runs BEFORE the package is published
- Runs on local
npm install
without any arguments - Run AFTER
prepublish
, but BEFOREprepublishOnly
This could possibly break some current workflows if not integrated properly with the current build process.
Some other methods are offered in this answer from Stack Overflow, some of which could possibly be integrated with the current build process, which takes place in the ./resources
folder using build-npm.js
.
Any thoughts? This would mitigate #746.