sidebar-markdown-notes
sidebar-markdown-notes copied to clipboard
Bundle files
Bundling with Webpack reduces extension size. Generally, it does so without breaking links and references throughout the code.
Our main Webview requires access to external modules. It can access local files, but methods of doing so are limited for security reasons. So far, complying with these restrictions and compiling with Webpack results in a broken build.
The current workaround is inelegant and involves copying .js files from the modules to the 'media/lib' folder, then reading them at runtime as shown below: https://github.com/AssisrMatheus/sidebar-markdown-notes/blob/31d2acdf78110f013d7fe3340ab3ff23ab5d841c/src/webviewProvider.ts#L95
See conversation below. Feel free to make corrections to this summary of the issue or ask for help if attempting a fix.
Hey thank you for the suggestion!
The main issue I'm having now is that I want to load the libraries files from node_modules instead of having to copy them to media/lib.
This would help a lot when importing the fonts for the add-latex-support branch. Since they are a lot and that could be automated.
@AssisrMatheus I think I understand. Not a web guy so bear with me! Help me at least characterize the issue properly. I'll update it as we go.
-
How relevant is CopyWebpackPlugin? If it misses the mark, explain why?
-
Ideally, what would your imports look like?
-
I know Webviews are fussy about URIs. How does that complicate/change the issue for us?
Not a web guy so bear with me!
No problem at all! I appreciate your help a lot.
-
I thought of using gulp to do that but that looks much better since we already have webpack. The reason I didn't use gulp at first is that felt that even thought it would work when bundling, it wouldn't work when developing the extension, and I didn't want to have a "hacky" way of copying those for each case. But after yesterday, I figured that when developing, the bundling process is called before running the vscode sandbox/emulator. So I think that might work great!
-
Which imports you mean? the ones in the node instance or in the webview instance?
-
Creating the URLs are easy enough, but we must make sure that the files exist when everything gets bundled and the .vsix is created, and that they still follow the correct path.
@AssisrMatheus its been great! I appreciate your answers, they're relatable and it helps me think. I have nothing real against either one, but I'd been feeling jaded about web-tech and maintainership for a long time. Its turned around and thats on you. For real, just happy to be here.
- I thought of using gulp to do that but that looks much better since we already have webpack...
I'll give it a shot! You reminded me of tasks, we can probably smooth out any hacky stuff the plugin introduces. We can have them preempt the webpack if we have to.
- Which imports you mean? the ones in the node instance or in the webview instance?
I think I just get spooked by html (lol) in the middle of code (gotem) because of how different the references can be, wondering about scoping, etc. I'm not really sure what I meant with that question now, don't worry about it. Sounds like I was spooked.
- Creating the URLs are easy enough, but we must make sure that the files exist when everything gets bundled and the .vsix is created, and that they still follow the correct path.
I'll keep that in mind! Thanks again.
I'd been feeling jaded about web-tech and maintainership for a long time. Its turned around and thats on you.
Oh maaan thank you for that! I also feel like this from time to time but then I get some bursts and it's when I create things like this 😆
I'll give it a shot! You reminded me of tasks, we can probably smooth out any hacky stuff the plugin introduces. We can have them preempt the webpack if we have to
Well, you don't need to use gulp specifically, since the webpack copy might already help with it. I was just explaining my thoughts a bit
I think I just get spooked by html (lol) in the middle of code (gotem) because of how different the references can be, wondering about scoping, etc. I'm not really sure what I meant with that question now, don't worry about it. Sounds like I was spooked.
No problem! That does get confusing from time to time. If the extension start getting bigger I'll try to find a way to read from a separate file maybe, if it's ever possible, the current setup is just a copy of the example they provide.
@AssisrMatheus yeah man, you're a great leader. I've always had a hard time acclimating to a lot of the habits and vibe I see all over GitHub. I'm stubborn and knew I'd be improvising on a lot, but wasn't tryna throw away what works out of ignorance.
After contributing here (for what, a week?) it was pretty clear what actually makes the difference as a maintainer. Also, I slowly had to face the fact that I liked working for you more than I did for me 😂. Good times.
I slowly had to face the fact that I liked working for you more than I did for me
Haha I can relate! When I began coding I really didn't like doing some random projects I wanted to do. But working for other's(and with others) helped me a lot and I think I learned much more, since I was getting feedback etc.