Repository navigation
Port github extension to use esbuild - #298778
Conversation
Had to make same fixes as with microsoft#296355. We can't pull in const enums from a d.ts file like this
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
There was a problem hiding this comment.
Pull request overview
Ports the GitHub built-in extension to the shared esbuild pipeline and updates Git API typings imports to avoid esbuild issues with runtime usage of const enums declared in .d.ts files.
Changes:
- Switch GitHub extension packaging/output from
out/todist/and add an esbuild entry script. - Convert Git API imports to
import typefrom the.d.tsfile, and introduce a runtime constants shim for formerly-const enumvalues. - Extend the shared
esbuild-extension-common.mtsrunner to allow configuring output format.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| extensions/github/src/util.ts | Converts Git API import to type-only from .d.ts. |
| extensions/github/src/typings/git.constants.ts | Adds runtime constants shim for Git const enum values. |
| extensions/github/src/shareProviders.ts | Converts Git API import to type-only from .d.ts. |
| extensions/github/src/remoteSourcePublisher.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/src/pushErrorHandler.ts | Switches GitErrorCodes to runtime constants shim; other Git API imports become type-only. |
| extensions/github/src/publish.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/src/links.ts | Switches runtime RefType usage to constants shim; other imports type-only. |
| extensions/github/src/historyItemDetailsProvider.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/src/extension.ts | Converts Git extension API imports to type-only from .d.ts. |
| extensions/github/src/credentialProvider.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/src/commands.ts | Switches runtime RefType usage to constants shim; other imports type-only. |
| extensions/github/src/canonicalUriProvider.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/src/branchProtection.ts | Converts Git API imports to type-only from .d.ts. |
| extensions/github/package.json | Points main to dist/extension.js (and removes "type": "module"). |
| extensions/github/esbuild.mts | Adds GitHub extension esbuild entry script (currently emitting ESM). |
| extensions/github/.vscodeignore | Ignores esbuild scripts instead of the old webpack config. |
| extensions/esbuild-extension-common.mts | Adds optional format to control CJS vs ESM output. |
Comments suppressed due to low confidence (2)
extensions/github/src/typings/git.constants.ts:66
GitErrorCodeshere contains many members that are not present insrc/typings/git.d.ts(e.g.BadRevision,NotASafeGitRepository,ForcePushWithLeaseRejected, etc.). Either updategit.d.tsto the newer API (matching these keys) or reduce this object to the keys declared in the local typings so the shim and types stay consistent.
export const GitErrorCodes = Object.freeze({
BadConfigFile: 'BadConfigFile',
BadRevision: 'BadRevision',
AuthenticationFailed: 'AuthenticationFailed',
NoUserNameConfigured: 'NoUserNameConfigured',
NoUserEmailConfigured: 'NoUserEmailConfigured',
NoRemoteRepositorySpecified: 'NoRemoteRepositorySpecified',
NotAGitRepository: 'NotAGitRepository',
NotASafeGitRepository: 'NotASafeGitRepository',
NotAtRepositoryRoot: 'NotAtRepositoryRoot',
Conflict: 'Conflict',
StashConflict: 'StashConflict',
UnmergedChanges: 'UnmergedChanges',
PushRejected: 'PushRejected',
ForcePushWithLeaseRejected: 'ForcePushWithLeaseRejected',
ForcePushWithLeaseIfIncludesRejected: 'ForcePushWithLeaseIfIncludesRejected',
RemoteConnectionError: 'RemoteConnectionError',
DirtyWorkTree: 'DirtyWorkTree',
extensions/github/esbuild.mts:16
esbuild.mtsis producing an ESM bundle (format: 'esm'), butpackage.jsonno longer declares"type": "module". With a.jsmain entrypoint this will typically be treated as CommonJS by Node/extension host and fail to load. Either switch the build output back tocjs(default inesbuild-extension-common.mts) or restore"type": "module"/ use.mjsso the runtime matches the bundle format.
| export type ForcePushMode = git.ForcePushMode; | ||
| export type RefType = git.RefType; | ||
| export type Status = git.Status; | ||
| export type GitErrorCodes = git.GitErrorCodes; | ||
|
|
||
| export const ForcePushMode = Object.freeze({ | ||
| Force: 0, | ||
| ForceWithLease: 1, | ||
| ForceWithLeaseIfIncludes: 2, | ||
| }) satisfies typeof git.ForcePushMode; |
There was a problem hiding this comment.
ForcePushMode in this constants shim includes ForceWithLeaseIfIncludes, but src/typings/git.d.ts currently declares ForcePushMode with only Force and ForceWithLease. This makes the shim drift from the local API typings (and will fail the satisfies typeof git.ForcePushMode check / misrepresent the API). Update git.d.ts to match the intended API surface, or trim the constants object to the members declared there.
This issue also appears on line 49 of the same file.
Had to make same fixes as with #296355. We can't pull in const enums from a d.ts file like this