-
Notifications
You must be signed in to change notification settings - Fork 240
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
[RRFC] Multi-app Monorepo Support #463
Comments
Another note about file/folder references (in addition to my previous comments): running npm ERR! Cannot set property 'dev' of null
npm ERR! A complete log of this run can be found in:
npm ERR! /home/matt/.npm/_logs/2021-09-24T17_01_32_762Z-debug.log Though it does seem to sort of work, it actually creates a symlink from apps/a/node_modules/@my/c to package/c, and I believe this process will also hoist any dependencies of package "c" to the root ... neither of which is hat I want for a deployable "app artifact" |
Action items:
|
I think this functionality extends beyond monorepos. To create a lambda archive of my module's files and it's production dependencies I have to
|
Before Opening Please...
Motivation ("The Why")
Please see detailed description in #462, but tl;dr I'd like npm to "natively" support installing a package workspace's
npm pack
'd artifact into an app workspace's local node_modules folder for production deployment without a bunch of extra prerelease/registry rigmarole. In a sense treat the monorepo/workspace root as a kind of ephemeral local registryExample
A monorepo with three workspaces, two apps "a" and "b", one package "c". Apps "a" and "b" depend on package "c", and are deployed to different locations (Docker, AWS Lambda, Google Cloud Functions, etc). Following best practices, minimizing build tooling, and wanting to ship a lean, production-only, app artifact, I'd like to an app structure like this (the dist folder is just meant to represent some production-ready code, this is just to show a folder structure that expresses the relationship between packages):
With this structure I'd zip the apps/a folder and push it to AWS, or
COPY
it into a Docker image in my Dockerfile, etc.How
Current Behaviour
This structure can be roughly achieved by running these commands:
Note:
I'm not sure why it's necessary to pack it twice, but something about running
npm i my.tgz -w @my/a
needs the tarball to exist in both the root and the workspace. Maybe a separate bug about resolving install paths when-w
is set?Also worth noting this changes apps/a/package.json's
"@my/c"
dependency from"^1.0.0"
to"file:my-c-1.0.0.tgz"
which I have to immediately undo in order to maintain the dev-time hoisted dependency functionality I want.Desired Behaviour
Allow a way to specify that
npm install
and/ornpm ci
should look to the workspaces in the current monorepo before reaching out to a registry. If a match is found callnpm pack
on that workspace and "serve" the resultant tarball (or its contents). Some suggestions for what this'd look like in the cli:npm i --only=prod --prefer-workspaces -w @my/a
npm i --only=prod --prefer-local -w @my/a
npm i --only=prod --registry=file:///. -w @my/a
It should work for
npm ci
as well.References
The text was updated successfully, but these errors were encountered: