Skip to content

Commit 62d57ff

Browse files
authored
Migrates the "typescript" dependencies to a catalog (#6969)
## What's the problem this PR addresses? We don't currently use / dogfood the `catalog:` specifier. As a result we didn't notice that the compat plugin was incorrectly ordered; we want to apply it before performing the compat changes, but the current code was going the other way around. Fixes #6920 ## How did you fix it? - Make the monorepo use `catalog:` for the `typescript` package. - Fixes the local development setup to load plugins in the same order as the CLI bundle. - Reorders the plugins so that `catalog:` is resolved before the compatibility patches are applied. ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent 4e36aa5 commit 62d57ff

File tree

10 files changed

+57
-12
lines changed

10 files changed

+57
-12
lines changed

.yarn/versions/2c93d723.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
4+
declined:
5+
- "@yarnpkg/eslint-config"
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-init"
11+
- "@yarnpkg/plugin-interactive-tools"
12+
- "@yarnpkg/plugin-nm"
13+
- "@yarnpkg/plugin-npm-cli"
14+
- "@yarnpkg/plugin-pack"
15+
- "@yarnpkg/plugin-patch"
16+
- "@yarnpkg/plugin-pnp"
17+
- "@yarnpkg/plugin-pnpm"
18+
- "@yarnpkg/plugin-stage"
19+
- "@yarnpkg/plugin-typescript"
20+
- "@yarnpkg/plugin-version"
21+
- "@yarnpkg/plugin-workspace-tools"
22+
- "@yarnpkg/builder"
23+
- "@yarnpkg/core"
24+
- "@yarnpkg/doctor"

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ npmPublishAccess: public
2121

2222
npmPublishProvenance: true
2323

24+
catalog:
25+
typescript: "^5.9.2"
26+
2427
packageExtensions:
2528
markdown-it@*:
2629
dependencies:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"jest": "^29.2.1",
2525
"pirates": "^4.0.5",
2626
"tslib": "^2.4.0",
27-
"typescript": "^5.9.2"
27+
"typescript": "catalog:"
2828
},
2929
"resolutions": {
3030
"ink@^3.2.0": "patch:ink@npm%3A3.2.0#~/.yarn/patches/ink-npm-3.2.0-2f1df5b094.patch",

packages/docusaurus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"three": "^0.145.0",
6969
"tslib": "^2.4.0",
7070
"typedoc": "^0.25.7",
71-
"typescript": "^5.9.2",
71+
"typescript": "catalog:",
7272
"unist-util-visit-parents": "^6.0.1",
7373
"usehooks-ts": "^3.1.1",
7474
"webpack": "^5.88.2"

packages/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"eslint": "^9.20.1",
39-
"typescript": "^5.9.2"
39+
"typescript": "catalog:"
4040
},
4141
"stableVersion": "3.1.0"
4242
}

packages/yarnpkg-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"devDependencies": {
2222
"@types/semver": "^7.1.0",
2323
"@yarnpkg/monorepo": "workspace:^",
24-
"typescript": "^5.9.2"
24+
"typescript": "catalog:"
2525
},
2626
"scripts": {
2727
"postpack": "rm -rf lib",

packages/yarnpkg-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"bundles": {
8080
"standard": [
8181
"@yarnpkg/plugin-essentials",
82+
"@yarnpkg/plugin-catalog",
8283
"@yarnpkg/plugin-compat",
8384
"@yarnpkg/plugin-constraints",
8485
"@yarnpkg/plugin-dlx",
@@ -101,8 +102,7 @@
101102
"@yarnpkg/plugin-stage",
102103
"@yarnpkg/plugin-typescript",
103104
"@yarnpkg/plugin-version",
104-
"@yarnpkg/plugin-workspace-tools",
105-
"@yarnpkg/plugin-catalog"
105+
"@yarnpkg/plugin-workspace-tools"
106106
]
107107
}
108108
},

