Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Build when installed from GitHub #785

Open
AadamZ5 opened this issue Oct 22, 2021 · 1 comment
Open

Build when installed from GitHub #785

AadamZ5 opened this issue Oct 22, 2021 · 1 comment

Comments

@AadamZ5
Copy link

AadamZ5 commented Oct 22, 2021

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 and npm 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 BEFORE prepublishOnly

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.

@junminstorage
Copy link
Contributor

junminstorage commented Oct 23, 2021

It used to target 'dist' but got changed in #683 with the reason specified in the PR.

Without affecting current setup, could we build to both folders?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants