Skip to content

Conversation

H4ad
Copy link
Contributor

@H4ad H4ad commented Apr 10, 2024

If we didn't load glob, we can save up to 6ms by lazy loading this module.

@wraithgar
Copy link
Member

Only 14 commands call setWorkspaces

$ grep -rc setWorkspaces lib/commands/|grep -v "0\$"
lib/commands//exec.js:1
lib/commands//owner.js:1
lib/commands//run-script.js:2
lib/commands//pack.js:1
lib/commands//query.js:1
lib/commands//version.js:3
lib/commands//init.js:1
lib/commands//publish.js:1
lib/commands//unpublish.js:1
lib/commands//dist-tag.js:1
lib/commands//view.js:1
lib/commands//sbom.js:1
lib/commands//pkg.js:1
lib/commands//diff.js:1

@wraithgar wraithgar merged commit 64bcf4c into npm:latest Apr 10, 2024
wraithgar pushed a commit to npm/package-json that referenced this pull request Apr 10, 2024
Since npm run didn't call those steps, we can save some `ms` by lazy
loading this dependency.

Before:


![image](https://github.com/npm/package-json/assets/12551007/b4654691-85c8-4431-ba60-f7188363a125)

After:


![image](https://github.com/npm/package-json/assets/12551007/f3b02669-2070-4171-aeda-90954c55f54d)

The entire load time didn't change, still `13ms` before & after, but if
we call `npm run` inside a project that didn't have workspaces, we will
save some `ms`, like this one:


![image](https://github.com/npm/package-json/assets/12551007/0fe98367-4967-40f2-8d71-2a1b8c4eda55)

But this will also require the PR npm/cli#7360
to be merged.
@github-actions github-actions bot mentioned this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants