Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .changeset/wicked-houses-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
3 changes: 2 additions & 1 deletion incubator/yarn-plugin-dynamic-extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ exports.factory = (require) => {
return;
}

for (const [, { cwd, manifest }] of workspace.project.workspacesByCwd) {
const workspaces = workspace.project.workspacesByCwd.values();
for (const { cwd, manifest } of workspaces) {
const { name, version, raw } = manifest;
if (!name || !version) {
return;
Expand Down

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions incubator/yarn-plugin-external-workspaces/src/outputCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class OutputWorkspaces extends BaseCommand {
}

// write out the workspace info to the path as requested
await outputWorkspaces(
outputWorkspaces(
project,
npath.toPortablePath(outputPath),
this.checkOnly,
Expand Down Expand Up @@ -110,7 +110,7 @@ export function outputWorkspaces(

const workspaces: Record<string, string> = {};
// iterate the workspaces and record their names and paths
for (const [, workspace] of project.workspacesByIdent) {
for (const workspace of project.workspacesByIdent.values()) {
const { name: ident, private: isPrivate } = workspace.manifest;
if (ident && !isPrivate) {
const name = structUtils.stringifyIdent(ident);
Expand Down Expand Up @@ -197,8 +197,9 @@ function findDependencyChanges(
let foundChanges = false;

for (const name in newDeps) {
if (oldDeps[name]) {
if (oldDeps[name] !== newDeps[name]) {
const oldDep = oldDeps[name];
if (oldDep) {
if (oldDep !== newDeps[name]) {
changes[name] = "update";
foundChanges = true;
}
Expand All @@ -222,12 +223,7 @@ function findDependencyChanges(
* return a string record in sorted order by key
*/
function sortStringRecord<T>(toSort: Record<string, T>): Record<string, T> {
const sortedKeys = Object.keys(toSort).sort();
const target: Record<string, T> = {};
for (const key of sortedKeys) {
target[key] = toSort[key];
}
return target;
return Object.fromEntries(Object.entries(toSort).sort());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ factory: function (require) {

Note that this will use the lockfile as is, running the resolution step such that the data in the lockfile is trusted as-is. The command
is optimized for speed of install, assuming that previous standard install commands will have been run to ensure the lockfile is up to date and correct.
`,examples:[["Install a single package and its dependencies","$0 install-to workspace-package-name"],["Install multiple packages and their dependencies","$0 install-to @my-scope/workspace-package-1 @my-scope/workspace-package-2"]]})}async execute(){let{stdout:s}=this.context,t=await r.Configuration.find(this.context.cwd,this.context.plugins),{project:a,workspace:n}=await r.Project.find(t,this.context.cwd),i=await r.Cache.find(t),p=S(this.workspaceNames,a);if(p.size===0)throw new c.UsageError("No valid workspaces specified. Please provide one or more workspace names");if(!n)throw new f.WorkspaceRequiredError(a.cwd,this.context.cwd);return await a.restoreInstallState({restoreResolutions:!1}),(await r.StreamReport.start({configuration:t,stdout:s,includeLogs:!0,includeVersion:!0},async l=>{if(this.verbose)for(let g of p){let v=r.structUtils.prettyWorkspace(t,g);l.reportInfo(0,`Installing workspace ${v} (${g.cwd})`)}await D(a,t,p,{cache:i,report:l,immutable:!0},this.verbose)})).exitCode()}};function S(e,o){let s=new Set;for(let t of e){let a=o.tryWorkspaceByIdent(r.structUtils.parseIdent(t));if(!a)throw new c.UsageError(`Unable to find workspace for ${t}. Please ensure the workspace name is correct`);s.add(a);let n=a.getRecursiveWorkspaceDependencies();for(let i of n)s.add(i)}return s.add(o.topLevelWorkspace),s}function y(e,o){let s=e.project.storedResolutions.get(o);if(s){let t=!e.accessibleLocators.has(s);return e.storedResolutions.set(o,s),e.accessibleLocators.add(s),t?e.project.storedPackages.get(s):void 0}}function h(e,o){let s=y(e,o.descriptorHash);if(s)for(let[,t]of s.dependencies)h(e,t)}function H(e,o){let s={project:e,accessibleLocators:new Set,storedResolutions:new Map};for(let t of o){let n=y(s,t.anchoredDescriptor.descriptorHash)?.dependencies??t.manifest.dependencies;for(let[,i]of n)h(s,i);for(let[,i]of t.manifest.devDependencies)h(s,i)}e.accessibleLocators=s.accessibleLocators,e.storedResolutions=s.storedResolutions}async function D(e,o,s,t,a=!1){let{report:n}=t,i=await o.getPackageExtensions();for(let w of i.values())for(let[,l]of w)for(let k of l)k.status=r.PackageExtensionStatus.Inactive;await n.startTimerPromise("Resolution step",async()=>{await e.resolveEverything(t)});let p=e.accessibleLocators.size;H(e,s),a&&n.reportInfo(0,`Trimming from ${p} to ${e.accessibleLocators.size} locators`),await n.startTimerPromise("Fetch step",async()=>{await e.fetchEverything(t)}),await n.startTimerPromise("Link step",async()=>{await e.linkEverything(t)}),await e.persistInstallStateFile()}var W={commands:[d]},C=W;return I(E);})();
`,examples:[["Install a single package and its dependencies","$0 install-to workspace-package-name"],["Install multiple packages and their dependencies","$0 install-to @my-scope/workspace-package-1 @my-scope/workspace-package-2"]]})}async execute(){let{stdout:s}=this.context,t=await r.Configuration.find(this.context.cwd,this.context.plugins),{project:a,workspace:n}=await r.Project.find(t,this.context.cwd),i=await r.Cache.find(t),p=S(this.workspaceNames,a);if(p.size===0)throw new c.UsageError("No valid workspaces specified. Please provide one or more workspace names");if(!n)throw new f.WorkspaceRequiredError(a.cwd,this.context.cwd);return await a.restoreInstallState({restoreResolutions:!1}),(await r.StreamReport.start({configuration:t,stdout:s,includeLogs:!0,includeVersion:!0},async l=>{if(this.verbose)for(let g of p){let v=r.structUtils.prettyWorkspace(t,g);l.reportInfo(0,`Installing workspace ${v} (${g.cwd})`)}await D(a,t,p,{cache:i,report:l,immutable:!0},this.verbose)})).exitCode()}};function S(e,o){let s=new Set;for(let t of e){let a=o.tryWorkspaceByIdent(r.structUtils.parseIdent(t));if(!a)throw new c.UsageError(`Unable to find workspace for ${t}. Please ensure the workspace name is correct`);s.add(a);let n=a.getRecursiveWorkspaceDependencies();for(let i of n)s.add(i)}return s.add(o.topLevelWorkspace),s}function y(e,o){let s=e.project.storedResolutions.get(o);if(s){let t=!e.accessibleLocators.has(s);return e.storedResolutions.set(o,s),e.accessibleLocators.add(s),t?e.project.storedPackages.get(s):void 0}}function h(e,o){let s=y(e,o.descriptorHash);if(s)for(let t of s.dependencies.values())h(e,t)}function H(e,o){let s={project:e,accessibleLocators:new Set,storedResolutions:new Map};for(let t of o){let n=y(s,t.anchoredDescriptor.descriptorHash)?.dependencies??t.manifest.dependencies;for(let i of n.values())h(s,i);for(let i of t.manifest.devDependencies.values())h(s,i)}e.accessibleLocators=s.accessibleLocators,e.storedResolutions=s.storedResolutions}async function D(e,o,s,t,a=!1){let{report:n}=t,i=await o.getPackageExtensions();for(let w of i.values())for(let[,l]of w)for(let k of l)k.status=r.PackageExtensionStatus.Inactive;await n.startTimerPromise("Resolution step",async()=>{await e.resolveEverything(t)});let p=e.accessibleLocators.size;H(e,s),a&&n.reportInfo(0,`Trimming from ${p} to ${e.accessibleLocators.size} locators`),await n.startTimerPromise("Fetch step",async()=>{await e.fetchEverything(t)}),await n.startTimerPromise("Link step",async()=>{await e.linkEverything(t)}),await e.persistInstallStateFile()}var W={commands:[d]},C=W;return I(E);})();
return plugin;
}
};
Expand Down
6 changes: 3 additions & 3 deletions incubator/yarn-plugin-install-to/src/installTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function traverseDependencies(
// traverse and record the resolutions, only returns a value if this hasn't been seen
const pkg = getResolution(options, descriptor.descriptorHash);
if (pkg) {
for (const [, dependency] of pkg.dependencies) {
for (const dependency of pkg.dependencies.values()) {
traverseDependencies(options, dependency);
}
}
Expand All @@ -210,11 +210,11 @@ function pareDownProject(project: Project, workspaces: Set<Workspace>) {

// traverse dependencies, preferrring the package but falling back to the manifest
const dependencies = pkg?.dependencies ?? workspace.manifest.dependencies;
for (const [, descriptor] of dependencies) {
for (const descriptor of dependencies.values()) {
traverseDependencies(options, descriptor);
}
// for workspace packages also traverse devDependencies
for (const [, descriptor] of workspace.manifest.devDependencies) {
for (const descriptor of workspace.manifest.devDependencies.values()) {
traverseDependencies(options, descriptor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function traverseDependencies(

const moduleDependencies = dependencies.get(currentModule)?.dependencies;
if (moduleDependencies) {
for (const [, dependency] of moduleDependencies) {
for (const dependency of moduleDependencies.values()) {
if (dependency["__rnxCyclicDependenciesChecked"]) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-serializer-esbuild/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getModulePath(
// In Metro 0.72.0, the key changed from module name to a unique key in order
// to support features such as `require.context`. For more details, see
// https://github.com/facebook/metro/commit/52e1a00ffb124914a95e78e9f60df1bc2e2e7bf0.
for (const [, value] of parent.dependencies) {
for (const value of parent.dependencies.values()) {
if (value.data.name === moduleName) {
return value.absolutePath;
}
Expand Down
Loading