From 456a363668ad416fb3b0aa80362884b411e88763 Mon Sep 17 00:00:00 2001 From: Ryan Block Date: Fri, 2 Feb 2024 15:31:26 -0800 Subject: [PATCH 1/2] Fix issue where Lambda runs against plugin Lambdas installed as dependencies --- changelog.md | 8 ++++++++ src/hydrate.js | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 0322b99..9f2a9ee 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,14 @@ --- +## [4.0.1] 2024-02-02 + +### Fixed + +- Fixed issue where treeshaking runs against Lambdas with explicit dependency manifests in cases where those Lambdas were themselves plugins installed as dependencies + +--- + ## [4.0.0] 2024-01-09 ### Added diff --git a/src/hydrate.js b/src/hydrate.js index b707fdd..fcf4f14 100644 --- a/src/hydrate.js +++ b/src/hydrate.js @@ -62,6 +62,12 @@ function hydrator (inventory, installing, params, callback) { // Does this project have any Lambdae? let hasLambdae = inv.lambdaSrcDirs?.length + let manifestFiles = [ 'package.json', 'requirements.txt', 'Gemfile' ] + let possibleLambdaManifests = [] + if (hasLambdae) possibleLambdaManifests = inv.lambdaSrcDirs.reduce((acc, dir) => { + acc.push(...manifestFiles.map(manifest => join(dir, manifest))) + return acc + }, []) // From here on out normalize all file comparisons to Unix paths let sharedDir = inv.shared && inv.shared.src && stripCwd(inv.shared.src, cwd) @@ -71,10 +77,11 @@ function hydrator (inventory, installing, params, callback) { * Find our dependency manifests */ // eslint-disable-next-line - let pattern = p => pathToUnix(`${p}/**/@(package.json|requirements.txt|Gemfile)`) + let pattern = p => pathToUnix(`${p}/**/@(${manifestFiles.join('|')})`) let dir = basepath || '.' // Get everything except shared let manifests = globSync(pattern(dir), { dot: true }).filter(file => { + if (possibleLambdaManifests.includes(file)) return true if (isDep(file)) return false if (sharedDir && file.includes(sharedDir)) return false if (viewsDir && file.includes(viewsDir)) return false From ef68e36285a77cf67e52ef403c8c43c6c6e1e1d7 Mon Sep 17 00:00:00 2001 From: Ryan Block Date: Fri, 2 Feb 2024 17:41:13 -0800 Subject: [PATCH 2/2] Don't forget to denormalize cwd in dependency plugin Lambdas --- src/hydrate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hydrate.js b/src/hydrate.js index fcf4f14..19f118b 100644 --- a/src/hydrate.js +++ b/src/hydrate.js @@ -65,7 +65,7 @@ function hydrator (inventory, installing, params, callback) { let manifestFiles = [ 'package.json', 'requirements.txt', 'Gemfile' ] let possibleLambdaManifests = [] if (hasLambdae) possibleLambdaManifests = inv.lambdaSrcDirs.reduce((acc, dir) => { - acc.push(...manifestFiles.map(manifest => join(dir, manifest))) + acc.push(...manifestFiles.map(manifest => stripCwd(join(dir, manifest), cwd))) return acc }, [])