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

Using Gridsome source code in production instead of NPM #1511

Open
mklueh opened this issue May 26, 2021 · 11 comments
Open

Using Gridsome source code in production instead of NPM #1511

mklueh opened this issue May 26, 2021 · 11 comments

Comments

@mklueh
Copy link

mklueh commented May 26, 2021

Hello, I´m looking for a way to build Gridsome from the source code into an "artifact", that I can use in my application. (To clearify, yes I'm aware that js is not compiled but rather packaged :) )

The reason for this is I need a certain feature that is not contained in the latest Gridsome version, as discussed here: #1497.

For example in Java, I would simply build a .jar file out of the library that I then can embed into my application.

I would appreciate any tips on how to do that, without deploying my own npm package to npmjs.org.

@noxify
Copy link
Contributor

noxify commented May 27, 2021

You could use yarn link or npm link to reference to your local gridsome sources.

@mklueh
Copy link
Author

mklueh commented May 27, 2021

You could use yarn link or npm link to reference to your local gridsome sources.

I do that locally, but I need to deploy my site somehow via CI (Netlify)

@a-kriya
Copy link

a-kriya commented May 28, 2021

@mklueh It doesn't look like Gridsome can be bundled up into an artifact. If you'd like to modify parts of it, I think you can run a script on postinstall of your project that would monkey-patch what you need to under node_modules/gridsome/.

@mklueh
Copy link
Author

mklueh commented May 28, 2021

@mklueh It doesn't look like Gridsome can be bundled up into an artifact. If you'd like to modify parts of it, I think you can run a script on postinstall of your project that would monkey-patch what you need to under node_modules/gridsome/.

Thanks for that great idea, I think I'll try that.

Maybe it's also an option to git clone gridsome from my fork into the node_modules directory in a postinstall script if there are many changes. Otherwise it could get messy patching every single file

@mklueh mklueh changed the title Building Gridsome locally for production Using Gridsome source code in production instead of NPM May 28, 2021
@a-kriya
Copy link

a-kriya commented May 28, 2021

@mklueh Oh, if you have a public repository, then you can just use that as a dependency npm i --save mklueh/gridsome. This doesn't require publishing to NPM, and will automatically fallback to GitHub. To be explicit, it should be equivalent to npm i --save https://github.com/mklueh/gridsome.

@mklueh
Copy link
Author

mklueh commented May 28, 2021

@a-kriya oh wow thanks, that's amazing. Didn't know this was possible, but it definitely solves my problem :)

@a-kriya
Copy link

a-kriya commented May 28, 2021

@mklueh Sweet. I suppose once you've tested it out, this ticket can be marked closed.

@mklueh
Copy link
Author

mklueh commented May 29, 2021

It´s not working and I guess the reason is the actual gridsome package required for installation is not in the root package.

This is what I get:

$ yarn add https://github.com/mklueh/gridsome
yarn add v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To cle
ar this warning, remove package-lock.json.
[1/4] Resolving packages...
error Can't add undefined: invalid package version undefined.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Something like yarn add https://github.com/mklueh/gridsome/tree/master/gridsome won´t work either

Edit:

I´ve upgraded to yarn berry (yarn 2..), which should support Github subdirectories, but I´m running into this now:

$ yarn add https://github.com/mklueh/gridsome/tree/master/gridsome
Internal Error: Invalid descriptor (https://github.com/mklueh/gridsome/tree/master/gridsome)

trying to install it with npm leads to this error:

npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: https://github.com/mklueh/gridsome/tree/master/gridsome.
npm ERR! package.json npm can't find a package.json file in your current directory.

although the package.json is present in the directory

https://stackoverflow.com/questions/67748990/invalid-descriptor-with-yarn-berry-github-subdirectory-install

@a-kriya
Copy link

a-kriya commented May 30, 2021

@mklueh npm install 'https://gitpkg.now.sh/mklueh/gridsome/gridsome?master'

https://gitpkg.vercel.app/
https://gitpkg.vercel.app/guide/#advanced-how-this-function-is-implemented

I found it mentioned at https://stackoverflow.com/a/62275259

@a-kriya
Copy link

a-kriya commented Jun 18, 2021

@mklueh Did the above resolve the issue with install?

@djmtype
Copy link

djmtype commented Dec 1, 2021

@a-kriya

It worked for me locally. However, I didn't test the build on Netlify. Thanks!

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

4 participants