File tree Expand file tree Collapse file tree 4 files changed +30
-18
lines changed
examples/monaco-editor-webpack-plugin Expand file tree Collapse file tree 4 files changed +30
-18
lines changed Original file line number Diff line number Diff line change 11# Monaco Editor Webpack Loader Plugin Example
22
33This 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 ) .
89To start it, simply run:
910
1011## Prerequisites
Original file line number Diff line number Diff line change 11import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js' ;
22
3- export { editor } from 'monaco-editor/esm/vs/editor/editor.api.js' ;
43export { setDiagnosticsOptions } from 'monaco-yaml' ;
54export default monaco ;
Original file line number Diff line number Diff line change @@ -4,8 +4,29 @@ boolean: true
44` ;
55
66async 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 ,
Original file line number Diff line number Diff 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 ] ,
You can’t perform that action at this time.
0 commit comments