Skip to content

Commit 1d6901b

Browse files
committed
update tutorial
1 parent 799cdd7 commit 1d6901b

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

README.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# monaco-editor-esm
1+
# @node-projects/monaco-editor-esm
22

33
## Real ESM version of Monaco Editor
44

@@ -10,32 +10,24 @@ This package provides a true ESM (EcmaScript Module) build of the [Monaco Editor
1010

1111
### Usage
1212

13-
#### With a Bundler (Webpack, Rollup, Vite, etc.)
1413
1. Install the package:
1514
```sh
16-
npm install monaco-editor-esm
15+
npm install @node-projects/monaco-editor-esm
1716
```
1817
2. Import the editor in your code:
1918
```js
20-
import * as monaco from 'monaco-editor-esm/esm/vs/editor/editor.main.js';
19+
import * as monaco from '@node-projects/monaco-editor-esm/esm/vs/editor/editor.main.js';
2120
```
2221
3. Make sure to load the required CSS from `/min`:
2322
```js
24-
import 'monaco-editor-esm/min/vs/editor/editor.main.css';
23+
import editorStyle from '@node-projects/monaco-editor-esm/min/vs/editor/editor.main.css' with { type : 'css' };
24+
shadowRoot.adoptedStyleSheets.push(editorStyle);
25+
// or
26+
document.adoptedStyleSheets.push(editorStyle);
2527
```
2628
Or include it in your HTML:
2729
```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>
30+
<link rel="stylesheet" href="node_modules/@node-projects/monaco-editor-esm/min/vs/editor/editor.main.css">
3931
```
4032

4133
### CSS Import Caveats

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "monaco-editor-esm",
2+
"name": "@node-projects/monaco-editor-esm",
33
"version": "0.55.1",
44
"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": [
@@ -30,5 +30,17 @@
3030
"files": [
3131
"min/",
3232
"esm/"
33-
]
33+
],
34+
"exports": {
35+
".": {
36+
"import": "./esm/vs/editor/editor.main.min.js"
37+
},
38+
"./esm/vs/editor/editor.main.js": "./esm/vs/editor/editor.main.js",
39+
"./esm/vs/editor/editor.api.js": "./esm/vs/editor/editor.api.js",
40+
"./esm/vs/editor/editor.api2.js": "./esm/vs/editor/editor.api2.js",
41+
"./esm/vs/editor/editor.worker.js": "./esm/vs/editor/editor.worker.js",
42+
"./esm/vs/language/*": "./esm/vs/language/*",
43+
"./esm/vs/basic-languages/*": "./esm/vs/basic-languages/*",
44+
"./min/vs/editor/editor.main.css": "./min/vs/editor/editor.main.css"
45+
}
3446
}

0 commit comments

Comments
 (0)