Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 34 additions & 0 deletions .yarn/versions/422a43ec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/cli": major
"@yarnpkg/core": major

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ The following changes only affect people writing Yarn plugins:

- `forgettableNames` & `forgettableBufferSize` have been removed (the only messages using them have been removed, making the forgettable logs implementation obsolete).

- `configuration.{packageExtensions,refreshPackageExtensions}` have been removed. Use `configuration.getPackageExtensions` instead.

- `configuration.normalizePackage` is now `async`.

### Installs

- Yarn now caches npm version metadata, leading to faster resolution steps and decreased network data usage.
Expand Down
22 changes: 12 additions & 10 deletions packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ export class Configuration {
public invalid: Map<string, string> = new Map();

public env: Record<string, string | undefined> = {};
public packageExtensions: Map<IdentHash, Array<[string, Array<PackageExtension>]>> = new Map();

public limits: Map<string, Limit> = new Map();

Expand Down Expand Up @@ -1337,8 +1336,6 @@ export class Configuration {
configuration.sources.set(`cacheFolder`, `<internal>`);
}

await configuration.refreshPackageExtensions();

return configuration;
}

Expand Down Expand Up @@ -1751,7 +1748,12 @@ export class Configuration {
return {os, cpu, libc};
}

async refreshPackageExtensions() {
private packageExtensions: Map<IdentHash, Array<[string, Array<PackageExtension>]>> | null = null;

async getPackageExtensions() {
if (this.packageExtensions !== null)
return this.packageExtensions;

this.packageExtensions = new Map();
const packageExtensions = this.packageExtensions;

Expand Down Expand Up @@ -1789,9 +1791,10 @@ export class Configuration {
return hooks.registerPackageExtensions;
}, this, registerPackageExtension);

for (const [descriptorString, extensionData] of this.get(`packageExtensions`)) {
for (const [descriptorString, extensionData] of this.get(`packageExtensions`))
registerPackageExtension(structUtils.parseDescriptor(descriptorString, true), miscUtils.convertMapsToIndexableObjects(extensionData), {userProvided: true});
}

return packageExtensions;
}

normalizeLocator(locator: Locator) {
Expand Down Expand Up @@ -1822,16 +1825,15 @@ export class Configuration {
}));
}

normalizePackage(original: Package) {
async normalizePackage(original: Package) {
const pkg = structUtils.copyPackage(original);

// We use the extensions to define additional dependencies that weren't
// properly listed in the original package definition

if (this.packageExtensions == null)
throw new Error(`refreshPackageExtensions has to be called before normalizing packages`);
const packageExtensions = await this.getPackageExtensions();

const extensionsPerIdent = this.packageExtensions.get(original.identHash);
const extensionsPerIdent = packageExtensions.get(original.identHash);
if (typeof extensionsPerIdent !== `undefined`) {
const version = original.version;

Expand Down
10 changes: 6 additions & 4 deletions packages/yarnpkg-core/sources/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class Project {
}

async preparePackage(originalPkg: Package, {resolver, resolveOptions}: {resolver: Resolver, resolveOptions: ResolveOptions}) {
const pkg = this.configuration.normalizePackage(originalPkg);
const pkg = await this.configuration.normalizePackage(originalPkg);

for (const [identHash, descriptor] of pkg.dependencies) {
const dependency = await this.configuration.reduceHook(hooks => {
Expand Down Expand Up @@ -1743,7 +1743,9 @@ export class Project {
if (hasPreErrors)
return;

for (const extensionsByIdent of this.configuration.packageExtensions.values())
const packageExtensions = await this.configuration.getPackageExtensions();

for (const extensionsByIdent of packageExtensions.values())
for (const [, extensionsByRange] of extensionsByIdent)
for (const extension of extensionsByRange)
extension.status = PackageExtensionStatus.Inactive;
Expand Down Expand Up @@ -1773,7 +1775,7 @@ export class Project {
}, async () => {
emitPeerDependencyWarnings(this, opts.report);

for (const [, extensionsPerRange] of this.configuration.packageExtensions) {
for (const [, extensionsPerRange] of packageExtensions) {
for (const [, extensions] of extensionsPerRange) {
for (const extension of extensions) {
if (extension.userProvided) {
Expand Down Expand Up @@ -1824,7 +1826,7 @@ export class Project {
}
});

for (const extensionsByIdent of this.configuration.packageExtensions.values())
for (const extensionsByIdent of packageExtensions.values())
for (const [, extensionsByRange] of extensionsByIdent)
for (const extension of extensionsByRange)
if (extension.userProvided && extension.status === PackageExtensionStatus.Active)
Expand Down