Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Add custom build options to pack #34

Open
Junkern opened this issue May 16, 2018 · 6 comments
Open

Add custom build options to pack #34

Junkern opened this issue May 16, 2018 · 6 comments

Comments

@Junkern
Copy link
Contributor

Junkern commented May 16, 2018

I am using macos and building an installer for windows. One of my dependencies is grpc which uses binary modules.

Installing and running the cli on a windows computer results in Failed to load gRPC binary module because it was not installed for the current system, which could be fixed with rebuilding it for windows (https://stackoverflow.com/questions/47979568/aws-lambda-error-failed-to-load-grpc-binary-module-because-it-was-not-installed).

Is it possible to add an option that somehow triggers the rebuild?

@jdx
Copy link
Contributor

jdx commented May 16, 2018

There is no support for building the CLI on windows and right now I don't have any plans to change that (they're all written in bash).

EDIT: sorry I actually read what you wrote (just woke up 😫). I think we'd need to add some kind of step to run postinstall. Maybe in the package.json scripts?

@jdx
Copy link
Contributor

jdx commented May 16, 2018

First I was just thinking I could run npm run postinstall after it's installed but it's not that easy. we have node, but npm might not be actually installed on the machine

@jdx
Copy link
Contributor

jdx commented May 16, 2018

A hook might be better here. We do have the update hook that is called anytime the CLI is updated. Perhaps we could just call that somehow when the CLI is first installed.

@Junkern
Copy link
Contributor Author

Junkern commented May 17, 2018

So, rebuilding is not possible if we don't have npm installed on the machine? Yarn also offers no rebuild capabilty (yarnpkg/yarn#756). I currently see two options:

  1. also ship/install npm for the target machine/OS so that we can do an npm rebuild during postinstall or update hook. That will increase the package size and make installing slower.
  2. Add the possibility to execute commands before everything is packed into the .exe/pkd/whatever. That way I could execute npm rebuild grpc --target=6.1.0 --target_arch=x64 --target_platform=linux --target_libc=glibc and have the dependency already ready for the target machine.

I think I will try to do the rebuild manually before I pack:win and try if it works on the target machine

@jdx
Copy link
Contributor

jdx commented May 17, 2018

We don't ship with yarn or npm. I would not recommend that approach as your users will need to also have all the dependencies installed to compile the code. I think you'll need to do something like have the prepare step of your CLI compile for the different targets.

@jdx
Copy link
Contributor

jdx commented May 17, 2018

Something would need to be added here I think: https://github.com/oclif/dev-cli/blob/master/src/tarballs/build.ts#L88

It could run whatever is in the prepare step, but because the devDependencies won't be installed that might not work quite right. We could either add a new type of script like oclif:build or something and set a couple of env vars you could use to see what the arch and platform it is targeting is. OR we could run the prepare step and put the ./node_modules/.bin from the root of the project (not the root of the current target) which would have all the devDependencies installed.

I'm not sure which is better right now

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