Skip to content

Commit 799cdd7

Browse files
committed
update readme
1 parent a19dd88 commit 799cdd7

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# monaco-editor-esm
2-
Real ESM version of vscode monaco editor
1+
# monaco-editor-esm
2+
3+
## Real ESM version of Monaco Editor
4+
5+
This package provides a true ESM (EcmaScript Module) build of the [Monaco Editor](https://github.com/microsoft/monaco-editor), suitable for modern build tools and direct browser usage. All JavaScript modules are available in the `/esm` directory, and all required CSS files are in `/min`.
6+
7+
### Why ESM?
8+
- Native ESM modules allow for better tree-shaking, direct browser imports, and compatibility with modern bundlers (Webpack, Rollup, Vite, etc.).
9+
- The official Monaco Editor package is not fully ESM and includes AMD/CommonJS code and non-standard CSS imports.
10+
11+
### Usage
12+
13+
#### With a Bundler (Webpack, Rollup, Vite, etc.)
14+
1. Install the package:
15+
```sh
16+
npm install monaco-editor-esm
17+
```
18+
2. Import the editor in your code:
19+
```js
20+
import * as monaco from 'monaco-editor-esm/esm/vs/editor/editor.main.js';
21+
```
22+
3. Make sure to load the required CSS from `/min`:
23+
```js
24+
import 'monaco-editor-esm/min/vs/editor/editor.main.css';
25+
```
26+
Or include it in your HTML:
27+
```html
28+
<link rel="stylesheet" href="node_modules/monaco-editor-esm/min/vs/editor/editor.main.css">
29+
```
30+
31+
#### Directly in the Browser
32+
- You can import modules from `/esm` using `<script type="module">`, but **CSS imports in JS are not natively supported in browsers**. You must manually include the CSS in your HTML:
33+
```html
34+
<link rel="stylesheet" href="path/to/min/vs/editor/editor.main.css">
35+
<script type="module">
36+
import * as monaco from './esm/vs/editor/editor.main.js';
37+
// ...
38+
</script>
39+
```
40+
41+
### CSS Import Caveats
42+
- The ESM modules may contain `import './file.css'` statements, which are not yet supported natively in browsers or Node.js. Most bundlers can handle these imports with the appropriate loader/plugin.
43+
- If you use the modules directly in the browser, you must include the CSS manually as shown above.
44+
- For more background, see the [discussion on ESM and CSS loading](https://github.com/microsoft/monaco-editor/issues/886#issuecomment-4248483831).
45+
46+
### Limitations
47+
- Some features may require additional configuration for web workers. See Monaco Editor documentation for details.
48+
- The ESM build is not guaranteed to be 100% compatible with all Monaco Editor plugins or extensions.
49+
50+
### License
51+
MIT

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "monaco-editor-esm",
33
"version": "0.55.1",
4-
"description": "esm version of monaco editor",
4+
"description": "A real ESM (EcmaScript Module) build of the Monaco Editor, suitable for modern build tools and direct browser usage. This package provides the Monaco Editor as native JavaScript modules in the /esm directory, and all required CSS in /min.\n\nNote: Due to current browser and JavaScript limitations, CSS imports in ESM modules are not natively supported in all environments. You may need to handle CSS loading manually or with a bundler. See README for details.",
55
"keywords": [
66
"monaco",
77
"esm"

0 commit comments

Comments
 (0)