Packing of layers is broken
See original GitHub issue/cc @juanjoDiaz
Folow up to https://github.com/serverless/serverless/pull/8602, where layer packaging issue was put to light
Related bugs: #5583, #5892 and #7837
Currently layers are packaged taking into package include
and exclude
patterns as defined on service level package
property and on layer layers[].package
property.
Still glob patterns are resolved against layer path, so service level patterns in a bad way influence what’s being packaged for layer, and that often leads to bugs and unexpected results
Proposed fix
I believe we should either:
- Ignore service level patterns when packaging the layer (respect purely layer level patterns). Downside is that we may break packaging for users, which by chance rely on current behavior (still I hope that’ll be rare)
- Package against service folder, but prepand patterns with
['!**', layerPath]
and map layer level pattenrs to${layerPath}/**/${layerPattern}
. Still I’m not 100% sure weather it’s fully safe
At this point I’m leaning towards (1), as it will make configuration less confusing (it’s more intuitive to assume that include
and exclude
patterns as set in layer context will be applied against layer directory and not service directory).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
It can be breaking for users which put on service level patterns which they expected to work against layer path, while I think in general users didn’t expect patterns to work that way (when they found, it works that way, they started to introduce workarounds to reverse effect of patterns in service, like here: https://github.com/serverless/serverless/issues/5583).
Also I think we never documented that patterns from service were taken into account.
I’d treat it as bug fix that’s worth addressing upfront, and I’d expect that if it’ll break for some it’ll be really rare.
I’ll create the PR after #8581 is merged or they would conflict.