diff options
author | adisbladis <adisbladis@gmail.com> | 2024-03-08 15:14:37 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-08 15:14:37 +1300 |
commit | 434df3c94b413ea1bd2f7310c7b821356f9edaf4 (patch) | |
tree | a78f2d5c53a79401b4b3c222e080b5b6ffc51993 /doc/languages-frameworks | |
parent | 5acb0a17239a819be784ddb9a92bff170c657013 (diff) | |
parent | b6e4b8680935288d1b05e285639373cfd4baf814 (diff) |
Merge pull request #289231 from adisbladis/fetchnpmlock
importNpmLock: init
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r-- | doc/languages-frameworks/javascript.section.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 4dc207f79847..c148070ad244 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -233,6 +233,37 @@ sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= It returns a derivation with all `package-lock.json` dependencies downloaded into `$out/`, usable as an npm cache. +#### importNpmLock {#javascript-buildNpmPackage-importNpmLock} + +`importNpmLock` is a Nix function that requires the following optional arguments: + +- `npmRoot`: Path to package directory containing the source tree +- `package`: Parsed contents of `package.json` +- `packageLock`: Parsed contents of `package-lock.json` +- `pname`: Package name +- `version`: Package version + +It returns a derivation with a patched `package.json` & `package-lock.json` with all dependencies resolved to Nix store paths. + +This function is analogous to using `fetchNpmDeps`, but instead of specifying `hash` it uses metadata from `package.json` & `package-lock.json`. + +Note that `npmHooks.npmConfigHook` cannot be used with `importNpmLock`. You will instead need to use `importNpmLock.npmConfigHook`: + +```nix +{ buildNpmPackage, importNpmLock }: + +buildNpmPackage { + pname = "hello"; + version = "0.1.0"; + + npmDeps = importNpmLock { + npmRoot = ./.; + }; + + npmConfigHook = importNpmLock.npmConfigHook; +} +``` + ### corepack {#javascript-corepack} This package puts the corepack wrappers for pnpm and yarn in your PATH, and they will honor the `packageManager` setting in the `package.json`. |