-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to App reload speed (#4924)
### WHY are these changes introduced? Improves app reloading performance by caching or avoiding expensive operations. ### WHAT is this pull request doing? - `~200ms` Introduces a new `reloadApp` function that reuses data from the previous app instance. - `~200ms` Caches JSON schema validators to avoid recompilation on each validation. - `~100ms` Replaces git ignore checking with a more efficient alternative: the `ignore` package - `~1200ms` Improves handling of CLI version warning to only check once per command execution. - Reduces the file-watcher debouncing time to 200ms Before this PR, time to reload an app: `1500-2000ms` New time: `~15-20ms` ❗ Improvement: `100x` ### How to test your changes? 1. Run `dev` on an app with multiple extensions using the app management API. 2. Make changes to extension configuration files. 3. Verify that reloading is faster and the app continues to function correctly. ### Measuring impact - [x] n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix ### Checklist - [x] I've considered possible cross-platform impacts (Mac, Linux, Windows) - [x] I've considered possible documentation changes
- Loading branch information
Showing
15 changed files
with
166 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/app/src/cli/models/app/validation/multi-cli-warning.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {renderInfo} from '@shopify/cli-kit/node/ui' | ||
import {currentProcessIsGlobal} from '@shopify/cli-kit/node/is-global' | ||
import {globalCLIVersion, localCLIVersion} from '@shopify/cli-kit/node/version' | ||
import {jsonOutputEnabled} from '@shopify/cli-kit/node/environment' | ||
|
||
export async function showMultipleCLIWarningIfNeeded(directory: string, dependencies: {[key: string]: string}) { | ||
// Show the warning if: | ||
// - There is a global installation | ||
// - The project has a local CLI dependency | ||
// - The user didn't include the --json flag (to avoid showing the warning in scripts or CI/CD pipelines) | ||
|
||
const localVersion = dependencies['@shopify/cli'] && (await localCLIVersion(directory)) | ||
const globalVersion = await globalCLIVersion() | ||
|
||
if (localVersion && globalVersion && !jsonOutputEnabled()) { | ||
const currentInstallation = currentProcessIsGlobal() ? 'global installation' : 'local dependency' | ||
|
||
const warningContent = { | ||
headline: `Two Shopify CLI installations found – using ${currentInstallation}`, | ||
body: [ | ||
`A global installation (v${globalVersion}) and a local dependency (v${localVersion}) were detected. | ||
We recommend removing the @shopify/cli and @shopify/app dependencies from your package.json, unless you want to use different versions across multiple apps.`, | ||
], | ||
link: { | ||
label: 'See Shopify CLI documentation.', | ||
url: 'https://shopify.dev/docs/apps/build/cli-for-apps#switch-to-a-global-executable-or-local-dependency', | ||
}, | ||
} | ||
renderInfo(warningContent) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.