From 193a8568629eb91a807a601621e08367e9ee45f6 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Dec 2024 13:31:10 +0100 Subject: [PATCH 1/6] Configurational dependencies --- text/0004-configurational-dependencies.md | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 text/0004-configurational-dependencies.md diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md new file mode 100644 index 0000000..1a3d021 --- /dev/null +++ b/text/0004-configurational-dependencies.md @@ -0,0 +1,55 @@ +# Configurational dependencies + +## Summary + +A new type of dependencies for installing configuration and hooks. + +## Motivation + +We want to make it possible to share some configurations between projects. Storing the configuration in regular dependencies is not an option as we might need the configuration during installation of the "regular" dependencies ("dependencies", "devDependencies", and "optionalDependencies"). Hence, we need to install these configurational dependencies before other types of dependencies. + +Some examples of usage: + +* Installing hooks used by [`.pnpmfile.cjs`](https://pnpm.io/pnpmfile). +* Installing the list of dependencies that are allowed to be built (the [pnpm.onlyBuiltDependenciesFile](https://pnpm.io/package_json#pnpmonlybuiltdependenciesfile)). +* Installing [catalogs](https://pnpm.io/catalogs). +* Loading patch file. + +## Detailed Explanation + +There will be a new field in `package.json` called `pnpm.configDependencies`. For example: + +```json +{ + "name": "my-pkg", + "version": "0.0.0", + "pnpm": { + "configDependencies": { + "my-configs": "1.0.0+sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==" + } + } +} +``` + +These new type of "configurational" dependencies will be npm packages with a lot of limitations: + +* They won't have any dependencies. Even if they will have dependencies, pnpm will ignore them during installation. +* They will not have lifecycle scripts. +* They will only be installable via exact versions. + +## Rationale and Alternatives + +For the list of "onlyBuiltDependencies" currently we can load them from `node_modules`. However, that does introduce some "works on my machine" issues as we don't have list during the linking from store stage. As a result, if the dependency is not allowed to be built, we still might load it from the side-effects cache. + +## Implementation + +These dependencies will be installed as early as possible in order to be able to load settings from it. So this should happen ouside of the `@pnpm/core` module. When we call `mutateModules` we should already have all the configurations from `pnpm.configDependencies` loaded and ready. + +## Prior Art + +## Unresolved Questions and Bikeshedding + +{{Write about any arbitrary decisions that need to be made (syntax, colors, formatting, minor UX decisions), and any questions for the proposal that have not been answered.}} + +{{THIS SECTION SHOULD BE REMOVED BEFORE RATIFICATION}} + From 7a4335b3ff293aceb7ef9ecfad9bedc922d221a1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Dec 2024 13:51:00 +0100 Subject: [PATCH 2/6] Add note about directory name --- text/0004-configurational-dependencies.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md index 1a3d021..18da68a 100644 --- a/text/0004-configurational-dependencies.md +++ b/text/0004-configurational-dependencies.md @@ -37,6 +37,8 @@ These new type of "configurational" dependencies will be npm packages with a lot * They will not have lifecycle scripts. * They will only be installable via exact versions. +These dependencies will be installed into a new directory (name to be decided), not into `node_modules`. + ## Rationale and Alternatives For the list of "onlyBuiltDependencies" currently we can load them from `node_modules`. However, that does introduce some "works on my machine" issues as we don't have list during the linking from store stage. As a result, if the dependency is not allowed to be built, we still might load it from the side-effects cache. From 008138c9584123ec74adb10493c694d5637a456f Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Dec 2024 22:53:41 +0100 Subject: [PATCH 3/6] Update text/0004-configurational-dependencies.md Co-authored-by: Brandon Cheng --- text/0004-configurational-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md index 18da68a..14e5fc1 100644 --- a/text/0004-configurational-dependencies.md +++ b/text/0004-configurational-dependencies.md @@ -41,7 +41,7 @@ These dependencies will be installed into a new directory (name to be decided), ## Rationale and Alternatives -For the list of "onlyBuiltDependencies" currently we can load them from `node_modules`. However, that does introduce some "works on my machine" issues as we don't have list during the linking from store stage. As a result, if the dependency is not allowed to be built, we still might load it from the side-effects cache. +For the list of "onlyBuiltDependencies" currently we can load them from `node_modules`. However, that does introduce some "works on my machine" issues as we don't have the list during the linking from store stage. As a result, if the dependency is not allowed to be built, we still might load it from the side-effects cache. ## Implementation From 73eaab804ac6962a84a20b29d946e3274973752b Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Dec 2024 22:56:19 +0100 Subject: [PATCH 4/6] Apply wording improvements --- text/0004-configurational-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md index 14e5fc1..6405490 100644 --- a/text/0004-configurational-dependencies.md +++ b/text/0004-configurational-dependencies.md @@ -41,7 +41,7 @@ These dependencies will be installed into a new directory (name to be decided), ## Rationale and Alternatives -For the list of "onlyBuiltDependencies" currently we can load them from `node_modules`. However, that does introduce some "works on my machine" issues as we don't have the list during the linking from store stage. As a result, if the dependency is not allowed to be built, we still might load it from the side-effects cache. +The `"onlyBuiltDependencies"` list can currently be loaded from `node_modules`. However, this introduces "works on my machine" issues since the list isn't available during the link-from-store stage. As a result, if the dependency is not allowed to be built, it might still be loaded from the side-effects cache. ## Implementation From 9ac01dc9bf8c50db77c0a5ccf8c91266e5a6d4a1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Dec 2024 23:05:17 +0100 Subject: [PATCH 5/6] Mention templates --- text/0004-configurational-dependencies.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md index 6405490..e288265 100644 --- a/text/0004-configurational-dependencies.md +++ b/text/0004-configurational-dependencies.md @@ -49,6 +49,8 @@ These dependencies will be installed as early as possible in order to be able to ## Prior Art +There was a big RFC by Brandon Cheng about a much more powerful system using [templates](https://github.com/pnpm/rfcs/pull/3), which was rejected. + ## Unresolved Questions and Bikeshedding {{Write about any arbitrary decisions that need to be made (syntax, colors, formatting, minor UX decisions), and any questions for the proposal that have not been answered.}} From 0114c3dc1fcb4dee8a9ed5df09e7e437b94169f3 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 27 Dec 2024 02:28:00 +0100 Subject: [PATCH 6/6] Specify the directory where config deps will be placed --- text/0004-configurational-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0004-configurational-dependencies.md b/text/0004-configurational-dependencies.md index e288265..323d03a 100644 --- a/text/0004-configurational-dependencies.md +++ b/text/0004-configurational-dependencies.md @@ -37,7 +37,7 @@ These new type of "configurational" dependencies will be npm packages with a lot * They will not have lifecycle scripts. * They will only be installable via exact versions. -These dependencies will be installed into a new directory (name to be decided), not into `node_modules`. +These dependencies will be installed into a new hidden directory inside `node_modules`: `node_modules/.pnpm-config`. ## Rationale and Alternatives