Skip to content

Commit d35b72e

Browse files
authored
Merge pull request #144 from domsew/fixExample
fix monaco-editor-webpack-plugin
2 parents 326a253 + 0518312 commit d35b72e

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

examples/monaco-editor-webpack-plugin/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Monaco Editor Webpack Loader Plugin Example
22

33
This demo demonstrates how bundle `monaco-editor` and `monaco-yaml` with
4-
[monaco-editor-webpack-plugin](https://github.com/microsoft/monaco-editor-webpack-plugin). The build
5-
output is [esm library](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).
6-
Example is based on
7-
[link](https://github.com/microsoft/monaco-editor-samples/tree/main/browser-esm-webpack-monaco-plugin).
4+
[monaco-editor-webpack-plugin](https://github.com/microsoft/monaco-editor/tree/main/webpack-plugin).
5+
The build output is
6+
[esm library](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). Example is
7+
based on
8+
[link](https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-webpack-monaco-plugin).
89
To start it, simply run:
910

1011
## Prerequisites
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
22

3-
export { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
43
export { setDiagnosticsOptions } from 'monaco-yaml';
54
export default monaco;

examples/monaco-editor-webpack-plugin/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@ boolean: true
44
`;
55

66
async function create() {
7-
const monaco = await import('./main.js');
7+
// Dynamic import is possible
8+
const { default: monaco } = await import('./main.js');
89

10+
// Define schema first
11+
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
12+
schemas: [
13+
{
14+
fileMatch: ['*'],
15+
uri: 'my-schema.json',
16+
schema: {
17+
type: 'object',
18+
properties: {
19+
number: {
20+
description: 'number property',
21+
type: 'number',
22+
},
23+
},
24+
},
25+
},
26+
],
27+
});
28+
29+
// Create editor
930
monaco.editor.create(document.querySelector('.editor'), {
1031
language: 'yaml',
1132
tabSize: 2,

examples/monaco-editor-webpack-plugin/webpack.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export default {
1414
outputModule: true,
1515
},
1616
devtool: 'source-map',
17-
resolve: {
18-
fallback: {
19-
// Yaml-ast-parser-custom-tags imports buffer. This can be omitted safely.
20-
buffer: false,
21-
},
22-
},
2317
module: {
2418
rules: [
2519
{
@@ -38,13 +32,10 @@ export default {
3832
customLanguages: [
3933
{
4034
label: 'yaml',
41-
entry: [
42-
'monaco-yaml/lib/esm/monaco.contribution',
43-
'vs/basic-languages/yaml/yaml.contribution',
44-
],
35+
entry: ['monaco-yaml', 'vs/basic-languages/yaml/yaml.contribution'],
4536
worker: {
46-
id: 'monaco-yaml/lib/esm/yamlWorker',
47-
entry: 'monaco-yaml/lib/esm/yaml.worker',
37+
id: 'monaco-yaml/yamlWorker',
38+
entry: 'monaco-yaml/yaml.worker',
4839
},
4940
},
5041
],

0 commit comments

Comments
 (0)