suren-atoyan / monaco-loader

The utility to easy setup monaco-editor into your browser
MIT License
185 stars 37 forks source link

Add support for loading TypeScript Sandbox/additional scripts #22

Closed oliverdunk closed 1 year ago

oliverdunk commented 2 years ago

The TypeScript Sandbox is based on Monaco and is loaded very similarly, but with some extra scripts:

require.config({
  paths: {
    vs: 'https://typescript.azureedge.net/cdn/4.0.5/monaco/min/vs',
    // vs: 'https://unpkg.com/@typescript-deploys/monaco-editor@4.0.5/min/vs',
    sandbox: 'https://www.typescriptlang.org/js/sandbox',
  },
  // This is something you need for monaco to work
  ignoreDuplicateModules: ['vs/editor/editor.main'],
})

// Grab a copy of monaco, TypeScript and the sandbox
require(['vs/editor/editor.main', 'vs/language/typescript/tsWorker', 'sandbox/index'], (
  main,
  _tsWorker,
  sandboxFactory
) => {

If this library could add support for loading additional scripts and getting a handle on the result, that would be super useful.

I don't think I'll be able to do it right away (so please feel free to beat me!) but I may be able to take a look at this at some point if you'd be open to a PR.

suren-atoyan commented 2 years ago

I guess here is the equivalent of that example 🙂