project-serum / swap-ui

React Component for Swapping on the Serum DEX
Apache License 2.0
113 stars 117 forks source link

Prepare script to allow module installs from Github #41

Closed secretshardul closed 3 years ago

secretshardul commented 3 years ago

NPM allows you to install modules directly from Github, which is useful for testing forks. Syntax:

npm i https://github.com/project-serum/swap-ui

The build files for this repo go in the dist folder, which is not committed in version control. This breaks the intended behaviour of the above script. The dist folder does not get added to node_modules.

This can be remedied with a prepare script. These scripts are run on client side when modules are installed from github.

Source: https://stackoverflow.com/a/50490565/7721443

armaniferrante commented 3 years ago

Awesome thanks!

secretshardul commented 3 years ago

@armaniferrante using yarn inside the prepare script has a drawback. Installs fail if the local machine doesn't have yarn. I'm currently facing this on Netlify. I made it work by using "prepare": "npm run build".

I don't think npm run build is a good option, since the module uses yarn. How about replicating the contents of the build script directly?

"build": "rm -rf dist && tsc --build tsconfig.json",
"prepare": "tsc --build tsconfig.json"
armaniferrante commented 3 years ago

Is there a good reason to not just force people to install yarn? I'm fine with that.

secretshardul commented 3 years ago

Netlify's CI/CD breaks. It either runs Yarn or NPM, not both. I've raised a ticket, but here's what works currently:

  1. Remove npm's package-lock.json and migrate project to yarn; or
  2. Remove yarn from the prepare script. https://github.com/secretshardul/swap-ui/blob/3da62089d5044f626991a76d5b0adc4cdeaed7f0/package.json#L30
secretshardul commented 3 years ago

I've made PR #54 to resolve this

@armaniferrante using yarn inside the prepare script has a drawback. Installs fail if the local machine doesn't have yarn. I'm currently facing this on Netlify. I made it work by using "prepare": "npm run build".

I don't think npm run build is a good option, since the module uses yarn. How about replicating the contents of the build script directly?

"build": "rm -rf dist && tsc --build tsconfig.json",
"prepare": "tsc --build tsconfig.json"