vscode-shader icon indicating copy to clipboard operation
vscode-shader copied to clipboard

Action needed: update your import of the built-in ripgrep

Open connor4312 opened this issue 3 years ago • 1 comments

Hello from the VS Code team 👋

We're doing some housekeeping that involves renaming some of our internal packages. Namely, vscode-ripgrep will be renamed to @vscode/ripgrep, which affects its location in VS Code's node_modules folder. It looks like this extension depends on vscode-ripgrep in a way that will break when this rename happens.

We suggest either:

  1. Adding an extra check for the renamed binary path in your extension, or
  2. Updating your extension to import vscode-ripgrep and retrieve the binary path from there. We will alias the require statement, so that the renamed package is always resolved correctly, and vscode-ripgrep exports the binary path. For example:
function getCoreNodeModule(moduleName) {
    try {
        return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
    } catch (err) {
        try {
            return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);
        } catch (err) {
            return undefined;
        }
    }
}

const { rgPath } = getCoreNodeModule('vscode-ripgrep');
// then child_process.spawn(rgPath, [...

Note that if you're building your extension with Webpack, you will want to use __non_webpack_require__ instead of require, otherwise webpack will try to (incorrectly) resolve the request by itself.

connor4312 avatar Jan 12 '22 20:01 connor4312

Hey @connor4312 , I'm trying your suggestion but this doesn't work for me on macOS with VSCode 1.85.0

stef-levesque avatar Dec 10 '23 19:12 stef-levesque