mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 08:10:11 +01:00
uses rollup to bundle monaco-editor's monaco.d.ts (#5033)
* uses rollup to bundle monaco-editor's monaco.d.ts * Adds missing await
This commit is contained in:
parent
298ad9e43d
commit
a59f6c8a72
7 changed files with 1428 additions and 422 deletions
|
|
@ -4,4 +4,5 @@ export async function buildAmdMinDev() {
|
|||
const rootPath = __dirname;
|
||||
await run('npx vite build --mode development', { cwd: rootPath });
|
||||
await run('npx vite build', { cwd: rootPath });
|
||||
await run('npx rollup -c rollup-types.config.mjs', { cwd: rootPath });
|
||||
}
|
||||
|
|
|
|||
66
build/amd/rollup-types.config.mjs
Normal file
66
build/amd/rollup-types.config.mjs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
import { join } from 'path';
|
||||
import { defineConfig } from 'rollup';
|
||||
import { dts } from 'rollup-plugin-dts';
|
||||
|
||||
const root = join(import.meta.dirname, '../../');
|
||||
const outDir = join(import.meta.dirname, './out');
|
||||
|
||||
/**
|
||||
* @param {string} filePath
|
||||
* @param {string} newExt
|
||||
*/
|
||||
function changeExt(filePath, newExt) {
|
||||
const idx = filePath.lastIndexOf('.');
|
||||
if (idx === -1) {
|
||||
return filePath + newExt;
|
||||
} else {
|
||||
return filePath.substring(0, idx) + newExt;
|
||||
}
|
||||
}
|
||||
|
||||
const mappedPaths = {
|
||||
[join(root, 'node_modules/monaco-editor-core/esm/')]: '.',
|
||||
[join(root, 'node_modules/')]: 'external/',
|
||||
[join(root, 'src/')]: 'vs/'
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
input: {
|
||||
types: join(import.meta.dirname, './src/types.ts')
|
||||
},
|
||||
output: {
|
||||
dir: outDir,
|
||||
format: 'es',
|
||||
preserveModules: false,
|
||||
entryFileNames: function (chunkInfo) {
|
||||
const moduleId = chunkInfo.facadeModuleId;
|
||||
if (moduleId) {
|
||||
for (const [key, val] of Object.entries(mappedPaths)) {
|
||||
if (moduleId.startsWith(key)) {
|
||||
const relativePath = moduleId.substring(key.length);
|
||||
return changeExt(join(val, relativePath), '.d.ts');
|
||||
}
|
||||
}
|
||||
}
|
||||
return '[name].d.ts';
|
||||
}
|
||||
},
|
||||
external: [/.*\.css/],
|
||||
plugins: [
|
||||
nodeResolve(),
|
||||
dts({
|
||||
compilerOptions: {
|
||||
stripInternal: true
|
||||
},
|
||||
includeExternal: ['monaco-editor-core']
|
||||
})
|
||||
]
|
||||
});
|
||||
3
build/amd/src/types.ts
Normal file
3
build/amd/src/types.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import * as m from './editor.main';
|
||||
|
||||
export { m };
|
||||
Loading…
Add table
Add a link
Reference in a new issue