Skip to content

Port github extension to use esbuild - #298778

Merged
Matt Bierner (mjbvz) merged 1 commit into
microsoft:mainfrom
mjbvz:dev/mjbvz/preliminary-canidae
Mar 2, 2026
Merged

Matt Bierner (mjbvz) merged 1 commit into
microsoft:mainfrom
mjbvz:dev/mjbvz/preliminary-canidae

Conversation

@mjbvz

Copy link
Copy Markdown
Contributor

Had to make same fixes as with #296355. We can't pull in const enums from a d.ts file like this

Had to make same fixes as with microsoft#296355. We can't pull in const enums from a d.ts file like this
Copilot AI review requested due to automatic review settings March 2, 2026 19:29
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • extensions/github/esbuild.mts
  • extensions/github/package.json
  • extensions/github/src/branchProtection.ts
  • extensions/github/src/canonicalUriProvider.ts
  • extensions/github/src/commands.ts
  • extensions/github/src/credentialProvider.ts
  • extensions/github/src/extension.ts
  • extensions/github/src/historyItemDetailsProvider.ts
  • extensions/github/src/links.ts
  • extensions/github/src/publish.ts
  • extensions/github/src/pushErrorHandler.ts
  • extensions/github/src/remoteSourcePublisher.ts
  • extensions/github/src/shareProviders.ts
  • extensions/github/src/typings/git.constants.ts
  • extensions/github/src/util.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/ to dist/ and add an esbuild entry script.
  • Convert Git API imports to import type from the .d.ts file, and introduce a runtime constants shim for formerly-const enum values.
  • Extend the shared esbuild-extension-common.mts runner 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

  • GitErrorCodes here contains many members that are not present in src/typings/git.d.ts (e.g. BadRevision, NotASafeGitRepository, ForcePushWithLeaseRejected, etc.). Either update git.d.ts to 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.mts is producing an ESM bundle (format: 'esm'), but package.json no longer declares "type": "module". With a .js main entrypoint this will typically be treated as CommonJS by Node/extension host and fail to load. Either switch the build output back to cjs (default in esbuild-extension-common.mts) or restore "type": "module" / use .mjs so the runtime matches the bundle format.

Comment on lines +8 to +17
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;

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@mjbvz
Matt Bierner (mjbvz) merged commit 2a1295c into microsoft:main Mar 2, 2026
22 checks passed
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants