install packages and get autocompletion on Monaco editor react


I want to give my users the ability to install npm packages in the browser and get autocompletion on the monaco editor for the installed packages, I have searched a lot and this what I came up with for now:

const { data: cryptoTypeDefs } = await axios.get(
        `https://unpkg.com/@types/node/crypto.d.ts`
      );
  monaco?.languages.typescript.typescriptDefaults.addExtraLib(
        cryptoTypeDefs,
        "crypto.d.ts"
      );

but this way is very tedious and I want a dynamic way to do this for installed packages,
here as you see I just extracted the crypto module alone from @types/node package.

Source: React – Stack Overflow

October 23, 2021
Category : News
Tags: monaco-editor | reactjs | visual-studio-monaco

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.