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

Documentation on how to use npm package in development #398

Closed
queenvictoria opened this issue Sep 13, 2021 · 1 comment · Fixed by #654
Closed

Documentation on how to use npm package in development #398

queenvictoria opened this issue Sep 13, 2021 · 1 comment · Fixed by #654

Comments

@queenvictoria
Copy link
Contributor

queenvictoria commented Sep 13, 2021

Hi there. I'm wondering if others have this issue: we fork lucide, create a branch, make a new icon, and, possibly, submit a PR.

Regardless of whether we think the icon has wider appeal, we now need to start using the new package.

As a monorepo, with intermediate build steps, it wasn't clear to me how to go about using the new package (lucide-vue in our case). I've been around the world in the last week trying different methods to get this working.

What doesn't work

  • Adding the git repo to package.json. For example npm install queenvictoria/lucide#cool-icon. As there is no build step and the package is nested into packages/lucide-vue.
  • Using gitpkg service on the sub directory as the build steps occur in the root directory of lucide.

What does work-ish

Add a postinstall step to your projects package.json (and removing lucide-vue from dependencies). I read this StackOverflow answer right at the very beginning of this journey and dismissed it as too complicated. However it does work and, in the end, not so complicated.

  "scripts": {
    "build:lucide-vue": "mkdir build_modules && cd build_modules && git clone git@github.com:queenvictoria/lucide.git && cd lucide && git checkout cool-icon && yarn install && yarn workspace lucide build && yarn workspace lucide-vue build && cd ../../ && npm install build_modules/lucide/packages/lucide-vue",
    "postinstall": "npm run build:lucide-vue"
  },

Why -ish?

So this works well locally. I am still working on our deploy system to to bring it in to production. There are currently a couple of failures:

  1. npm WARN lifecycle [repo]@[version]~postinstall: cannot run in wd [repo]@[version] npm run build:lucide-vue (wd=/usr/src/app)
  2. WARN Module lucide-vue/nuxt not found. Please ensure lucide-vue/nuxt is in devDependencies and installed. HINT: During build step, for npm/yarn, NODE_ENV=production or --production should NOT be used.

To resolve 1) I've added (to our Dockerfile) RUN npm set unsafe-perm true. Now it looks like build:lucide-vue gets called many times (possibly in a loop) which causes a timeout during our build step (currently 20 minutes)

What next?

I'd really like to understand if there is a proscribed method for doing this. And or that this be added to the documentation (perhaps in contributing). Or, if it's already there, apologies!

@Rogdham
Copy link

Rogdham commented Nov 29, 2021

A possible solution would be to use the patch-package lib if the changes are not too big. Probably not the answer you were looking for, but a workaround.

It goes like this: you commit patches fo some libraries into your repo, and patch-package makes sure to apply the patches when needed (e.g. during install).

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

Successfully merging a pull request may close this issue.

2 participants