![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
vite-plugin-monaco-editor
Advanced tools
A plugin to simplify loading the Monaco Editor with vite.
node_modules/.monaco
directory, via the server.middlewares
proxy http server for the bundle worker.// make sure you have it installed monaco-editor.
yarn add vite-plugin-monaco-editor -D
// or
npm install --save-dev vite-plugin-monaco-editor
vite.config.ts
:import { defineConfig } from 'vite';
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
export default defineConfig({
plugins: [monacoEditorPlugin()],
});
index.ts
:import * as monaco from 'monaco-editor';
monaco.editor.create(document.getElementById('container'), {
value: 'console.log("Hello, world")',
language: 'javascript',
});
The import * as monaco from 'monaco-editor'
is import all features and languages of the Monaco Editor. Assume you only need part of the features and languages:
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 };
The Complete list of imports: customMonaco.ts
index.ts
import { monaco } from './customMonaco.ts';
monaco.editor.create(document.getElementById('container'), {
value: 'console.log("Hello, world")',
language: 'javascript',
});
languageWorkers
(string[]
) - include only a subset of the languageWorkers supported.
customWorkers
(IWorkerDefinition[]
) - include your custom worker.
[{label: "graphql", entry: "monaco-graphql/esm/graphql.worker"}]
, The entry
is relative path in the node_modules Or you can set absolute path.publicPath
(string
) - custom public path for worker scripts, overrides the public path from which files generated by this plugin will be served. Or you can set CDN e.g https://unpkg.com/vite-plugin-monaco-editor@1.0.5/cdn
monacoeditorwork
globalAPI
(boolean
) - specifies whether the editor API should be exposed through a global monaco
object or not. This option is applicable to 0.22.0
and newer version of monaco-editor
. Since 0.22.0
, the ESM version of the monaco editor does no longer define a global monaco
object unless global.MonacoEnvironment = { globalAPI: true }
is set (change log).
false
.customDistPath
((root: string, buildOutDir: string, base: string) => string
) - Custom callback returns the worker path
forceBuildCDN
(boolean
) - If you use CDN, the build is skipped by default. Set to true if you want to generate woker
false
Some languages share the same web worker. If one of the following languages is included, you must also include the language responsible for instantiating their shared worker:
Language | Instantiator |
---|---|
javascript | typescript |
handlebars | html |
scss, less | css |
FAQs
A vite plugin for the Monaco Editor
We found that vite-plugin-monaco-editor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.