Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to contribute, how do you build a linkable lib? #509

Open
1 of 17 tasks
colmben opened this issue Sep 13, 2019 · 1 comment
Open
1 of 17 tasks

Trying to contribute, how do you build a linkable lib? #509

colmben opened this issue Sep 13, 2019 · 1 comment

Comments

@colmben
Copy link
Contributor

colmben commented Sep 13, 2019

I'm submitting a...

  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report
  • Performance issue
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Current behavior

I am trying to test a small change that will enable the forgotten password flow to work correctly. To do that I am trying to link to a fork on github (using something like this in my package.json:

"angular-token": "git+https://github.com/colmben/angular-token.git#fixBranch",

)

I have tried a few different ways but I can't get the repo to build in a way that is linkable like this, due to the way the repo is structured with the example app in root and the actual lib in projects/angular-token.

If I build:lib, I get files in a root dist folder. I can commit this (which is the way to create a repo that is directly linkable as above) but when I npm install the repo it gives me an entry for angular-token-app instead of angular-token and that entry doesn't seem to give me access to AngularTokenService/AngularTokenModule in app.modules.

I have gone as far as using git subtree split to create a repo from /projects/angular-token, with the dist copied in from the root dir. This actually works locally but Heroku (where I am trying to test the issue) says it can't resolve angular-token.

Could any share how they are testing changes? The fix is only testable on a real server so I can't just play around with the local node_modules.

Environment

Angular-Token version: 7.1.0-rc.0
Angular version: 8.2.2

Bundler

  • Angular CLI (Webpack)
  • Webpack
  • SystemJS

Browser:

  • Chrome (desktop) version XX
  • Chrome (Android) version XX
  • Chrome (iOS) version XX
  • Firefox version XX
  • Safari (desktop) version XX
  • Safari (iOS) version XX
  • IE version XX
  • Edge version XX

Others:

@colmben
Copy link
Contributor Author

colmben commented Sep 15, 2019

I ended up using a convoluted process of making a change, npm run build:lib, "git subtree split" out the dist/angular-token/ folder, pushing that to the master of a my-angular-token repo and linking to that. So (as far as I can remember this is how I did it, you may need to play around with the general idea if this doesn't work straight off...)

git clone the repo locally

Change the remote to an empty github repo of your own, e.g.:
git remote set-url origin https://github.com/<your-github-username>/my-angular-token.git

Make your changes then build and commit

npm run build:lib
git commit -am 'fix'

Don't push anything yet, instead split out a subtree of the local repo to a branch for the dist files, and then push that to the remote (as master if wish, which is what I am doing here)

git subtree split --prefix=dist/angular-token/ -b fixBranch
git push origin fixBranch:master

You can then link to your repo in package.json like this:
"angular-token": "git+https://github.com/<your-github-username>/my-angular-token.git#master"

I couldn't for the life of me figure out how to get that subtree branch to pull any subsequent changes to the master dist files after any new changes/builds. So I ended up just blowing the local subtree branch out of the water and redoing the subtree split after new changes.
git branch -D fixBranch

Almost certainly my lack of knowledge showing here, but any clearer advice about to contribute/test the lib would be useful.

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

No branches or pull requests

1 participant