Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack Bundle for the VS Code extension is not including any node_modules dependencies #17

Open
dljsjr opened this issue May 7, 2024 · 2 comments

Comments

@dljsjr
Copy link

dljsjr commented May 7, 2024

This is the root cause of:

It's pretty easy to verify by inspecting the output from vsce's various commands.

@dljsjr dljsjr changed the title Webpack Bundle is not including any node_modules dependencies Webpack Bundle for the VS Code extension is not including any node_modules dependencies May 7, 2024
@dljsjr
Copy link
Author

dljsjr commented May 30, 2024

I forked the project to implement a fix, but the issues end up going much deeper.

  1. The vm2 library used for sandboxing JavaScript is quite old/out-of-date, no longer maintained, and considered a critical security vulnerability. This should probably be fixed upstream in Bruno itself, as well, given the sometimes sensitive nature of REST APIs.
  2. Most of the extension code assumes a node.js environment and/or Electron environment, and wasn't updated to work properly in a "browser" environment (which is what the Bruno Panel is, since it's a Webview).
  3. The original issue stands; the webpack config isn't configured to actually bundle dependencies from the package.json

I was able to solve the WebPack issues, but then ran in to some of the above issues.

The primary blocker in the fact that utilizing the VS Code API in a Webview isn't as straight forward as require-ing the module; you have to use a window function, and it can only be called once: https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension

The Webview for the Bruno Panel seems to work by trying to load the extension script as a regular JS script in the Webview's HTML for code reuse; this won't work for a variety of reasons. Firstly, the above-mentioned inability to access the vscode via a require. Secondly, it's not a node.js environment, so some stuff won't work without browser polyfills.

Related, Webpack 5 doesn't do automatic Node.js polyfills anymore, so I used this to get me as far as I could: https://webpack.js.org/configuration/resolve/#resolvefallback.

I'm not a JS developer, so I hit the limits of what I was able to pull off, and I also unfortunately forgot to push my changes up to a fork, and deleted my local clone. That was a very dumb move on my part. But I doubt my changes were the proper solution, anyway.

But point is, it seems that the extension needs a very deep refactor to fix these issues.

Extra Unsolicted Input

I'd advocate for changing the Webpack target from node to webworker if possible while fixing this; doing so will allow the extension to run in the browser version VS Code: https://code.visualstudio.com/api/working-with-extensions/bundling-extension#configure-webpack

@gilbertotcc
Copy link

I'm facing the error described in "Run request" and Bruno Panel not loading on VS Code 1.80. I hope somebody can help with the fixes because it would be helpful to use this extension within VSC.

Unfortunately I'm not expert in JavaScript programming and development of VSC extensions, otherwise I'd be happy to help.

Thanks @dljsjr for opening this issue and analysing what's going wrong.

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

No branches or pull requests

2 participants