Skip to content

Commit

Permalink
fix(perf): only initialize workpaces when we are inside a workspace (#…
Browse files Browse the repository at this point in the history
…7360)

If we didn't load `glob`, we can save up to `6ms` by lazy loading this
module.
  • Loading branch information
H4ad authored Apr 10, 2024
1 parent 5a28a29 commit 64bcf4c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/base-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const { relative } = require('path')

const { definitions } = require('@npmcli/config/lib/definitions')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const { aliases: cmdAliases } = require('./utils/cmd-list')
const log = require('./utils/log-shim.js')

Expand Down Expand Up @@ -170,6 +169,7 @@ class BaseCommand {
const relativeFrom = prefixInsideCwd ? this.npm.localPrefix : process.cwd()

const filters = this.npm.config.get('workspace')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const ws = await getWorkspaces(filters, {
path: this.npm.localPrefix,
includeWorkspaceRoot,
Expand Down

0 comments on commit 64bcf4c

Please sign in to comment.