0.0.0 • Published 8 years ago

monaco-commonjs v0.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Monaco CommonJS

Disclaimer: everything in here is highly untested and very much a hack.

Instead of the annoying Monaco AMD loading, this module wraps the whole party in one CommonJS import without modifying any of the underlying source code.

This isn't published anywhere, but you can probably do the following to dev with it:

  • npm install
  • npm build
  • npm link
  • In your project: npm link react-monaco

Things to note:

  • Monaco is huge. The final dist here came out to 3.9MB. I would work to reduce this size, but then I'd probably have to touch the source code.
  • WebWorkers don't work. Let's not talk about it.
  • I couldn't figure out how to get around leaving monaco on the window. Maybe there is a clever way to inject it into the shimmed modules and keep it off the window, but I don't think I am clever enough to figure it out.
  • You'll need to serve up the extra disted SVG resource.
  • You'll need Python2 to build.

Why did you do this?

It felt like the best option for integrating the component. If we went ahead and used AMD for this stuff, but then built most of our code with CommonJS, that would be kind of wild. Why would we resolve some dependencies at build time and others at run time? That's just confusing.

Rewriting all of our code to be AMD also seemed really unfun. Things like Webpack and SystemJS are super hot and work around the CommonJS module style. I like those things more than I hate wrapping this module.

As an added bonus, using their module as AMD would not work with the current Workspace local setup and would lead to lots of CORS issues and rerouting to certain asset servers. You'd end up having to tweak their AMD loader anyway.

Why didn't you use Typescript?

I am lazy and had all the tooling set up for coffee. If you want the typings, you can probably require monaco-editor in as a dependency to your project and then pull in their typings as needed.

Why not modify the underlying source?

Cause then it would be really annoying to rebase if something new came along.

Why not build their Typescript source to CommonJS instead of shimming around AMD?

Tried it, didn't work nearly as well as I had hoped it would. Feel free to try it yourself.

Do you still support NLS and different languages?

Probably not.

Do you still support language extensions?

Probably, but if your extension requires a special worker that they would AMD load in, you'll have to add it yourself to the big module map. Otherwise, the hacked loader in here won't be able to find it.

I was loading CSS with their special loader and now it doesn't work!

Put it in your build yourself.