monaco-editor/build/build.js

207 lines
4.8 KiB
JavaScript
Raw Normal View History

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2021-11-12 18:22:26 +08:00
//@ts-check
const glob = require('glob');
2021-11-14 03:41:24 +08:00
const { copyFile, removeDir, tsc, dts, buildESM, buildAMD } = require('../build/utils');
2021-11-13 07:04:23 +08:00
removeDir(`out`);
2021-11-13 07:04:23 +08:00
tsc(`src/tsconfig.json`);
2021-11-14 03:06:41 +08:00
//#region Type Defintion
2021-11-14 02:40:20 +08:00
dts(`out/amd/css/monaco.contribution.d.ts`, `out/release/css/monaco.d.ts`, 'monaco.languages.css');
2021-11-12 08:02:23 +08:00
dts(
2021-11-14 02:40:20 +08:00
`out/amd/html/monaco.contribution.d.ts`,
`out/release/html/monaco.d.ts`,
'monaco.languages.html'
2021-11-12 08:02:23 +08:00
);
2021-11-14 02:46:33 +08:00
dts(
`out/amd/json/monaco.contribution.d.ts`,
`out/release/json/monaco.d.ts`,
'monaco.languages.json'
);
2021-11-14 03:06:41 +08:00
dts(
`out/amd/typescript/monaco.contribution.d.ts`,
`out/release/typescript/monaco.d.ts`,
'monaco.languages.typescript'
);
//#endregion
//#region css
2021-11-14 03:41:24 +08:00
buildESM({
2021-11-13 07:04:23 +08:00
base: 'css',
entryPoints: ['src/css/monaco.contribution.ts', 'src/css/cssMode.ts', 'src/css/css.worker.ts'],
2021-11-12 18:31:25 +08:00
external: ['monaco-editor-core', '*/cssMode']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-13 07:04:23 +08:00
base: 'css',
entryPoint: 'src/css/monaco.contribution.ts',
2021-11-12 21:39:56 +08:00
amdModuleId: 'vs/language/css/monaco.contribution',
amdDependencies: ['vs/editor/editor.api']
2021-11-12 18:31:25 +08:00
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-13 07:04:23 +08:00
base: 'css',
entryPoint: 'src/css/cssMode.ts',
2021-11-12 21:39:56 +08:00
amdModuleId: 'vs/language/css/cssMode'
2021-11-12 18:31:25 +08:00
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-13 07:04:23 +08:00
base: 'css',
entryPoint: 'src/css/cssWorker.ts',
2021-11-12 21:39:56 +08:00
amdModuleId: 'vs/language/css/cssWorker'
});
2021-11-14 02:40:20 +08:00
2021-11-14 03:06:41 +08:00
//#endregion
//#region html
2021-11-14 03:41:24 +08:00
buildESM({
2021-11-14 02:40:20 +08:00
base: 'html',
entryPoints: [
'src/html/monaco.contribution.ts',
'src/html/htmlMode.ts',
'src/html/html.worker.ts'
],
external: ['monaco-editor-core', '*/htmlMode']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:40:20 +08:00
base: 'html',
entryPoint: 'src/html/monaco.contribution.ts',
amdModuleId: 'vs/language/html/monaco.contribution',
amdDependencies: ['vs/editor/editor.api']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:40:20 +08:00
base: 'html',
entryPoint: 'src/html/htmlMode.ts',
amdModuleId: 'vs/language/html/htmlMode'
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:40:20 +08:00
base: 'html',
entryPoint: 'src/html/htmlWorker.ts',
amdModuleId: 'vs/language/html/htmlWorker'
});
2021-11-14 02:46:33 +08:00
2021-11-14 03:06:41 +08:00
//#endregion
//#region json
2021-11-14 03:41:24 +08:00
buildESM({
2021-11-14 02:46:33 +08:00
base: 'json',
2021-11-14 03:06:41 +08:00
entryPoints: [
'src/json/monaco.contribution.ts',
'src/json/jsonMode.ts',
'src/json/json.worker.ts'
],
2021-11-14 02:46:33 +08:00
external: ['monaco-editor-core', '*/jsonMode']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:46:33 +08:00
base: 'json',
entryPoint: 'src/json/monaco.contribution.ts',
amdModuleId: 'vs/language/json/monaco.contribution',
amdDependencies: ['vs/editor/editor.api']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:46:33 +08:00
base: 'json',
entryPoint: 'src/json/jsonMode.ts',
amdModuleId: 'vs/language/json/jsonMode'
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 02:46:33 +08:00
base: 'json',
entryPoint: 'src/json/jsonWorker.ts',
amdModuleId: 'vs/language/json/jsonWorker'
});
2021-11-14 03:06:41 +08:00
//#endregion
//#region typescript
copyFile(
`src/typescript/lib/typescriptServices-amd.js`,
`out/amd/typescript/lib/typescriptServices.js`
);
2021-11-14 03:41:24 +08:00
buildESM({
2021-11-14 03:06:41 +08:00
base: 'typescript',
entryPoints: [
'src/typescript/monaco.contribution.ts',
'src/typescript/tsMode.ts',
'src/typescript/ts.worker.ts'
],
external: ['monaco-editor-core', '*/tsMode']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 03:06:41 +08:00
base: 'typescript',
entryPoint: 'src/typescript/monaco.contribution.ts',
amdModuleId: 'vs/language/typescript/monaco.contribution',
amdDependencies: ['vs/editor/editor.api']
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 03:06:41 +08:00
base: 'typescript',
entryPoint: 'src/typescript/tsMode.ts',
amdModuleId: 'vs/language/typescript/tsMode'
});
2021-11-14 03:41:24 +08:00
buildAMD({
2021-11-14 03:06:41 +08:00
base: 'typescript',
entryPoint: 'src/typescript/tsWorker.ts',
amdModuleId: 'vs/language/typescript/tsWorker'
});
//#endregion
//#region basic-languages
glob('../src/basic-languages/*/*.contribution.ts', { cwd: __dirname }, function (err, files) {
if (err) {
console.error(err);
return;
}
const languages = files.map((file) => file.split('/')[3]);
// ESM
{
/** @type {string[]} */
2021-11-15 16:37:13 +08:00
const entryPoints = [
'src/basic-languages/monaco.contribution.ts',
'src/basic-languages/_.contribution.ts'
];
const external = ['monaco-editor-core', '*/_.contribution'];
for (const language of languages) {
entryPoints.push(`src/basic-languages/${language}/${language}.contribution.ts`);
entryPoints.push(`src/basic-languages/${language}/${language}.ts`);
external.push(`*/${language}.contribution`);
external.push(`*/${language}`);
}
2021-11-14 03:41:24 +08:00
buildESM({
base: 'basic-languages',
entryPoints,
external
});
}
// AMD
{
2021-11-14 03:41:24 +08:00
buildAMD({
base: 'basic-languages',
entryPoint: 'src/basic-languages/monaco.contribution.ts',
amdModuleId: 'vs/basic-languages/monaco.contribution',
amdDependencies: ['vs/editor/editor.api']
});
for (const language of languages) {
2021-11-14 03:41:24 +08:00
buildAMD({
base: 'basic-languages',
entryPoint: `src/basic-languages/${language}/${language}.ts`,
amdModuleId: `vs/basic-languages/${language}/${language}`
});
}
}
});
//#endregion