mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-05-24 12:21:53 +00:00
fix monaco-editor-webpack-plugin
after library output change
This commit is contained in:
parent
326a253813
commit
0518312cac
4 changed files with 30 additions and 18 deletions
|
|
@ -1,10 +1,11 @@
|
||||||
# Monaco Editor Webpack Loader Plugin Example
|
# Monaco Editor Webpack Loader Plugin Example
|
||||||
|
|
||||||
This demo demonstrates how bundle `monaco-editor` and `monaco-yaml` with
|
This demo demonstrates how bundle `monaco-editor` and `monaco-yaml` with
|
||||||
[monaco-editor-webpack-plugin](https://github.com/microsoft/monaco-editor-webpack-plugin). The build
|
[monaco-editor-webpack-plugin](https://github.com/microsoft/monaco-editor/tree/main/webpack-plugin).
|
||||||
output is [esm library](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).
|
The build output is
|
||||||
Example is based on
|
[esm library](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). Example is
|
||||||
[link](https://github.com/microsoft/monaco-editor-samples/tree/main/browser-esm-webpack-monaco-plugin).
|
based on
|
||||||
|
[link](https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-webpack-monaco-plugin).
|
||||||
To start it, simply run:
|
To start it, simply run:
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
||||||
|
|
||||||
export { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
||||||
export { setDiagnosticsOptions } from 'monaco-yaml';
|
export { setDiagnosticsOptions } from 'monaco-yaml';
|
||||||
export default monaco;
|
export default monaco;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,29 @@ boolean: true
|
||||||
`;
|
`;
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
const monaco = await import('./main.js');
|
// Dynamic import is possible
|
||||||
|
const { default: monaco } = await import('./main.js');
|
||||||
|
|
||||||
|
// Define schema first
|
||||||
|
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
||||||
|
schemas: [
|
||||||
|
{
|
||||||
|
fileMatch: ['*'],
|
||||||
|
uri: 'my-schema.json',
|
||||||
|
schema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
number: {
|
||||||
|
description: 'number property',
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create editor
|
||||||
monaco.editor.create(document.querySelector('.editor'), {
|
monaco.editor.create(document.querySelector('.editor'), {
|
||||||
language: 'yaml',
|
language: 'yaml',
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,6 @@ export default {
|
||||||
outputModule: true,
|
outputModule: true,
|
||||||
},
|
},
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
// Yaml-ast-parser-custom-tags imports buffer. This can be omitted safely.
|
|
||||||
buffer: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
|
@ -38,13 +32,10 @@ export default {
|
||||||
customLanguages: [
|
customLanguages: [
|
||||||
{
|
{
|
||||||
label: 'yaml',
|
label: 'yaml',
|
||||||
entry: [
|
entry: ['monaco-yaml', 'vs/basic-languages/yaml/yaml.contribution'],
|
||||||
'monaco-yaml/lib/esm/monaco.contribution',
|
|
||||||
'vs/basic-languages/yaml/yaml.contribution',
|
|
||||||
],
|
|
||||||
worker: {
|
worker: {
|
||||||
id: 'monaco-yaml/lib/esm/yamlWorker',
|
id: 'monaco-yaml/yamlWorker',
|
||||||
entry: 'monaco-yaml/lib/esm/yaml.worker',
|
entry: 'monaco-yaml/yaml.worker',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue