To avoid importing all features and languages, you can manually import specific ESM modules and the editor API. This is useful for optimizing your bundle.
- Create a custom entry point (e.g.,
customMonaco.ts):
import 'monaco-editor/esm/vs/editor/editor.all.js';
import 'monaco-editor/esm/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.js';
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
export { monaco };
- Use the custom entry point in your application:
import { monaco } from './customMonaco.ts';
monaco.editor.create(document.getElementById('container'), {
value: 'console.log("Hello, world")',
language: 'javascript',
});