Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: Use yarn pnp #1586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

{
"eslint.nodePath": "node_modules",
"eslint.nodePath": ".yarn/sdks",
"eslint.runtime": "node",
"typescript.format.enable": true,
"typescript.validate.enable": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
Expand All @@ -23,5 +22,11 @@
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.enablePromptUseWorkspaceTsdk": true
}
20 changes: 20 additions & 0 deletions .yarn/sdks/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

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

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

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

// Defer to the real eslint/bin/eslint.js your application uses
module.exports = absRequire(`eslint/bin/eslint.js`);
6 changes: 6 additions & 0 deletions .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "eslint",
"version": "8.36.0-sdk",
"main": "./lib/api.js",
"type": "commonjs"
}
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
20 changes: 20 additions & 0 deletions .yarn/sdks/prettier/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

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

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/index.js
require(absPnpApiPath).setup();
}
}

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

const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

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

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

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

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

const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

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

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

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

// Defer to the real typescript/bin/tsserver your application uses
module.exports = absRequire(`typescript/bin/tsserver`);
6 changes: 6 additions & 0 deletions .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "typescript",
"version": "5.0.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
8 changes: 7 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

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
Expand All @@ -12,4 +13,9 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

packageExtensions:
"@ant-design/pro-layout@*":
dependencies:
"@ant-design/cssinjs": ^1.6.2

