{"id":22137,"library":"rollup-plugin-monaco-editor","title":"rollup-plugin-monaco-editor","description":"A Rollup plugin for bundling Monaco Editor with support for selective language and feature inclusion. Version 0.2.1 is current; it is compatible with monaco-editor versions 0.21.x to 0.31.x and Rollup 2.x. The plugin helps reduce bundle size by allowing users to specify only needed languages and editor features. It automatically generates a workers directory and handles CSS injection. Works best alongside @rollup/plugin-node-resolve, @rollup/plugin-commonjs, and a CSS plugin like rollup-plugin-postcss.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/chengcyber/rollup-plugin-monaco-editor","tags":["javascript","rollup","plugin","monaco-editor","typescript"],"install":[{"cmd":"npm install rollup-plugin-monaco-editor","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-monaco-editor","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-monaco-editor","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; the editor runtime to bundle","package":"monaco-editor","optional":false},{"reason":"peer dependency; requires Rollup 2.x or higher","package":"rollup","optional":false}],"imports":[{"note":"ESM module; default export is the plugin function.","wrong":"const monaco = require('rollup-plugin-monaco-editor')","symbol":"default","correct":"import monaco from 'rollup-plugin-monaco-editor'"},{"note":"TypeScript type for plugin options; use import type for isolated declarations.","wrong":"","symbol":"MonacoEditorPluginOptions","correct":"import type { MonacoEditorPluginOptions } from 'rollup-plugin-monaco-editor'"},{"note":"CommonJS users must use .default; the package exports ESM only but can be required with this pattern.","wrong":"const monaco = require('rollup-plugin-monaco-editor')","symbol":"monaco (in CommonJS)","correct":"const { default: monaco } = require('rollup-plugin-monaco-editor')"}],"quickstart":{"code":"// rollup.config.js\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport postcss from 'rollup-plugin-postcss';\nimport commonjs from '@rollup/plugin-commonjs';\nimport monaco from 'rollup-plugin-monaco-editor';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    format: 'es',\n    dir: 'dist',\n  },\n  plugins: [\n    postcss(),\n    monaco({\n      languages: ['json'],\n      // features: ['contextmenu']\n    }),\n    nodeResolve(),\n    commonjs(),\n  ],\n};","lang":"typescript","description":"Minimal Rollup config using rollup-plugin-monaco-editor with selective language inclusion and necessary companion plugins."},"warnings":[{"fix":"Order plugins as: monaco(), then nodeResolve(), then commonjs().","message":"Plugin must be placed before nodeResolve and commonjs in the plugins array.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Set esm: true/false explicitly if output format is not clear.","message":"If output.format is 'es' or 'esm' and esm option is not set, defaults to true; otherwise false.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Ensure the 'workers' subdirectory is copied to deployment or served statically.","message":"Workers are output to a 'workers' directory inside the output directory; make sure your server serves it.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Upgrade monaco-editor to at least 0.21.2.","message":"monaco-editor versions below 0.21.2 are not supported.","severity":"deprecated","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install monaco-editor","cause":"Missing peer dependency monaco-editor.","error":"Error: The 'monaco-editor' package must be installed as a dependency."},{"fix":"Reorder plugins so monaco() comes first.","cause":"Incorrect plugin order: monaco() placed after nodeResolve or commonjs.","error":"Error: 'must be called before nodeResolve and commonjs'"},{"fix":"Define output.dir in your rollup configuration.","cause":"Output 'dir' not set or missing in rollup config.","error":"TypeError: Cannot read properties of undefined (reading 'dir')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}