Add support to pass libraries as a compressed file#176
Add support to pass libraries as a compressed file#176jpverdejo wants to merge 1 commit intomkslanc:mainfrom
Conversation
|
@jpverdejo Hi! I’m not sure I fully understand the context. For example, why isn’t something like this an option? Could you please clarify the requirements or provide a small, reproducible example? |
|
I understand this may be a niche solution, so no big deal if you think we should keep it in our fork. Your solution would work under these conditions:
However in our use case none or those are true:
On top of that we use our own sandboxed JS runtime to run the code written in the editor in a different environment (backend), so keeping those 2 environments in sync is a must To solve this issue we built a middleground/setup repo, where we'll configure all the packages we want, plus anything extra that we need (ie, patch a library, add extra declaration files for custom supported behavior, etc), and we need this to output "something" that's easy to use for both the backend JS runtime and the ACE editor By supporting passing the declaration files as a package to ace-linters we can just do it like: package.json editor.ts (And a similar solution for the backend) With this whenever we need to update the libraries and/or declarations, we can go to the setup repo, make the changes, and then just use the new version in the FE and BE Again, I understand if this is not something we want to support upstream, but wanted to contribute back what is a useful new feature for us |
|
@jpverdejo Thanks for such detailed answer! I need to think a bit whether to proceed with this or not |
I need to pass a decent amount of declaration files to the editor. These declaration files will be defined in a separate repo and published to NPM.
In our current implementation (react app bundled with rsbuild) the only option I had was defining each file independently, as the bundler doesn't allow dynamic imports (
files.forEach({ ...; require(filename); ...}))The solution we came up with is to compress all the files into a single zip and pass it to the web worker for it to decompress and add as a library
I thought it could be useful to somebody else and decided to open a PR.
I had a hard time coming up with a way to test it, and this is the best I could come up with, but it's not something I'd want to get merged. Because of that I'll open it as a draft PR to gather feedback before getting to a prod-ready solution