Skip to content

feat: declare acquireVsCodeApi on the global namespace - #62

Merged
dhuebner merged 1 commit into
TypeFox:mainfrom
RedGlow:bundled-acquire-vscode-api
Aug 26, 2026
Merged

feat: declare acquireVsCodeApi on the global namespace#62
dhuebner merged 1 commit into
TypeFox:mainfrom
RedGlow:bundled-acquire-vscode-api

Conversation

@RedGlow

@RedGlow RedGlow commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

When using the bundled version of the Messenger class in vscode-messenger-webview (the one built in the lib directory), the code that gets imported is something like this:

vscode-api.js:

Object.defineProperty(exports, "__esModule", { value: true });

(makes sense it's empty, since declare and interface don't produce javascript code)

messenger.js:

const vscode_api_1 = require("./vscode-api");
...
        this.vscode = vscode !== null && vscode !== void 0 ? vscode : (0, vscode_api_1.acquireVsCodeApi)();

(this is wrong: acquireVsCodeApi is defined on globalThis/window, not in the module!)

By moving the declaration of acquireVsCodeApi on the global namespace, the bundled code is now:

        this.vscode = vscode !== null && vscode !== void 0 ? vscode : acquireVsCodeApi();

(notice that there's no longer a reference to vscode_api_1 or ./vscode-api)

@dhuebner dhuebner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for contributing!

@dhuebner
dhuebner merged commit 850e9f3 into TypeFox:main Aug 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants