Remove UMD support

It was already broken.

Also the npm ecosystem is moving towards ESM only. This package should be a
part of that.
This commit is contained in:
Remco Haszing 2021-07-17 13:21:17 +02:00
parent bb3d8bd941
commit 67e2accd3b
No known key found for this signature in database
GPG key ID: 40D9F5FE9155FD3C
6 changed files with 7 additions and 379 deletions

View file

@ -1,164 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link
rel="stylesheet"
data-name="vs/editor/editor.main"
href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
/>
</head>
<body>
<h2>Monaco Editor YAML test page</h2>
<code id="path"></code>
<div
id="container"
style="width: 800px; height: 600px; border: 1px solid grey;"
></div>
<style>
.x-highlight-range {
background-color: lightblue;
}
</style>
<script>
// Loading basic-languages to get the YAML language definition
var paths = {
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
'vs/language/yaml': '../lib/dev',
vs: '../node_modules/monaco-editor-core/dev/vs',
prettier: '../node_modules/prettier',
};
if (document.location.protocol === 'http:') {
// Add support for running local http server
let testIndex = document.location.pathname.indexOf('/test/');
if (testIndex !== -1) {
let prefix = document.location.pathname.substr(0, testIndex);
paths['vs/language/yaml'] = prefix + '/lib/dev';
}
}
var require = {
paths: paths,
};
</script>
<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
<script>
require([
'vs/basic-languages/monaco.contribution',
'vs/language/yaml/monaco.contribution',
'prettier/standalone',
'prettier/parser-yaml',
], function () {
const yaml = `p1: `;
const modelUri = monaco.Uri.parse('a://b/foo.json');
const editor = monaco.editor.create(
document.getElementById('container'),
{
language: 'yaml',
showFoldingControls: 'always',
model: monaco.editor.createModel(yaml, 'yaml', modelUri),
}
);
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
enableSchemaRequest: true,
hover: true,
completion: true,
validate: true,
format: true,
schemas: [
{
uri: 'http://myserver/foo-schema.json', // id of the first schema
fileMatch: [modelUri.toString()], // associate with our model
schema: {
type: 'object',
properties: {
p1: {
enum: ['v1', 'v2'],
},
p2: {
$ref: 'http://myserver/bar-schema.json', // reference the second schema
},
},
},
},
{
uri: 'http://myserver/bar-schema.json', // id of the first schema
schema: {
type: 'object',
properties: {
q1: {
enum: ['x1', 'x2'],
},
},
},
},
],
});
require(['vs/editor/contrib/quickOpen/quickOpen'], async (
quickOpen
) => {
const NEVER_CANCEL_TOKEN = {
isCancellationRequested: false,
onCancellationRequested: () => Event.NONE,
};
let oldDecorations = [];
async function _getSymbolForPosition(model, position) {
const symbols = await quickOpen.getDocumentSymbols(
model,
false,
NEVER_CANCEL_TOKEN
);
function _recur(symbol) {
let target = symbol;
if (symbol && symbol.children && symbol.children.length) {
target =
_recur(
symbol.children.find((child) =>
child.range.containsPosition(position)
)
) || symbol;
}
return target;
}
return _recur({ children: symbols });
}
editor.onDidChangeCursorSelection(async ({ selection }) => {
const model = editor.getModel();
const position = selection.getPosition();
const symbol = await _getSymbolForPosition(model, position);
console.log(`${symbol.name}: ${symbol.range}`);
if (symbol && symbol.range) {
const decoration = {
range: symbol.range,
options: {
isWholeLine: false,
className: 'x-highlight-range',
},
};
oldDecorations = editor.deltaDecorations(
oldDecorations,
decoration ? [decoration] : []
);
}
});
});
});
</script>
</body>
</html>

111
package-lock.json generated
View file

@ -19,13 +19,10 @@
"husky": "^5.2.0",
"lint-staged": "^10.5.4",
"monaco-editor": "^0.21.3",
"monaco-languages": "^2.1.1",
"monaco-plugin-helpers": "^1.0.3",
"prettier": "2.0.5",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"typescript": "^4.2.3",
"uglify-es": "^3.3.9",
"yaml-language-server": "^0.11.1"
}
},
@ -6905,13 +6902,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/monaco-languages": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-2.1.1.tgz",
"integrity": "sha512-VuiqdK1NAIVnXVDUWMQUwqmYsIaWVoi9N735QnwP0O5WZaihA9Spt3JTC1Tk8lBqk5ei/DB2394BWfONeZ+5BA==",
"dev": true,
"license": "MIT"
},
"node_modules/monaco-plugin-helpers": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz",
@ -8460,20 +8450,6 @@
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
"node_modules/requirejs": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
"integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
"dev": true,
"license": "MIT",
"bin": {
"r_js": "bin/r.js",
"r.js": "bin/r.js"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -10046,30 +10022,6 @@
"node": ">=4.2.0"
}
},
"node_modules/uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
"commander": "~2.13.0",
"source-map": "~0.6.1"
},
"bin": {
"uglifyjs": "bin/uglifyjs"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/uglify-es/node_modules/commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true,
"license": "MIT"
},
"node_modules/uglify-js": {
"version": "3.4.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",
@ -17499,12 +17451,6 @@
"integrity": "sha512-9N7wATLpi+googstvtm6IKg97vPQ77FDYEpkow5tLriM/VJ0DaTRyUP4UVzcoH7KlPDX+e/rE7/imcOUeGkT6g==",
"dev": true
},
"monaco-languages": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-2.1.1.tgz",
"integrity": "sha512-VuiqdK1NAIVnXVDUWMQUwqmYsIaWVoi9N735QnwP0O5WZaihA9Spt3JTC1Tk8lBqk5ei/DB2394BWfONeZ+5BA==",
"dev": true
},
"monaco-plugin-helpers": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz",
@ -17529,15 +17475,12 @@
"js-yaml": "^3.14.1",
"lint-staged": "^10.5.4",
"monaco-editor": "^0.21.3",
"monaco-languages": "^2.1.1",
"monaco-plugin-helpers": "^1.0.3",
"prettier": "2.0.5",
"react-webpack-example": "file:examples/react-webpack",
"react-webpack-worker-loader-example": "file:examples/react-webpack-worker-loader",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"typescript": "^4.2.3",
"uglify-es": "^3.3.9",
"yaml-ast-parser-custom-tags": "^0.0.43",
"yaml-language-server": "^0.11.1"
},
@ -23072,12 +23015,6 @@
"integrity": "sha512-9N7wATLpi+googstvtm6IKg97vPQ77FDYEpkow5tLriM/VJ0DaTRyUP4UVzcoH7KlPDX+e/rE7/imcOUeGkT6g==",
"dev": true
},
"monaco-languages": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-2.1.1.tgz",
"integrity": "sha512-VuiqdK1NAIVnXVDUWMQUwqmYsIaWVoi9N735QnwP0O5WZaihA9Spt3JTC1Tk8lBqk5ei/DB2394BWfONeZ+5BA==",
"dev": true
},
"monaco-plugin-helpers": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz",
@ -24364,12 +24301,6 @@
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
"requirejs": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
"integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -25669,24 +25600,6 @@
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"dev": true
},
"uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"requires": {
"commander": "~2.13.0",
"source-map": "~0.6.1"
},
"dependencies": {
"commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true
}
}
},
"uglify-js": {
"version": "3.4.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",
@ -28519,12 +28432,6 @@
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
"requirejs": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
"integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@ -29824,24 +29731,6 @@
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"dev": true
},
"uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"requires": {
"commander": "~2.13.0",
"source-map": "~0.6.1"
},
"dependencies": {
"commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true
}
}
},
"uglify-js": {
"version": "3.4.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",

View file

@ -4,12 +4,8 @@
"description": "YAML plugin for the Monaco Editor",
"scripts": {
"watch": "tsc -p ./src --watch",
"compile": "rimraf ./out && npm run compile:umd && npm run compile:esm",
"compile:umd": "tsc -p ./tsconfig.json",
"compile:esm": "tsc -p ./tsconfig.esm.json",
"bundle": "rimraf ./lib && npm run bundle:umd && npm run bundle:esm && mcopy ./src/monaco.d.ts ./lib/monaco.d.ts",
"bundle:umd": "node ./scripts/bundle-umd",
"bundle:esm": "node ./scripts/bundle-esm",
"compile": "rimraf ./out && tsc",
"bundle": "rimraf ./lib && node ./scripts/bundle-esm && mcopy ./src/monaco.d.ts ./lib/monaco.d.ts",
"build": "npm run compile && npm run bundle",
"prepare": "husky install && npm run build",
"lint": "prettier --check ."
@ -44,13 +40,10 @@
"husky": "^5.2.0",
"lint-staged": "^10.5.4",
"monaco-editor": "^0.21.3",
"monaco-languages": "^2.1.1",
"monaco-plugin-helpers": "^1.0.3",
"prettier": "2.0.5",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"typescript": "^4.2.3",
"uglify-es": "^3.3.9",
"yaml-language-server": "^0.11.1"
},
"prettier": {

View file

@ -1,77 +0,0 @@
const requirejs = require('requirejs');
const path = require('path');
const fs = require('fs');
const uglifyES = require('uglify-es');
const helpers = require('monaco-plugin-helpers');
const REPO_ROOT = path.resolve(__dirname, '..');
const sha1 = helpers.getGitVersion(REPO_ROOT);
const semver = require('../package.json').version;
const headerVersion = semver + '(' + sha1 + ')';
const BUNDLED_FILE_HEADER = [
'/*!-----------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * monaco-yaml version: ' + headerVersion,
' * Released under the MIT license',
' * https://github.com/kpdecker/monaco-yaml/blob/master/LICENSE.md',
' *-----------------------------------------------------------------------------*/',
'',
].join('\n');
bundleOne('monaco.contribution');
bundleOne('yamlMode');
bundleOne('yamlWorker');
function bundleOne(moduleId, exclude) {
requirejs.optimize(
{
baseUrl: 'out/amd/',
name: 'vs/language/yaml/' + moduleId,
out: 'lib/dev/' + moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/yaml': REPO_ROOT + '/out/amd',
'monaco-editor/esm/vs/editor/editor.api':
REPO_ROOT + '/out/amd/fillers/monaco-editor-amd',
},
optimize: 'none',
packages: [
{
name: 'vscode-languageserver-types',
location: path.join(
REPO_ROOT,
'node_modules/vscode-languageserver-types/lib/umd'
),
main: 'main',
},
{
name: 'yaml-language-server',
location: path.join(
REPO_ROOT,
'node_modules/yaml-language-server/out/server/src'
),
main: 'index',
},
],
},
function () {
const devFilePath = path.join(REPO_ROOT, 'lib/dev/' + moduleId + '.js');
const minFilePath = path.join(REPO_ROOT, 'lib/min/' + moduleId + '.js');
const fileContents = fs.readFileSync(devFilePath).toString();
console.log();
console.log(`Minifying ${devFilePath}...`);
const result = uglifyES.minify(fileContents, {
output: {
comments: 'some',
},
});
console.log(`Done.`);
try {
fs.mkdirSync(path.join(REPO_ROOT, 'lib/min'));
} catch (err) {}
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
}
);
}

View file

@ -1,16 +0,0 @@
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"module": "esnext",
"moduleResolution": "node",
"lib": ["dom", "es2016"],
"outDir": "./out/esm",
"sourceMap": true,
"target": "es6",
"types": []
},
"exclude": ["node_modules", "out", "lib", "test"]
}

View file

@ -1,11 +1,14 @@
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"module": "umd",
"downlevelIteration": true,
"module": "esnext",
"moduleResolution": "node",
"lib": ["dom", "es2016"],
"outDir": "./out/amd",
"outDir": "./out/esm",
"sourceMap": true,
"target": "es6",
"types": []
},