BUG (monorepo): Package dependencies aren't included when root level dep also exists.
See original GitHub issueHi! Awesome package you have here 😃
Created a minimal example repo reproducing the issue we are experiencing here
Currently, when 2 functions in our monorepo have conflicting dependencies declared, serverless-jetpack
is failing to include the node_modules
that includes the dependency if it is not the root node_modules
. So for example:
functions/a/ # depends on diff ^4.0.1
package.json
src/
index.js
node_modules/
diff/
functions/b/ # depends on diff @3.5.0
package.json
src/
index.js
node_modules/
diff/
Results in the following artifacts:
a/ # no node_modules present
functions/a/src/index.js
functions/a/package.json
package.json
b/ # root node_modules present
node_modules
functions/b/src/index.js
functions/b/package.json
package.json
I can spend some time digging into this issue this weekend, but wanted to open up the issue with an example/description so if anyone else wants to look into it they have some reference info.
Details
serverless-jetpack
version: ^0.5.0
serverless
version: ^1.48.0
/cc @ryan-roemer
edit:
was able to narrow down the source of the issue:
# global include
package:
individually: true
include:
- package.json
- "!**/yarn.lock"
- "!functions/**" # this negative include comes after the function-level dependencies in the globInclude array
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
The Case for Monorepos: A sane Workspace Setup (Part 2)
Learn how to setup dev tooling in a monorepo, run tasks efficiently, release multiple packages and overcome common DevOps challenges.
Read more >Things I wish I had known when I started JavaScript monorepo ...
Root package.json must list all monorepo packages in it's dependencies field. The reason is simple: all packages of the monorepo will be ...
Read more >Inside the pain of monorepos and hoisting - Jonathan Creamer
One of the most painful cons, when it comes to working in a specifically JavaScript based monorepo, is the pain that comes from...
Read more >Subprojects - The Meson Build system
A subproject example ... Usually dependencies consist of some header files plus a library to link against. To declare this internal dependency use ......
Read more >Problems with React SketchApp in Lerna monorepo with yarn ...
Update: 1 month later. one mayor problem with my repo was that i had forgot to add "packages":["packages/*"] to my lerna.json in root....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
SUPER WEIRD STUFF
On a hunch, I decided to cut out all of jetpack and just focus on our
globby()
andnanomatch
inputs and outputs. I created: tmp-glob-test.jsHere’s the weird stuff: If the working directory matches the “set working directory” internally to jetpack (which is then passed to
globby()
via `cwd) then different globbing behavior happens.Here’s a basic example:
Takeaways
process.cwd() === cwd
then a simple!functions
(and not!functions/**
) gets us pretty much what we want for our monorepo scenario – exclude all offunctions
except for things added back in and the dependencies added by Jetpack.globby()
to see if there’s some insight into this behavior. It seems super weird thatglobby(patterns, { cwd })
has that parameter but the actual current working directory affects results…Notes
that sounds like a good approach! the greatest difficulty i encountered trying to fix this was maintaining the existing functionality for non-monorepos so adding a new config option may very well be required. as you said there is no equivalent sls behavior in the monorepo scenario so needing a little extra in our config to get it to work seems fine.