mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Add buildESM to common build script
This commit is contained in:
parent
1ffcd4ae93
commit
8944900f86
3 changed files with 41 additions and 32 deletions
|
|
@ -3,10 +3,13 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//@ts-check
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
|
const alias = require('esbuild-plugin-alias');
|
||||||
|
|
||||||
const REPO_ROOT = path.join(__dirname, '..');
|
const REPO_ROOT = path.join(__dirname, '..');
|
||||||
|
|
||||||
|
|
@ -86,7 +89,7 @@ function tsc(_projectPath) {
|
||||||
cp.spawnSync(
|
cp.spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[path.join(__dirname, '../node_modules/typescript/lib/tsc.js'), '-p', projectPath],
|
[path.join(__dirname, '../node_modules/typescript/lib/tsc.js'), '-p', projectPath],
|
||||||
{ stdio: 'inherit', stderr: 'inherit' }
|
{ stdio: 'inherit' }
|
||||||
);
|
);
|
||||||
console.log(`Compiled ${_projectPath}`);
|
console.log(`Compiled ${_projectPath}`);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +105,7 @@ function prettier(_filePath) {
|
||||||
cp.spawnSync(
|
cp.spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[path.join(__dirname, '../node_modules/prettier/bin-prettier.js'), '--write', filePath],
|
[path.join(__dirname, '../node_modules/prettier/bin-prettier.js'), '--write', filePath],
|
||||||
{ stdio: 'inherit', stderr: 'inherit' }
|
{ stdio: 'inherit' }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`Ran prettier over ${_filePath}`);
|
console.log(`Ran prettier over ${_filePath}`);
|
||||||
|
|
@ -170,6 +173,32 @@ function build(options) {
|
||||||
}
|
}
|
||||||
exports.build = build;
|
exports.build = build;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {{
|
||||||
|
* entryPoints: string[];
|
||||||
|
* external: string[];
|
||||||
|
* }} options
|
||||||
|
*/
|
||||||
|
function buildESM(options) {
|
||||||
|
build({
|
||||||
|
entryPoints: options.entryPoints,
|
||||||
|
bundle: true,
|
||||||
|
target: 'esnext',
|
||||||
|
format: 'esm',
|
||||||
|
define: {
|
||||||
|
AMD: 'false'
|
||||||
|
},
|
||||||
|
external: options.external,
|
||||||
|
outdir: 'release/esm/',
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
'vscode-nls': path.join(__dirname, 'fillers/vscode-nls.ts')
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.buildESM = buildESM;
|
||||||
|
|
||||||
function getGitVersion() {
|
function getGitVersion() {
|
||||||
const git = path.join(REPO_ROOT, '.git');
|
const git = path.join(REPO_ROOT, '.git');
|
||||||
const headPath = path.join(git, 'HEAD');
|
const headPath = path.join(git, 'HEAD');
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//@ts-check
|
||||||
|
|
||||||
const alias = require('esbuild-plugin-alias');
|
const alias = require('esbuild-plugin-alias');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { removeDir, tsc, dts, build } = require('../build/utils');
|
const { removeDir, tsc, dts, build, buildESM } = require('../build/utils');
|
||||||
|
|
||||||
removeDir(`monaco-css/release`);
|
removeDir(`monaco-css/release`);
|
||||||
removeDir(`monaco-css/out`);
|
removeDir(`monaco-css/out`);
|
||||||
|
|
@ -18,21 +20,9 @@ dts(
|
||||||
'monaco.languages.css'
|
'monaco.languages.css'
|
||||||
);
|
);
|
||||||
|
|
||||||
build({
|
buildESM({
|
||||||
entryPoints: ['src/monaco.contribution.ts', 'src/cssMode.ts', 'src/css.worker.ts'],
|
entryPoints: ['src/monaco.contribution.ts', 'src/cssMode.ts', 'src/css.worker.ts'],
|
||||||
bundle: true,
|
|
||||||
target: 'esnext',
|
|
||||||
format: 'esm',
|
|
||||||
define: {
|
|
||||||
AMD: false
|
|
||||||
},
|
|
||||||
external: ['monaco-editor-core', '*/cssMode'],
|
external: ['monaco-editor-core', '*/cssMode'],
|
||||||
outdir: 'release/esm/',
|
|
||||||
plugins: [
|
|
||||||
alias({
|
|
||||||
'vscode-nls': path.join(__dirname, '../build/fillers/vscode-nls.ts')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,7 +38,7 @@ function buildOneAMD(type, entryPoint, banner) {
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
define: {
|
define: {
|
||||||
AMD: true
|
AMD: 'true'
|
||||||
},
|
},
|
||||||
external: ['*/cssMode'],
|
external: ['*/cssMode'],
|
||||||
globalName: 'moduleExports',
|
globalName: 'moduleExports',
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//@ts-check
|
||||||
|
|
||||||
const alias = require('esbuild-plugin-alias');
|
const alias = require('esbuild-plugin-alias');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { removeDir, tsc, dts, build } = require('../build/utils');
|
const { removeDir, tsc, dts, build, buildESM } = require('../build/utils');
|
||||||
|
|
||||||
removeDir(`monaco-html/release`);
|
removeDir(`monaco-html/release`);
|
||||||
removeDir(`monaco-html/out`);
|
removeDir(`monaco-html/out`);
|
||||||
|
|
@ -18,21 +20,9 @@ dts(
|
||||||
'monaco.languages.html'
|
'monaco.languages.html'
|
||||||
);
|
);
|
||||||
|
|
||||||
build({
|
buildESM({
|
||||||
entryPoints: ['src/monaco.contribution.ts', 'src/htmlMode.ts', 'src/html.worker.ts'],
|
entryPoints: ['src/monaco.contribution.ts', 'src/htmlMode.ts', 'src/html.worker.ts'],
|
||||||
bundle: true,
|
|
||||||
target: 'esnext',
|
|
||||||
format: 'esm',
|
|
||||||
define: {
|
|
||||||
AMD: false
|
|
||||||
},
|
|
||||||
external: ['monaco-editor-core', '*/htmlMode'],
|
external: ['monaco-editor-core', '*/htmlMode'],
|
||||||
outdir: 'release/esm/',
|
|
||||||
plugins: [
|
|
||||||
alias({
|
|
||||||
'vscode-nls': path.join(__dirname, '../build/fillers/vscode-nls.ts')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,7 +38,7 @@ function buildOneAMD(type, entryPoint, banner) {
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
define: {
|
define: {
|
||||||
AMD: true
|
AMD: 'true'
|
||||||
},
|
},
|
||||||
external: ['*/htmlMode'],
|
external: ['*/htmlMode'],
|
||||||
globalName: 'moduleExports',
|
globalName: 'moduleExports',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue