Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the git extension from webpack to esbuild. The main challenge was handling const enums defined in the git.d.ts API file, which esbuild cannot inline from declaration files. The solution creates a runtime constants file that provides Object.freeze equivalents of the const enums while maintaining type safety through TypeScript's satisfies operator.
Changes:
- Created
git.constants.tsto provide runtime equivalents of const enums (RefType, Status, ForcePushMode, GitErrorCodes) from git.d.ts - Updated all imports throughout the extension to use
import typefor types and import runtime values from git.constants - Replaced webpack configuration with esbuild configuration
- Added ESLint rule to enforce the import pattern and prevent future violations
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/git/src/api/git.constants.ts | New file providing runtime const enum equivalents using Object.freeze with satisfies for type safety |
| extensions/git/src/uri.ts | Updated imports: type-only import for Change, runtime import for Status |
| extensions/git/src/timelineProvider.ts | Updated to use type-only imports for AvatarQuery and AvatarQueryCommit |
| extensions/git/src/test/smoke.test.ts | Updated imports to separate types from runtime values |
| extensions/git/src/statusbar.ts | Updated imports: type-only for Branch and RemoteSourcePublisher, runtime for RefType |
| extensions/git/src/repositoryCache.ts | Updated to use type-only imports |
| extensions/git/src/repository.ts | Updated imports to separate types from runtime const enum values |
| extensions/git/src/remotePublisher.ts | Updated to use type-only import |
| extensions/git/src/quickDiffProvider.ts | Updated to import Status from git.constants for runtime usage |
| extensions/git/src/pushError.ts | Updated to use type-only import |
| extensions/git/src/postCommitCommands.ts | Updated to use type-only import |
| extensions/git/src/model.ts | Updated to use type-only imports |
| extensions/git/src/main.ts | Updated to use type-only import for GitExtension |
| extensions/git/src/historyProvider.ts | Updated imports to separate types from runtime RefType |
| extensions/git/src/historyItemDetailsProvider.ts | Updated to use type-only imports |
| extensions/git/src/git.ts | Updated imports and added explicit type annotations for status variables to work with runtime const enums |
| extensions/git/src/editSessionIdentityProvider.ts | Updated to import RefType from git.constants |
| extensions/git/src/decorationProvider.ts | Updated imports: type-only for Change, runtime for GitErrorCodes and Status |
| extensions/git/src/commands.ts | Updated imports, added default case to refId switch statement throwing error for unknown ref types |
| extensions/git/src/branchProtection.ts | Updated to use type-only imports |
| extensions/git/src/blame.ts | Updated to use type-only imports |
| extensions/git/src/autofetch.ts | Updated to import GitErrorCodes from git.constants |
| extensions/git/src/askpass.ts | Updated to use type-only imports |
| extensions/git/src/artifactProvider.ts | Updated imports: type-only for Ref and Worktree, runtime for RefType |
| extensions/git/src/api/extension.ts | Updated to use type-only imports |
| extensions/git/src/api/api1.ts | Updated imports to separate types from runtime const enum values |
| extensions/git/src/actionButton.ts | Updated imports: type-only for Branch, runtime for RefType and Status |
| extensions/git/extension.webpack.config.js | Removed webpack configuration file |
| extensions/git/esbuild.mts | New esbuild configuration with three entry points (main, askpass-main, git-editor-main) |
| extensions/git/.vscodeignore | Updated to ignore esbuild config instead of webpack config |
| eslint.config.js | Added rule to enforce import type pattern for git.d.ts and prevent non-type imports |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #296355
Required more changes as esbuild won't inline const enums from
d.tsfiles