Skip to content

Allow Extensions to use native modules shipped with vscode #84439

@go2sh

Description

@go2sh

It would be nice to use the node-pty module shipped with vscode in an extension. Currently, I'am doing the following:

//@ts-ignore
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
const moduleName = path.join(vscode.env.appRoot, "node_modules.asar", "node-pty");
const spawn: typeof import('node-pty').spawn = requireFunc(moduleName).spawn;

It should be possible to create a require interceptor injecting the parrents node-pty object into the extension.

This is especially nice as there is no general way of loading platform dependent code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    *dev-questionVS Code Extension Development Question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions