package-esbuild.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. import * as esbuild from 'esbuild';
  6. import * as path from 'path';
  7. import { removeDir } from '../../build/fs';
  8. removeDir('test/smoke/esbuild/out');
  9. const workerEntryPoints = [
  10. 'vs/language/json/json.worker.js',
  11. 'vs/language/css/css.worker.js',
  12. 'vs/language/html/html.worker.js',
  13. 'vs/language/typescript/ts.worker.js',
  14. 'vs/editor/editor.worker.js'
  15. ];
  16. build({
  17. entryPoints: workerEntryPoints.map((entry) =>
  18. path.join(__dirname, `../../out/monaco-editor/esm/${entry}`)
  19. ),
  20. bundle: true,
  21. format: 'iife',
  22. logLevel: 'silent',
  23. outbase: path.join(__dirname, '../../out/monaco-editor/esm/'),
  24. outdir: path.join(__dirname, 'esbuild/out')
  25. });
  26. build({
  27. entryPoints: [path.join(__dirname, 'esbuild/index.js')],
  28. bundle: true,
  29. format: 'iife',
  30. logLevel: 'silent',
  31. outdir: path.join(__dirname, 'esbuild/out'),
  32. loader: {
  33. '.ttf': 'file'
  34. }
  35. });
  36. function build(opts: esbuild.BuildOptions) {
  37. esbuild.build(opts).then((result) => {
  38. const errors = result.errors;
  39. const warnings = result.warnings.filter((w) => {
  40. return (
  41. w.text !==
  42. 'Top-level "this" will be replaced with undefined since this file is an ECMAScript module'
  43. );
  44. });
  45. if (errors.length > 0) {
  46. console.log(`errors:`);
  47. console.error(errors);
  48. }
  49. if (warnings.length > 0) {
  50. console.log(`warnings:`);
  51. console.error(warnings);
  52. }
  53. });
  54. }