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.