Merge pull request #76 from stephank/fix/pnp

Fix missing PnP linkers if node_modules exists
This commit is contained in:
Stéphan Kochen
2023-11-01 13:38:58 +01:00
committed by GitHub
2 changed files with 12 additions and 11 deletions
+2
View File
@@ -325,6 +325,8 @@ export default async (
ISOLATED: isolatedCode.join("\n"), ISOLATED: isolatedCode.join("\n"),
ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")), ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")),
NEED_ISOLATED_BUILD_SUPPRORT: isolatedIntegration.length > 0, NEED_ISOLATED_BUILD_SUPPRORT: isolatedIntegration.length > 0,
USES_PNP_LINKER: configuration.get("nodeLinker") === "pnp",
USES_NM_LINKER: configuration.get("nodeLinker") === "node-modules",
}); });
await xfs.writeFilePromise(nixExprPath, projectExpr); await xfs.writeFilePromise(nixExprPath, projectExpr);
+8 -9
View File
@@ -174,14 +174,13 @@ let
cp ${lockfile} "$out/libexec/$name/yarn.lock" cp ${lockfile} "$out/libexec/$name/yarn.lock"
cp --recursive .yarn "$out/libexec/$name" cp --recursive .yarn "$out/libexec/$name"
# If the project uses the node-modules linker, then # Copy the Yarn linker output into the package.
# include the node_modules folder in the package. #@@ IF USES_PNP_LINKER
if [ -d node_modules ]; then
cp --recursive node_modules "$out/libexec/$name"
else
# Otherwise, assume PnP. Copy the loader into the package.
cp .pnp.* "$out/libexec/$name" cp .pnp.* "$out/libexec/$name"
fi #@@ ENDIF USES_PNP_LINKER
#@@ IF USES_NM_LINKER
cp --recursive node_modules "$out/libexec/$name"
#@@ ENDIF USES_NM_LINKER
fi fi
cd "$out/libexec/$name" cd "$out/libexec/$name"
@@ -190,10 +189,10 @@ let
mkdir -p "$out/bin" mkdir -p "$out/bin"
yarn nixify install-bin $out/bin yarn nixify install-bin $out/bin
#@@ IF USES_NM_LINKER
# A package with node_modules doesn't need the cache # A package with node_modules doesn't need the cache
if [ -d node_modules ]; then
yarn cache clean yarn cache clean
fi #@@ ENDIF USES_NM_LINKER
runHook postInstall runHook postInstall
''; '';