Adopt `esbuild` for `monaco-typescript`
parent
c0d4493bd9
commit
dcbd8121d9
@ -1,120 +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 JSON test page</h2>
|
||||
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
|
||||
|
||||
<script>
|
||||
// Loading basic-languages to get the json language definition
|
||||
var paths = {
|
||||
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
||||
'vs/language/json': '../release/dev',
|
||||
vs: '../node_modules/monaco-editor-core/dev/vs'
|
||||
};
|
||||
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/json'] = prefix + '/release/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/json/monaco.contribution'
|
||||
], function () {
|
||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: [
|
||||
'{',
|
||||
' "type": "team",',
|
||||
' "test": {',
|
||||
' "testPage": "tools/testing/run-tests.htm",',
|
||||
' "enabled": true',
|
||||
' },',
|
||||
' "search": {',
|
||||
' "excludeFolders": [',
|
||||
' ".git",',
|
||||
' "node_modules",',
|
||||
' "tools/bin",',
|
||||
' "tools/counts",',
|
||||
' "tools/policheck",',
|
||||
' "tools/tfs_build_extensions",',
|
||||
' "tools/testing/jscoverage",',
|
||||
' "tools/testing/qunit",',
|
||||
' "tools/testing/chutzpah",',
|
||||
' "server.net"',
|
||||
' ]',
|
||||
' },',
|
||||
' "languages": {',
|
||||
' "vs.languages.typescript": {',
|
||||
' "validationSettings": [{',
|
||||
' "scope":"/",',
|
||||
' "noImplicitAny":true,',
|
||||
' "noLib":false,',
|
||||
' "extraLibs":[],',
|
||||
' "semanticValidation":true,',
|
||||
' "syntaxValidation":true,',
|
||||
' "codeGenTarget":"ES5",',
|
||||
' "moduleGenTarget":"",',
|
||||
' "lint": {',
|
||||
' "emptyBlocksWithoutComment": "warning",',
|
||||
' "curlyBracketsMustNotBeOmitted": "warning",',
|
||||
' "comparisonOperatorsNotStrict": "warning",',
|
||||
' "missingSemicolon": "warning",',
|
||||
' "unknownTypeOfResults": "warning",',
|
||||
' "semicolonsInsteadOfBlocks": "warning",',
|
||||
' "functionsInsideLoops": "warning",',
|
||||
' "functionsWithoutReturnType": "warning",',
|
||||
' "tripleSlashReferenceAlike": "warning",',
|
||||
' "unusedImports": "warning",',
|
||||
' "unusedVariables": "warning",',
|
||||
' "unusedFunctions": "warning",',
|
||||
' "unusedMembers": "warning"',
|
||||
' }',
|
||||
' },',
|
||||
' {',
|
||||
' "scope":"/client",',
|
||||
' "baseUrl":"/client",',
|
||||
' "moduleGenTarget":"amd"',
|
||||
' },',
|
||||
' {',
|
||||
' "scope":"/server",',
|
||||
' "moduleGenTarget":"commonjs"',
|
||||
' },',
|
||||
' {',
|
||||
' "scope":"/build",',
|
||||
' "moduleGenTarget":"commonjs"',
|
||||
' },',
|
||||
' {',
|
||||
' "scope":"/node_modules/nake",',
|
||||
' "moduleGenTarget":"commonjs"',
|
||||
' }],',
|
||||
' "allowMultipleWorkers": true',
|
||||
' }',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n'),
|
||||
language: 'json'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const { copyFile, removeDir, tsc, dts, buildESM, buildAMD } = require('../build/utils');
|
||||
|
||||
removeDir(`monaco-typescript/release`);
|
||||
removeDir(`monaco-typescript/out`);
|
||||
|
||||
copyFile(
|
||||
`monaco-typescript/src/lib/typescriptServices-amd.js`,
|
||||
`monaco-typescript/out/amd/lib/typescriptServices.js`
|
||||
);
|
||||
|
||||
copyFile(
|
||||
`monaco-typescript/src/lib/typescriptServices.js`,
|
||||
`monaco-typescript/out/esm/lib/typescriptServices.js`
|
||||
);
|
||||
|
||||
tsc(`monaco-typescript/src/tsconfig.json`);
|
||||
|
||||
dts(
|
||||
`monaco-typescript/out/amd/monaco.contribution.d.ts`,
|
||||
`monaco-typescript/monaco.d.ts`,
|
||||
'monaco.languages.typescript'
|
||||
);
|
||||
|
||||
buildESM({
|
||||
entryPoints: ['src/monaco.contribution.ts', 'src/tsMode.ts', 'src/ts.worker.ts'],
|
||||
external: ['monaco-editor-core', '*/tsMode']
|
||||
});
|
||||
buildAMD({
|
||||
entryPoint: 'src/monaco.contribution.ts',
|
||||
banner: 'define("vs/language/typescript/monaco.contribution",["vs/editor/editor.api"],()=>{'
|
||||
});
|
||||
buildAMD({
|
||||
entryPoint: 'src/tsMode.ts',
|
||||
banner: 'define("vs/language/typescript/tsMode",["vs/editor/editor.api"],()=>{'
|
||||
});
|
||||
buildAMD({
|
||||
entryPoint: 'src/tsWorker.ts',
|
||||
banner: 'define("vs/language/typescript/tsWorker",[],()=>{'
|
||||
});
|
@ -1,10 +1,7 @@
|
||||
{
|
||||
"scripts": {
|
||||
"compile-amd": "../node_modules/.bin/mcopy ./src/lib/typescriptServices-amd.js ./out/amd/lib/typescriptServices.js && ../node_modules/.bin/tsc -p ./src/tsconfig.json",
|
||||
"compile-esm": "../node_modules/.bin/mcopy ./src/lib/typescriptServices.js ./out/esm/lib/typescriptServices.js && ../node_modules/.bin/tsc -p ./src/tsconfig.esm.json",
|
||||
"compile": "../node_modules/.bin/mrmdir ./out && npm run compile-amd && npm run compile-esm && node ./scripts/dts && ../node_modules/.bin/prettier --write ./monaco.d.ts",
|
||||
"watch": "../node_modules/.bin/tsc -p ./src --watch",
|
||||
"prepublishOnly": "../node_modules/.bin/mrmdir ./release && npm run compile && node ./scripts/release.js && node ./scripts/bundle && ../node_modules/.bin/mcopy ./out/esm/monaco.contribution.d.ts ./release/esm/monaco.contribution.d.ts && ../node_modules/.bin/mcopy ./out/esm/fillers/monaco-editor-core.d.ts ./release/esm/fillers/monaco-editor-core.d.ts",
|
||||
"prepublishOnly": "node ./build",
|
||||
"import-typescript": "node ./scripts/importTypescript"
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const requirejs = require('requirejs');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const terser = require('terser');
|
||||
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-typescript version: ' + headerVersion,
|
||||
' * Released under the MIT license',
|
||||
' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
|
||||
' *-----------------------------------------------------------------------------*/',
|
||||
''
|
||||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
bundleOne('tsMode', ['vs/language/typescript/monaco.contribution']);
|
||||
bundleOne('tsWorker');
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
requirejs.optimize(
|
||||
{
|
||||
baseUrl: 'out/amd/',
|
||||
name: 'vs/language/typescript/' + moduleId,
|
||||
out: 'release/dev/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/language/typescript': REPO_ROOT + '/monaco-typescript/out/amd',
|
||||
'vs/language/typescript/fillers/monaco-editor-core':
|
||||
REPO_ROOT + '/monaco-typescript/out/amd/fillers/monaco-editor-core-amd'
|
||||
},
|
||||
optimize: 'none'
|
||||
},
|
||||
async function (buildResponse) {
|
||||
const devFilePath = path.join(REPO_ROOT, 'monaco-typescript/release/dev/' + moduleId + '.js');
|
||||
const minFilePath = path.join(REPO_ROOT, 'monaco-typescript/release/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${devFilePath}...`);
|
||||
const result = await terser.minify(fileContents, {
|
||||
output: {
|
||||
comments: 'some'
|
||||
}
|
||||
});
|
||||
console.log(`Done minifying ${devFilePath}.`);
|
||||
try {
|
||||
fs.mkdirSync(path.join(REPO_ROOT, 'monaco-typescript/release/min'));
|
||||
} catch (err) {}
|
||||
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
|
||||
}
|
||||
);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../');
|
||||
const SRC_PATH = path.join(REPO_ROOT, 'out/amd/monaco.contribution.d.ts');
|
||||
const DST_PATH = path.join(REPO_ROOT, 'monaco.d.ts');
|
||||
|
||||
const lines = fs
|
||||
.readFileSync(SRC_PATH)
|
||||
.toString()
|
||||
.split(/\r\n|\r|\n/);
|
||||
let result = [
|
||||
`/*---------------------------------------------------------------------------------------------`,
|
||||
` * Copyright (c) Microsoft Corporation. All rights reserved.`,
|
||||
` * Licensed under the MIT License. See License.txt in the project root for license information.`,
|
||||
` *--------------------------------------------------------------------------------------------*/`,
|
||||
``,
|
||||
`/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />`,
|
||||
``,
|
||||
`declare namespace monaco.languages.typescript {`
|
||||
];
|
||||
for (let line of lines) {
|
||||
if (/^import/.test(line)) {
|
||||
continue;
|
||||
}
|
||||
if (line === 'export {};') {
|
||||
continue;
|
||||
}
|
||||
line = line.replace(/ /g, '\t');
|
||||
line = line.replace(/declare /g, '');
|
||||
if (line.length > 0) {
|
||||
line = `\t${line}`;
|
||||
result.push(line);
|
||||
}
|
||||
}
|
||||
result.push(`}`);
|
||||
result.push(``);
|
||||
|
||||
fs.writeFileSync(DST_PATH, result.join('\n'));
|
@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const helpers = require('monaco-plugin-helpers');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../../');
|
||||
|
||||
helpers.packageESM({
|
||||
repoRoot: REPO_ROOT,
|
||||
esmSource: 'monaco-typescript/out/esm',
|
||||
esmDestination: 'monaco-typescript/release/esm',
|
||||
entryPoints: ['monaco.contribution.js', 'tsMode.js', 'ts.worker.js'],
|
||||
resolveSkip: ['monaco-editor-core']
|
||||
});
|
@ -1,12 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Resolves with the global monaco API
|
||||
|
||||
declare const define: any;
|
||||
|
||||
define([], function () {
|
||||
return (<any>self).monaco;
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out/esm",
|
||||
"declaration": true,
|
||||
"target": "es5",
|
||||
"lib": ["dom", "es5", "es2015.collection", "es2015.iterable", "es2015.promise"],
|
||||
"strict": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue