@monaco-editor/loader vs ace-builds vs react-monaco-editor
Code Editor Libraries Comparison
1 Year
@monaco-editor/loaderace-buildsreact-monaco-editorSimilar Packages:
What's Code Editor Libraries?

Code editor libraries are essential tools in web development that provide developers with the ability to integrate rich code editing features into their applications. These libraries often include syntax highlighting, code completion, and other advanced functionalities that enhance the user experience when writing code. The choice of a specific library can significantly impact the performance, usability, and extensibility of the code editor within a web application.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
@monaco-editor/loader1,103,37920086.1 kB142 months agoMIT
ace-builds894,6993,04054.1 MB018 days agoBSD-3-Clause
react-monaco-editor157,3593,96558.5 kB792 months agoMIT
Feature Comparison: @monaco-editor/loader vs ace-builds vs react-monaco-editor

Customization

  • @monaco-editor/loader:

    @monaco-editor/loader provides extensive customization options, allowing developers to modify themes, key bindings, and editor settings. It supports a wide range of languages and offers features like custom snippets and language services, making it highly adaptable to specific use cases.

  • ace-builds:

    ace-builds is known for its high level of customization. Developers can easily change the appearance and behavior of the editor through themes, modes, and custom commands. It also allows for the creation of custom modes for new languages, providing flexibility for specialized applications.

  • react-monaco-editor:

    react-monaco-editor allows for customization through props that can be passed directly to the Monaco Editor. This includes options for setting the editor's language, theme, and other configurations, making it easy to tailor the editor to fit the needs of a React application.

Performance

  • @monaco-editor/loader:

    @monaco-editor/loader is optimized for performance, especially in large codebases. It uses lazy loading to load only the necessary components and languages, which helps in reducing the initial load time and improving responsiveness during editing sessions.

  • ace-builds:

    ace-builds is lightweight and designed for high performance, even with large files. It efficiently handles syntax highlighting and code folding, ensuring that the editor remains responsive regardless of the complexity of the code being edited.

  • react-monaco-editor:

    react-monaco-editor inherits the performance characteristics of the Monaco Editor, which is optimized for handling large files and complex code structures. However, performance can vary based on how it is integrated into the React application, so careful management of state and rendering is essential.

Integration

  • @monaco-editor/loader:

    @monaco-editor/loader is designed for easy integration into various environments, including web applications and frameworks. It can be loaded asynchronously, which helps in optimizing the loading process and allows for dynamic language support.

  • ace-builds:

    ace-builds can be easily integrated into any web application, regardless of the framework being used. It requires minimal setup and can be embedded in existing HTML pages, making it a versatile choice for developers looking for a straightforward solution.

  • react-monaco-editor:

    react-monaco-editor is specifically tailored for React applications, providing a seamless way to integrate the Monaco Editor into React components. It manages the lifecycle of the editor, making it easy to use within the React paradigm.

Community and Support

  • @monaco-editor/loader:

    @monaco-editor/loader benefits from strong community support and extensive documentation, as it is part of the Visual Studio Code ecosystem. This means developers can find numerous resources, plugins, and community-contributed enhancements to extend its capabilities.

  • ace-builds:

    ace-builds has a dedicated community and a wealth of documentation available. While it may not be as widely adopted as Monaco, it has been around for a long time and has a stable user base that contributes to its ongoing development and support.

  • react-monaco-editor:

    react-monaco-editor has a growing community, especially among React developers. Its documentation is straightforward, and since it wraps the Monaco Editor, developers can also refer to the Monaco Editor's resources for additional support.

Learning Curve

  • @monaco-editor/loader:

    @monaco-editor/loader has a moderate learning curve, especially for developers unfamiliar with the Monaco Editor's API. However, once understood, it offers powerful features that can significantly enhance the coding experience.

  • ace-builds:

    ace-builds is relatively easy to learn, with a straightforward API and plenty of examples available. Developers can quickly get started with basic functionality and gradually explore more advanced features as needed.

  • react-monaco-editor:

    react-monaco-editor is easy to learn for developers already familiar with React. The integration is straightforward, and the component-based approach aligns well with React's paradigms, making it accessible for those who are new to code editors.

How to Choose: @monaco-editor/loader vs ace-builds vs react-monaco-editor
  • @monaco-editor/loader:

    Choose @monaco-editor/loader if you need a powerful, feature-rich code editor that supports multiple programming languages and offers advanced features like IntelliSense, code navigation, and debugging capabilities. It is particularly well-suited for applications that require a robust editing experience similar to Visual Studio Code.

  • ace-builds:

    Select ace-builds if you are looking for a lightweight, highly customizable code editor that is easy to integrate and supports a wide range of programming languages. Ace is known for its performance and flexibility, making it ideal for applications where speed and responsiveness are critical.

  • react-monaco-editor:

    Opt for react-monaco-editor if you are building a React application and want to leverage the capabilities of the Monaco Editor with a simple and straightforward integration. This package wraps the Monaco Editor in a React component, making it easier to manage state and props within a React ecosystem.

README for @monaco-editor/loader

@monaco-editor/loader · monthly downloads gitHub license npm version PRs welcome

The utility to easy setup monaco-editor into your browser

Synopsis

Configure and download monaco sources via its loader script, without needing to use webpack's (or any other module bundler's) configuration files

Motivation

It's been a while we are working with monaco editor. It's a great library and provides a powerful editor out of the box. Anyway, there were couple of problems related to the setup process. The main problem is the need to do some additional webpack configuration; that's not bad, but some quite useful tools, like CRA, aren't happy with that fact. The library @monaco-editor/react was being created to solve that problem - monaco editor wrapper for easy/one-line integration with React applications without needing to use webpack's (or any other module bundler's) configuration files. In that library, there was a utility that cares about the initialization process of monaco and overcomes the additional use of webpack configuration. That utility grows over time and now it's a separate library. Now, you can easily setup monaco into your browser, create your own editors, wrappers for React/Vue/Angular of whatever you want.

How it works

Monaco editor provides a script called loader, which itself provides tooling to download monaco sources. The library, under the hood, handles the configuration and loading part and gives us an easy-to-use API to interact with it

Documentation

Contents

Installation

npm install @monaco-editor/loader

or

yarn add @monaco-editor/loader

NOTE: For TypeScript type definitions, this package uses the monaco-editor package as a peer dependency. So, if you need types and don't already have the monaco-editor package installed, you will need to do so.

Introduction

The library exports types and the utility called loader, the last one has two methods

Usage

import loader from '@monaco-editor/loader';

loader.init().then(monaco => {
  monaco.editor.create(/* editor container, e.g. document.body */, {
    value: '// some comment',
    language: 'javascript',
  });
});

codesandbox

.config

By using the .config method we can configure the monaco loader. By default all sources come from CDN, you can change that behavior and load them from wherever you want

import loader from '@monaco-editor/loader';

// you can change the source of the monaco files
loader.config({ paths: { vs: '...' } });

// you can configure the locales
loader.config({ 'vs/nls': { availableLanguages: { '*': 'de' } } });

// or
loader.config({
  paths: {
    vs: '...',
  },
  'vs/nls' : {
    availableLanguages: {
      '*': 'de',
    },
  },
});

loader.init().then(monaco => { /* ... */ });

codesandbox

Configure the loader to load the monaco as an npm package

import loader from '@monaco-editor/loader';
import * as monaco from 'monaco-editor';

loader.config({ monaco });

loader.init().then(monacoInstance => { /* ... */ });

codesandbox

.init

The .init method handles the initialization process. It returns the monaco instance, wrapped with cancelable promise

import loader from '@monaco-editor/loader';

loader.init().then(monaco => {
  console.log('Here is the monaco instance', monaco);
});

codesandbox

import loader from '@monaco-editor/loader';

const cancelable = loader.init();

cancelable.then(monaco => {
  console.log('You will not see it, as it is canceled');
});

cancelable.cancel();

codesandbox

Notes

For electron users

In general it works fine with electron, but there are several cases that developers usually face to and sometimes it can be confusing. Here they are:

  1. Download process fails or if you use @monaco-editor/react You see loading screen stuck Usually, it's because your environment doesn't allow you to load external sources. By default, it loads monaco sources from CDN. You can see the default configuration. But sure you can change that behavior; the library is fully configurable. Read about it here. So, if you want to download it from your local files, you can do it like this:
import loader from '@monaco-editor/loader';

loader.config({ paths: { vs: '../path-to-monaco' } });

or, if you want to use it as an npm package, you can do it like this:

import loader from '@monaco-editor/loader';
import * as monaco from 'monaco-editor';

loader.config({ monaco });

loader.init().then(monacoInstance => { /* ... */ });
  1. Based on your electron environment it can be required to have an absolute URL The utility function taken from here can help you to achieve that. Let's imagine you have monaco-editor package installed and you want to load monaco from the node_modules rather than from CDN: in that case, you can write something like this:
function ensureFirstBackSlash(str) {
    return str.length > 0 && str.charAt(0) !== '/'
        ? '/' + str
        : str;
}

function uriFromPath(_path) {
    const pathName = path.resolve(_path).replace(/\\/g, '/');
    return encodeURI('file://' + ensureFirstBackSlash(pathName));
}

loader.config({
  paths: {
    vs: uriFromPath(
      path.join(__dirname, '../node_modules/monaco-editor/min/vs')
    )
  }
});

or, just use it as an npm package.

There were several issues about this topic that can be helpful too - 1 2 3 4

And if you use electron with monaco and have faced an issue different than the above-discribed ones, please let us know to make this section more helpful.

For Next.js users

The part of the source that should be pre-parsed is optimized for server-side rendering, so, in usual cases, it will work fine, but if you want to have access, for example, to monacoInstance you should be aware that it wants to access the document object, and it requires browser environment. Basically you just need to avoid running that part out of browser environment, there are several ways to do that. One of them is described here.

And if you use monaco with Next.js and have faced an issue different than the above-described one, please let us know to make this section more helpful.

License

MIT