1

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 is 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.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Mossa Dababesh
  • 130
  • 1
  • 6
  • Why's that tedious? You are adding two lines per library! I consider that super easy. – Mike Lischke Oct 23 '21 at 17:22
  • I need the way to be more dynamic, like I need to install every package in a standard way, here I am pulling the crypto module alone from package @types/node, I have no clue how to pull every module type defs from the package – Mossa Dababesh Oct 24 '21 at 08:45
  • Then this is probably not a Monaco editor problem as such, but has to do with getting the individual typings. You may want to ask this as an own question. – Mike Lischke Oct 24 '21 at 09:28

0 Answers0