Closed mariusa closed 4 years ago
A post on Workspaces is planned, and you can certainly use Workspaces for this use case, I'd imagine, though it'd be a little bit outside the target use case. Might be a bit too situation-specific for this blog series?
If you're comfortable using a monorepo, you could define your apps and all their shared deps as workspaces, so you'd have something like:
my-big-ol-mono-repo
+-- shared-deps
| +-- foo
| +-- bar
| +-- baz
+-- applications
+-- acme-customer-site
+-- intranet
+-- wob-blag
Then in the root package.json
, have this:
{
"workspaces": [
"applications/*",
"shared-deps/*"
]
}
That would, of course, re-publish all of your applications any time you push an update to any of them, or to any shared deps, and you'd have to configure your PaaS to use a specific folder to run each application. But it would guarantee that things stay in sync. (And there'd be nothing stopping you from also publishing some or all of those shared deps as npm packages, of course.)
What / Why
We'd like to share a few specific Vue components or .js files between multiple projects, front-end and backend (nodejs). Backend is published to a PaaS (Heroku).
There are alternatives, none good: https://www.smashingmagazine.com/2018/04/sharing-code-between-projects/ https://stackoverflow.com/questions/11278921/how-to-share-code-between-node-js-apps (don't want to go through the hassle of publishing private modules)
Bit looks good, but it requires signup to another 3rd party service. We already use github & npm.
Could npm v7 workspaces handle this? How?
Would be great to
Thanks!