Support monorepo with NPM Workspaces
Is your feature request related to a problem? Please describe.
Currently, it is not possible to run fastly compute serve inside a monorepo with NPM Workspaces as demonstrated by this sample repo. A @fastly/js-compute not found in package.json error is thrown.
➜ fastly-error git:(main) npm run start:client
> [email protected] start:client
> npm start -w packages/client
> @package/[email protected] start
> fastly compute serve
✓ Initializing...
✓ Verifying package manifest...
✗ Verifying local javascript toolchain...
ERROR: `@fastly/js-compute` not found in package.json.
To fix this error, run the following command:
$ npm install --save-dev @fastly/js-compute
npm ERR! Lifecycle script `start` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: @package/[email protected]
npm ERR! at location: [...]/fastly-error/packages/client
I guess the issue is that when in a monorepo, the node_modules is on the root level and the relevant script runs in the context of a child-package (where also the relevant package.json is).
Describe the solution you'd like
I don't know the reason it's build as it is today, but I've never before come across another NPM package that inspects the package.json file to make sure dependencies are added. It seems to me to miss the target. The relevant question is rather if the dependency is installed or not and the best way to find out is by using it, right?
Additional context
NPM Workspaces Related to package @fastly/js-compute Related to issue #359
Hi @marlun78
We've been working on the following PR for a while now to try and address issues with the Fastly CLI build process: https://github.com/fastly/cli/pull/640
Once this is merged (and released) I'll ping back in this ticket so you can upgrade and see if the changes work better for your situation. If not, then we can continue the discussion.
Thanks.
Hi @marlun78
Apologies, I just realised I said I would report back once #640 had been merged. Since that PR was merged I was discussing some similar issues internally with a colleague and so https://github.com/fastly/cli/pull/671 is currently in the works which I think might actually resolve this issue.
Just an FYI that this issue will be closed automatically once that PR is merged.