packages/yarnpkg-doctor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"micromatch": "^4.0.2",
1717
"p-limit": "^2.2.0",
1818
"tslib": "^2.4.0",
19-
"typescript": "^5.9.2"
19+
"typescript": "catalog:"
2020
},
2121
"devDependencies": {
2222
"@types/micromatch": "^4.0.1",

scripts/setup-local-plugins.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const DYNAMIC_LIBS_MODULE = require.resolve(`${PACKAGES}/yarnpkg-cli/sources/too
2121
require.cache[PLUGIN_CONFIGURATION_MODULE] = {exports: {getPluginConfiguration}};
2222

2323
function getPluginConfiguration() {
24+
const pluginOrder = require(`@yarnpkg/cli/package.json`)[`@yarnpkg/builder`].bundles.standard;
25+
2426
const folders = fs.readdirSync(PACKAGES);
2527

2628
const pluginFolders = folders.filter(folder => {
@@ -40,9 +42,25 @@ function getPluginConfiguration() {
4042
console.warn(`Disabled non-requirable plugin ${folder}: ${e.message}`);
4143
isRequirable = false;
4244
}
45+
4346
return isRequirable;
4447
});
4548

49+
pluginFolders.sort((a, b) => {
50+
const indexA = pluginOrder.indexOf(`@yarnpkg/${a}`);
51+
const indexB = pluginOrder.indexOf(`@yarnpkg/${b}`);
52+
53+
if (indexA === -1 && indexB === -1)
54+
return a.localeCompare(b);
55+
56+
if (indexA === -1)
57+
return 1;
58+
if (indexB === -1)
59+
return -1;
60+
61+
return indexA - indexB;
62+
});
63+
4664
// Note that we don't need to populate the `modules` field, because the
4765
// plugins will be loaded without being transformed by the builder wrapper,
4866
// so they will simply access their own set of dependencies.

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5811,7 +5811,7 @@ __metadata:
58115811
esbuild: "npm:esbuild-wasm@^0.23.0"
58125812
semver: "npm:^7.1.2"
58135813
tslib: "npm:^2.4.0"
5814-
typescript: "npm:^5.9.2"
5814+
typescript: "catalog:"
58155815
bin:
58165816
builder: ./sources/boot-cli-dev.js
58175817
languageName: unknown
@@ -5931,7 +5931,7 @@ __metadata:
59315931
micromatch: "npm:^4.0.2"
59325932
p-limit: "npm:^2.2.0"
59335933
tslib: "npm:^2.4.0"
5934-
typescript: "npm:^5.9.2"
5934+
typescript: "catalog:"
59355935
bin:
59365936
doctor: ./sources/boot-cli-dev.js
59375937
languageName: unknown
@@ -6019,7 +6019,7 @@ __metadata:
60196019
three: "npm:^0.145.0"
60206020
tslib: "npm:^2.4.0"
60216021
typedoc: "npm:^0.25.7"
6022-
typescript: "npm:^5.9.2"
6022+
typescript: "catalog:"
60236023
unified: "npm:^11.0.4"
60246024
unist-util-visit-parents: "npm:^6.0.1"
60256025
usehooks-ts: "npm:^3.1.1"
@@ -6040,7 +6040,7 @@ __metadata:
60406040
eslint-plugin-react: "npm:^7.37.4"
60416041
globals: "npm:^15.15.0"
60426042
tslib: "npm:^2.4.0"
6043-
typescript: "npm:^5.9.2"
6043+
typescript: "catalog:"
60446044
peerDependencies:
60456045
eslint: "*"
60466046
typescript: "*"
@@ -6125,7 +6125,7 @@ __metadata:
61256125
pirates: "npm:^4.0.5"
61266126
semver: "npm:^7.1.2"
61276127
tslib: "npm:^2.4.0"
6128-
typescript: "npm:^5.9.2"
6128+
typescript: "catalog:"
61296129
dependenciesMeta:
61306130
core-js:
61316131
built: false

0 commit comments

Comments
 (0)