Skip to content

Commit

Permalink
internal: Use yarn pnp
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Dec 28, 2024
1 parent 19d4669 commit 6e42c9a
Show file tree
Hide file tree
Showing 44 changed files with 488 additions and 136 deletions.
26 changes: 17 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ jobs:
npm pkg set 'workspaces[]'='examples/normalizr-relationships'
- restore_cache:
keys:
- v14-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }}
- v15-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }}
# fallback to using the latest cache if no exact match is found
- v14-dependencies-
- v15-dependencies-
- run:
name: yarn install
command: |
Expand All @@ -50,7 +50,7 @@ jobs:
paths:
- .yarn/cache
- .yarn/install-state.gz
key: v14-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }}
key: v15-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }}
- run: yarn run ci:build:types
- run: yarn run ci:build-test-lib
- persist_to_workspace:
Expand All @@ -62,10 +62,11 @@ jobs:
- project/examples/todo-app
- project/examples/github-app
- project/examples/normalizr-relationships
- project/node_modules
- project/packages
- project/scripts
- project/.yarnrc.yml
- project/.pnp.cjs
- project/.pnp.loader.mjs
- project/babel.config.js
- project/eslint.config.mjs
- project/jest.config.js
Expand Down Expand Up @@ -108,9 +109,10 @@ jobs:
command: |
if [ "<< parameters.react-version >>" == "^17.0.0" ]; then
yarn up react@<< parameters.react-version >> react-dom@<< parameters.react-version >> react-test-renderer@<< parameters.react-version >> @react-navigation/native@^6.0.0 @react-navigation/native-stack@^6.0.0 react-native-screens@^3.0.0 @testing-library/react@^12.0.0
yarn add --dev @testing-library/react-hooks
yarn workspace @data-client/test add --dev @testing-library/react-hooks
elif [ "<< parameters.react-version >>" == "^18" ]; then
yarn up react@<< parameters.react-version >> react-dom@<< parameters.react-version >> react-test-renderer@<< parameters.react-version >>
yarn workspace @data-client/test add --dev @testing-library/react-hooks
fi
- run:
name: Running Jest
Expand All @@ -127,7 +129,7 @@ jobs:
./codecov < ./lcov.info || true;
fi
else
yarn test:ci --maxWorkers=4 --selectProjects Node ReactDOM --testPathPattern packages/react packages/use-enhanced-reducer packages/img
yarn test:ci --maxWorkers=4 --selectProjects ReactDOM --testPathPattern packages/react packages/use-enhanced-reducer packages/img
fi
node_matrix:
Expand All @@ -143,10 +145,16 @@ jobs:
- run:
command: |
node --version
- run:
name: Install testing packages compatible with Node
command: |
yarn workspace @data-client/react add --dev @testing-library/react-hooks
yarn workspace @data-client/test add --dev @testing-library/react-hooks
yarn up react@18 react-dom@18 react-test-renderer@18
- run:
# we must use npm because yarn 4 isn't compatible with legacy node versions
command: |
ANANSI_JEST_TYPECHECK=false npm test --ci --maxWorkers=2 --selectProjects Node
ANANSI_JEST_TYPECHECK=false yarn test --ci --maxWorkers=2 --selectProjects Node
setup-esmodule-types:
executor: node
Expand Down Expand Up @@ -224,7 +232,7 @@ jobs:
- run:
command: |
cd examples/todo-app
npm run build:browser -- --env readable
yarn run build:browser --env readable
- run:
command: |
cd examples/normalizr-relationships
Expand All @@ -244,7 +252,7 @@ workflows:
- node_matrix:
matrix:
parameters:
node-version: ["14.21", "16.19", "18.18", "20.12.2"]
node-version: ["18.18", "20.12.2"]
requires:
- setup
- lint:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"arcanis.vscode-zipfs"
]
}
10 changes: 7 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"eslint.nodePath": "node_modules",
"eslint.nodePath": ".yarn/sdks",
"typescript.format.enable": true,
"typescript.validate.enable": true,
"[javascript]": {
Expand All @@ -18,7 +18,7 @@
"typescriptreact"
],
"eslint.format.enable": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
Expand Down Expand Up @@ -52,11 +52,15 @@
"**/versioned_docs": true,
"**/*_versioned_docs": true,
"**/v8.log": true,
"website/src/components/Playground/editor-types": true
"website/src/components/Playground/editor-types": true,
"**/.yarn": true,
"**/.pnp.*": true
},
"files.readonlyExclude": {
"**/.next": true,
"**/v8.log": true,
"website/src/components/Playground/editor-types": true
},
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.enablePromptUseWorkspaceTsdk": true
}
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/bin/eslint.js
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/bin/eslint.js your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/bin/eslint.js`));
27 changes: 27 additions & 0 deletions .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "eslint",
"version": "9.17.0-sdk",
"main": "./lib/api.js",
"type": "commonjs",
"bin": {
"eslint": "./bin/eslint.js"
},
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/api.js"
},
"./package.json": "./package.json",
"./use-at-your-own-risk": {
"types": "./lib/types/use-at-your-own-risk.d.ts",
"default": "./lib/unsupported-api.js"
},
"./rules": {
"types": "./lib/types/rules/index.d.ts"
},
"./universal": {
"types": "./lib/types/universal.d.ts",
"default": "./lib/universal.js"
}
}
}
5 changes: 5 additions & 0 deletions .yarn/sdks/integrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is automatically generated by @yarnpkg/sdks.
# Manual changes might be lost!

integrations:
- vscode
32 changes: 32 additions & 0 deletions .yarn/sdks/prettier/bin/prettier.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/bin/prettier.cjs
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`));
32 changes: 32 additions & 0 deletions .yarn/sdks/prettier/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real prettier your application uses
module.exports = wrapWithUserWrapper(absRequire(`prettier`));
7 changes: 7 additions & 0 deletions .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "prettier",
"version": "3.4.2-sdk",
"main": "./index.cjs",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
}
32 changes: 32 additions & 0 deletions .yarn/sdks/typescript/bin/tsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsc
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript/bin/tsc your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsc`));
32 changes: 32 additions & 0 deletions .yarn/sdks/typescript/bin/tsserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsserver
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real typescript/bin/tsserver your application uses
module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsserver`));
10 changes: 10 additions & 0 deletions .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "typescript",
"version": "5.7.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
}
}
3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ changesetIgnorePatterns:
- "**/__tests__/**"
- "**/*.md"

nodeLinker: node-modules
nodeLinker: pnp
pnpEnableEsmLoader: true

yarnPath: .yarn/releases/yarn-4.5.3.cjs

Expand Down
5 changes: 2 additions & 3 deletions __tests__/new.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { Temporal } from '@js-temporal/polyfill';
import React, { createContext, useContext } from 'react';

import {
schema,
Endpoint,
Expand All @@ -16,6 +13,8 @@ import {
Resource,
ResourceOptions,
} from '@data-client/rest';
import { Temporal } from '@js-temporal/polyfill';
import React, { createContext, useContext } from 'react';

/** Represents data with primary key being from 'id' field. */
export class IDEntity extends Entity {
Expand Down
2 changes: 1 addition & 1 deletion examples/coin-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/react": "*",
"@types/react-dom": "*",
"react-refresh": "*",
"typescript": "5.7",
"typescript": "5.7.2",
"webpack": "*",
"webpack-cli": "*"
},
Expand Down
Loading

0 comments on commit 6e42c9a

Please sign in to comment.