fix: make ts-node
dependency truly optional
#1825
Merged
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.
What did you implement:
ts-node
is meant to be an opt-in dependency (as in, a dependency that is not installed by default, but will be used if installed) per #636, but it's been added as an optional dependency rather than an .. err ... "right kind of optional dependency" (aka peer dependency set as optional).In the context of
package.json
, "optional dependencies" are ones that the package manager should try to install but skip if they error - they're intended for dependencies that are os-specific likefsevents
or the underlying binaries foresbuild
- so right now,ts-node
will always be installed because it does not have any os constraints, and in turn it leads to complaints about missing peer dependencies viats-node
:In the context of
package.json
, the correct way to express "optional" in the way most people think is to include the dependency as a peer dependency withoptional: true
in its meta settings.How did you implement it:
I added
ts-node
as an optional peer dependency, and removedtypescript
and@types/node
as peer dependencies since they're not used directly byserverless-webpack
How can we verify it:
Install
serverless-webpack
, do annpm ls
and see thatts-node
isn't installed nor are there any dependency warnings - you can then installtypescript
andts-node
, and you'll still not have any dependency warnings.Also see serverless/serverless-azure-functions#517 for prior art
Todos:
Write testsWrite documentationFix linting errorsMake sure code coverage hasn't droppedProvide verification config / commands / resourcesIs this ready for review?: Yes
Is it a breaking change?: Debatable 😅