build.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. const esbuild = require('esbuild');
  6. const alias = require('esbuild-plugin-alias');
  7. const path = require('path');
  8. const cp = require('child_process');
  9. const { copyFile, removeDir } = require('../../build/utils');
  10. removeDir(`monaco-css/release`);
  11. removeDir(`monaco-css/out`);
  12. cp.spawnSync(process.execPath, [path.join(__dirname, '../../node_modules/typescript/lib/tsc.js'), '-p', path.join(__dirname, '../src/tsconfig.json')], { stdio: 'inherit', stderr: 'inherit' });
  13. cp.spawnSync(process.execPath, [path.join(__dirname, './dts.js')], { stdio: 'inherit', stderr: 'inherit' });
  14. cp.spawnSync(process.execPath, [path.join(__dirname, '../../node_modules/prettier/bin-prettier.js'), '--write', path.join(__dirname, '../monaco.d.ts')], { stdio: 'inherit', stderr: 'inherit' });
  15. esbuild.build({
  16. entryPoints: ['src/cssMode.ts', 'src/css.worker.ts', 'src/monaco.contribution.ts'],
  17. bundle: true,
  18. target: 'esnext',
  19. format: 'esm',
  20. external: ['monaco-editor-core', '*/cssMode'],
  21. outdir: 'release/esm/',
  22. plugins: [
  23. alias({
  24. 'vscode-nls': path.join(__dirname, '../src/fillers/vscode-nls.ts'),
  25. }),
  26. ],
  27. }).then((result) => {
  28. if (result.errors.length > 0) {
  29. console.error(result.errors);
  30. }
  31. if (result.warnings.length > 0) {
  32. console.error(result.warnings);
  33. }
  34. });
  35. copyFile('monaco-css/out/amd/monaco.contribution.d.ts', 'monaco-css/release/esm/monaco.contribution.d.ts');
  36. copyFile('monaco-css/out/amd/fillers/monaco-editor-core.d.ts', 'monaco-css/release/esm/fillers/monaco-editor-core.d.ts');
  37. cp.spawnSync(process.execPath, [path.join(__dirname, './bundle.js')], { stdio: 'inherit', stderr: 'inherit' });