Vite plugin to simplify loading the Monaco Editor with full ESM support. Current stable version is 2.0.2, with regular updates. It uses Vite's plugin hooks (configResolved, configureServer, transformIndexHtml) and esbuild to bundle workers in a proxy server, avoiding manual worker configuration. Key differentiators: native ESM loading, no global API dependency, support for custom workers and partial imports, and CDN-friendly publicPath option. Peer dependency on monaco-editor >=0.33.0. Ships TypeScript types.
npm install vite-plugin-monaco-editor-esmVerified import paths — ran on the pinned version, not inferred.
Vite config with the plugin, then create a Monaco Editor instance using all features.
Use the plugin's default handling; do not manually configure worker paths.
Remove globalAPI option; it defaults to false and is no longer needed.
For each language used, include its worker in languageWorkers (e.g., 'typescript').
Set publicPath to the served path, e.g., '/workers' or a CDN URL.
Set forceBuildCDN: true to bundle workers locally, or ensure CDN URL contains the workers.
Ensure plugin is correctly added to Vite plugins and publicPath matches the development server path (default 'monacoeditorwork').
Add import 'monaco-editor/esm/vs/editor/editor.all.js' before using the editor API.
Ensure monaco-editor version >=0.33.0 and use the correct ESM path.