yarnPath: .yarn/releases/yarn-3.5.0.cjs
2 changes: 1 addition & 1 deletion packages/jest-preset-anansi/src/jest-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
'/node_modules/(?!@babel/runtime)',
'\\.pnp\\.[^\\/]+$',
],
resolver: require.resolve(`jest-pnp-resolver`),
resolver: require.resolve(`./resolver`),
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(m|c)?(j|t)sx?$',
coveragePathIgnorePatterns: ['node_modules'],
moduleFileExtensions: [
Expand Down
21 changes: 21 additions & 0 deletions packages/jest-preset-anansi/src/resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const pnpResolve = require('jest-pnp-resolver');
const path = require('path');

module.exports = (request: string, options: Record<string, any>) => {
if (
options.paths &&
Array.isArray(options.paths) &&
!['.', '/'].includes(request[0])
) {
for (const rootPath of options.paths) {
try {
const p = path.join(rootPath, request);
return require.resolve(p);
// eslint-disable-next-line no-empty
} catch (e) {}
}
}

return pnpResolve(request, options);
};
65 changes: 53 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ __metadata:
languageName: node
linkType: hard

"@ant-design/cssinjs@npm:1.7.1, @ant-design/cssinjs@npm:^1.5.6, @ant-design/cssinjs@npm:^1.7.1":
"@ant-design/cssinjs@npm:1.7.1, @ant-design/cssinjs@npm:^1.5.6, @ant-design/cssinjs@npm:^1.6.2, @ant-design/cssinjs@npm:^1.7.1":
version: 1.7.1
resolution: "@ant-design/cssinjs@npm:1.7.1"
dependencies:
Expand Down Expand Up @@ -6915,9 +6915,9 @@ __metadata:
linkType: hard

"@types/unist@npm:*, @types/unist@npm:^2.0.0":
version: 2.0.6
resolution: "@types/unist@npm:2.0.6"
checksum: 25cb860ff10dde48b54622d58b23e66214211a61c84c0f15f88d38b61aa1b53d4d46e42b557924a93178c501c166aa37e28d7f6d994aba13d24685326272d5db
version: 2.0.3
resolution: "@types/unist@npm:2.0.3"
checksum: 4427306b094561da28164e7e5250c4e6b382cb8eac40bf7e6bb0ff1e6e00c13e47aaf32e4a08fc8ba54602d07f79a39fb9ba304cc9dc886b1e3caf824649edbd
languageName: node
linkType: hard

Expand Down Expand Up @@ -9932,10 +9932,10 @@ __metadata:
dependencies:
dot-prop: ^5.2.0
graceful-fs: ^4.1.2
make-dir: ^3.0.0
unique-string: ^2.0.0
write-file-atomic: ^3.0.0
xdg-basedir: ^4.0.0
make-dir: ^1.0.0
unique-string: ^1.0.0
write-file-atomic: ^2.0.0
xdg-basedir: ^3.0.0
checksum: 60ef65d493b63f96e14b11ba7ec072fdbf3d40110a94fb7199d1c287761bdea5c5244e76b2596325f30c1b652213aa75de96ea20afd4a5f82065e61ea090988e
languageName: node
linkType: hard
Expand Down Expand Up @@ -10369,6 +10369,13 @@ __metadata:
languageName: node
linkType: hard

"crypto-random-string@npm:^1.0.0":
version: 1.0.0
resolution: "crypto-random-string@npm:1.0.0"
checksum: 6fc61a46c18547b49a93da24f4559c4a1c859f4ee730ecc9533c1ba89fa2a9e9d81f390c2789467afbbd0d1c55a6e96a71e4716b6cd3e77736ed5fced7a2df9a
languageName: node
linkType: hard

"crypto-random-string@npm:^2.0.0":
version: 2.0.0
resolution: "crypto-random-string@npm:2.0.0"
Expand Down Expand Up @@ -16924,6 +16931,15 @@ __metadata:
languageName: node
linkType: hard

"make-dir@npm:^1.0.0":
version: 1.3.0
resolution: "make-dir@npm:1.3.0"
dependencies:
pify: ^3.0.0
checksum: c564f6e7bb5ace1c02ad56b3a5f5e07d074af0c0b693c55c7b2c2b148882827c8c2afc7b57e43338a9f90c125b58d604e8cf3e6990a48bf949dfea8c79668c0b
languageName: node
linkType: hard

"make-dir@npm:^2.0.0, make-dir@npm:^2.1.0":
version: 2.1.0
resolution: "make-dir@npm:2.1.0"
Expand Down Expand Up @@ -17323,7 +17339,7 @@ __metadata:
languageName: node
linkType: hard

"memfs@npm:^3.1.2, memfs@npm:^3.4.1, memfs@npm:^3.4.13":
"memfs@npm:^3.1.2, memfs@npm:^3.4.1, memfs@npm:^3.4.13, memfs@npm:^3.4.3":
version: 3.4.13
resolution: "memfs@npm:3.4.13"
dependencies:
Expand Down Expand Up @@ -17788,7 +17804,16 @@ __metadata:
languageName: node
linkType: hard

"mime-types@npm:^2.1.12, mime-types@npm:^2.1.25, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:~2.1.17, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34":
"mime-types@npm:^2.1.12, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:~2.1.17, mime-types@npm:~2.1.24":
version: 2.1.32
resolution: "mime-types@npm:2.1.32"
dependencies:
mime-db: 1.52.0
checksum: 4487dfd2f872126d2c219ec731ad47a6169a438d5a4cce6ecef7594ce08eaefaf0d85429485a76ec005f095016c7ec488a24cf8bfcc0ea06de0355e23395746f
languageName: node
linkType: hard

"mime-types@npm:^2.1.25, mime-types@npm:~2.1.34":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
Expand Down Expand Up @@ -25147,6 +25172,15 @@ __metadata:
languageName: node
linkType: hard

"unique-string@npm:^1.0.0":
version: 1.0.0
resolution: "unique-string@npm:1.0.0"
dependencies:
crypto-random-string: ^1.0.0
checksum: 588f16bd4ec99b5130f237793d1a5694156adde20460366726573238e41e93b739b87987e863792aeb2392b26f8afb292490ace119c82ed12c46816c9c859f5f
languageName: node
linkType: hard

"unique-string@npm:^2.0.0":
version: 2.0.0
resolution: "unique-string@npm:2.0.0"
Expand Down Expand Up @@ -25778,7 +25812,7 @@ __metadata:
resolution: "webpack-dev-middleware@npm:5.3.1"
dependencies:
colorette: ^2.0.10
memfs: ^3.4.1
memfs: ^3.4.3
mime-types: ^2.1.31
range-parser: ^1.2.1
schema-utils: ^4.0.0
Expand Down Expand Up @@ -26186,7 +26220,7 @@ __metadata:
languageName: node
linkType: hard

"write-file-atomic@npm:^2.3.0, write-file-atomic@npm:^2.4.2":
"write-file-atomic@npm:^2.0.0, write-file-atomic@npm:^2.3.0, write-file-atomic@npm:^2.4.2":
version: 2.4.3
resolution: "write-file-atomic@npm:2.4.3"
dependencies:
Expand Down Expand Up @@ -26307,6 +26341,13 @@ __metadata:
languageName: node
linkType: hard

"xdg-basedir@npm:^3.0.0":
version: 3.0.0
resolution: "xdg-basedir@npm:3.0.0"
checksum: 60d613dcb09b1198c70cb442979825531c605ac7861a8a6131304207d2962020dbb23660ac7e1be324fb9e4111a51a6206d875148d3e98df47a7d1869fa1515f
languageName: node
linkType: hard

"xdg-basedir@npm:^4.0.0":
version: 4.0.0
resolution: "xdg-basedir@npm:4.0.0"
Expand Down