feat: Respect the package-lock.json for a NodeJS Lambda function #681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Respect the
package-lock.json
so NodeJS Lambda for reproducible builds, which are critical in production environments. Similarly, like for the Poetry, copy a lock file, if such is present, to a temporary build directory. npm will use apackage-lock.json
file when available in a working directory.In the example
package.json
, require a lowerrequests
version to demonstratepackage-lock.json
usage.package.json
specifies~0.2.0
and the latest available matching version is0.2.2
, butpackage-lock.json
freezes version0.2.1
and that version gets installed with this change, while previously the0.2.2
would be installed.Motivation and Context
npm
because thepackage-lock.json
is not copied to a temporary build directory.Breaking Changes
package-lock.json
is not present in the source directory.package-lock.json
is present, it will be honoured going forward, by default, which would be an expected behaviour. This should be desired because a new version of a dependency might unexpectedly break a deployment, as mentioned in the package.py should respect package-lock.json when creating an archive for Node.js lambda functions. #423, while locked dependencies would have been tested in unit tests. If someone doesn't want to lock their dependencies, they shouldn't have a lock file.How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectsterraform apply
inexamples/build-package/
(with commented out irrelevant Python examples for clarity).builds
directory, I checked whether the zip file's content appeared as expected.requests-0.3.0
dependency.reqests-0.2.1
dependency, as expected.pre-commit run -a
on my pull request