Skip to content

Commit

Permalink
test(build): address pnpm issues (#2799)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Nov 7, 2023
1 parent fc7972d commit 4381988
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .changeset/quick-papayas-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
26 changes: 26 additions & 0 deletions incubator/build/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as fs from "node:fs";

const needsTransforming = [
"find-up",
"locate-path",
"p-limit",
"p-locate",
"path-exists",
"yocto-queue",
].join("|");

function isPnpmMode() {
const url = new URL("../../.yarnrc.yml", import.meta.url);
const yarnConfig = fs.readFileSync(url, { encoding: "utf-8" });
return yarnConfig.includes("nodeLinker: pnpm");
}

export default {
preset: "@rnx-kit/jest-preset/private",
resolver: "@rnx-kit/jest-preset/typescript-esm-resolver.cjs",
transformIgnorePatterns: [
isPnpmMode()
? `/node_modules/.store/(?!(${needsTransforming})-npm)`
: `/node_modules/(?!(${needsTransforming})/)`,
],
};
9 changes: 2 additions & 7 deletions incubator/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"@rnx-kit/eslint-config": "*",
"@rnx-kit/jest-preset": "*",
"@rnx-kit/scripts": "*",
"@types/jest": "^29.2.1",
"@types/node": "^18.0.0",
"@types/qrcode": "^1.4.2",
"@types/yargs": "^16.0.0",
"eslint": "^8.0.0",
Expand All @@ -66,12 +68,5 @@
"engines": {
"node": ">=18.12"
},
"jest": {
"preset": "@rnx-kit/jest-preset/private",
"resolver": "@rnx-kit/jest-preset/typescript-esm-resolver.cjs",
"transformIgnorePatterns": [
"/node_modules/(?!(find-up|locate-path|p-limit|p-locate|path-exists|yocto-queue)/)"
]
},
"experimental": true
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@changesets/cli": "^2.22.0",
"@types/jest": "^29.2.1",
"@types/node": "^18.0.0",
"eslint": "^8.0.0",
"jest-cli": "^29.2.1",
"metro": "^0.76.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/tools-workspaces/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ function dirnameAll(paths: string[]): string[] {
}

function makeFindSentinel<R>(finder: (name: string[]) => R) {
const isTesting = Boolean(process.env.JEST_WORKER_ID);
let result: R | undefined;
return () => {
if (process.env.JEST_WORKER_ID || !result) {
if (isTesting || !result) {
result = finder(WORKSPACE_ROOT_SENTINELS);
}
return result;
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3463,6 +3463,8 @@ __metadata:
"@rnx-kit/eslint-config": "*"
"@rnx-kit/jest-preset": "*"
"@rnx-kit/scripts": "*"
"@types/jest": ^29.2.1
"@types/node": ^18.0.0
"@types/qrcode": ^1.4.2
"@types/yargs": ^16.0.0
env-paths: ^3.0.0
Expand Down Expand Up @@ -12601,6 +12603,8 @@ __metadata:
"@babel/core": ^7.0.0
"@babel/preset-env": ^7.0.0
"@changesets/cli": ^2.22.0
"@types/jest": ^29.2.1
"@types/node": ^18.0.0
eslint: ^8.0.0
jest-cli: ^29.2.1
metro: ^0.76.5
Expand Down

0 comments on commit 4381988

Please sign in to comment.