Skip to content

Commit d9fb87d

Browse files
committed
CI for Monaco Editor compile and bundling.
1 parent 9b70b18 commit d9fb87d

10 files changed

Lines changed: 302 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,20 @@ jobs:
110110
name: Run Unit Tests
111111
- run: ./scripts/test-integration.sh --tfs "Integration Tests"
112112
name: Run Integration Tests
113+
114+
monaco:
115+
runs-on: macos-latest
116+
env:
117+
CHILD_CONCURRENCY: "1"
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
steps:
120+
- uses: actions/checkout@v1
121+
- uses: actions/setup-node@v1
122+
with:
123+
node-version: 10
124+
- run: yarn --frozen-lockfile
125+
name: Install Dependencies
126+
- run: yarn monaco-compile-check
127+
name: Run Monaco Editor Checks
128+
- run: yarn editor-esm-bundle
129+
name: Editor Distro & ESM Bundle

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ out-editor/
1111
out-editor-src/
1212
out-editor-build/
1313
out-editor-esm/
14+
out-editor-esm-bundle/
1415
out-editor-min/
1516
out-monaco-editor-core/
1617
out-vscode/

build/gulpfile.editor.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,28 @@ gulp.task('editor-distro',
310310
)
311311
);
312312

313+
const bundleEditorESMTask = task.define('editor-esm-bundle-webpack', () => {
314+
return standalone.bundleESM();
315+
});
316+
317+
gulp.task('editor-esm-bundle',
318+
task.series(
319+
task.parallel(
320+
util.rimraf('out-editor-src'),
321+
util.rimraf('out-editor-build'),
322+
util.rimraf('out-editor-esm'),
323+
util.rimraf('out-monaco-editor-core'),
324+
util.rimraf('out-editor'),
325+
util.rimraf('out-editor-min')
326+
),
327+
extractEditorSrcTask,
328+
createESMSourcesAndResourcesTask,
329+
compileEditorESMTask,
330+
bundleEditorESMTask,
331+
finalEditorResourcesTask
332+
)
333+
);
334+
313335
//#region monaco type checking
314336

315337
function createTscCompileTask(watch) {

build/lib/compilation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function createCompile(src, build, emitError) {
4444
const input = es.through();
4545
const output = input
4646
.pipe(utf8Filter)
47-
.pipe(bom())
47+
.pipe(bom()) // this is required to preserve BOM in test files that loose it otherwise
4848
.pipe(utf8Filter.restore)
4949
.pipe(tsFilter)
5050
.pipe(util.loadSourcemaps())

build/lib/standalone.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
*--------------------------------------------------------------------------------------------*/
66
Object.defineProperty(exports, "__esModule", { value: true });
77
const ts = require("typescript");
8+
const es = require("event-stream");
89
const fs = require("fs");
910
const path = require("path");
1011
const tss = require("./treeshaking");
12+
const gulp = require("gulp");
13+
const webpack = require("webpack");
14+
const webpackGulp = require('webpack-stream');
1115
const REPO_ROOT = path.join(__dirname, '../../');
1216
const SRC_DIR = path.join(REPO_ROOT, 'src');
1317
let dirCache = {};
@@ -309,3 +313,23 @@ function transportCSS(module, enqueue, write) {
309313
return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;
310314
}
311315
}
316+
function bundleESM() {
317+
const result = es.through();
318+
const webpackConfigPath = path.join(__dirname, '../../build/monaco/monaco.webpack.config.js');
319+
const webpackConfig = Object.assign(Object.assign({}, require(webpackConfigPath)), { mode: 'production' });
320+
const webpackDone = (err, stats) => {
321+
if (err) {
322+
result.emit('error', err);
323+
}
324+
const { compilation } = stats;
325+
if (compilation.errors.length > 0) {
326+
result.emit('error', compilation.errors.join('\n'));
327+
}
328+
if (compilation.warnings.length > 0) {
329+
result.emit('data', compilation.warnings.join('\n'));
330+
}
331+
};
332+
return webpackGulp(webpackConfig, webpack, webpackDone)
333+
.pipe(gulp.dest('out-editor-esm-bundle'));
334+
}
335+
exports.bundleESM = bundleESM;

build/lib/standalone.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as ts from 'typescript';
7+
import * as es from 'event-stream';
78
import * as fs from 'fs';
89
import * as path from 'path';
910
import * as tss from './treeshaking';
11+
import * as gulp from 'gulp';
12+
import * as webpack from 'webpack';
13+
const webpackGulp = require('webpack-stream');
1014

1115
const REPO_ROOT = path.join(__dirname, '../../');
1216
const SRC_DIR = path.join(REPO_ROOT, 'src');
@@ -357,3 +361,30 @@ function transportCSS(module: string, enqueue: (module: string) => void, write:
357361
return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;
358362
}
359363
}
364+
365+
export function bundleESM() {
366+
const result = es.through();
367+
368+
const webpackConfigPath = path.join(__dirname, '../../build/monaco/monaco.webpack.config.js');
369+
370+
const webpackConfig = {
371+
...require(webpackConfigPath),
372+
...{ mode: 'production' }
373+
};
374+
375+
const webpackDone = (err: any, stats: any) => {
376+
if (err) {
377+
result.emit('error', err);
378+
}
379+
const { compilation } = stats;
380+
if (compilation.errors.length > 0) {
381+
result.emit('error', compilation.errors.join('\n'));
382+
}
383+
if (compilation.warnings.length > 0) {
384+
result.emit('data', compilation.warnings.join('\n'));
385+
}
386+
};
387+
388+
return webpackGulp(webpackConfig, webpack, webpackDone)
389+
.pipe(gulp.dest('out-editor-esm-bundle'));
390+
}

build/monaco/esm.core.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
6+
// Entry file for webpack bunlding.
7+
8+
import * as monaco from 'monaco-editor-core';
9+
10+
self.MonacoEnvironment = {
11+
getWorkerUrl: function (moduleId, label) {
12+
return './editor.worker.bundle.js';
13+
}
14+
}
15+
16+
monaco.editor.create(document.getElementById('container'), {
17+
value: [
18+
'var hello = "hello world";'
19+
].join('\n'),
20+
language: 'javascript'
21+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
6+
const path = require('path');
7+
8+
module.exports = {
9+
mode: 'production',
10+
entry: {
11+
"core": './build/monaco/esm.core.js',
12+
"editor.worker": './out-monaco-editor-core/esm/vs/editor/editor.worker.js'
13+
},
14+
output: {
15+
globalObject: 'self',
16+
filename: '[name].bundle.js',
17+
path: path.resolve(__dirname, 'dist')
18+
},
19+
module: {
20+
rules: [
21+
{
22+
test: /\.css$/,
23+
use: ['style-loader', 'css-loader'],
24+
},
25+
{
26+
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
27+
use: [
28+
{
29+
loader: 'file-loader',
30+
options: {
31+
name: '[name].[ext]',
32+
outputPath: 'fonts/'
33+
}
34+
}
35+
]
36+
}
37+
]
38+
},
39+
resolve: {
40+
alias: {
41+
'monaco-editor-core': path.resolve(__dirname, '../../out-monaco-editor-core/esm/vs/editor/editor.main.js'),
42+
}
43+
},
44+
stats: {
45+
all: false,
46+
modules: true,
47+
maxModules: 0,
48+
errors: true,
49+
warnings: true,
50+
// our additional options
51+
moduleTrace: true,
52+
errorDetails: true,
53+
chunks: true
54+
}
55+
};

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@
8383
"copy-webpack-plugin": "^4.5.2",
8484
"coveralls": "^2.11.11",
8585
"cson-parser": "^1.3.3",
86+
"css-loader": "^3.2.0",
8687
"debounce": "^1.0.0",
8788
"event-stream": "3.3.4",
8889
"express": "^4.13.1",
8990
"fancy-log": "^1.3.3",
9091
"fast-plist": "0.1.2",
92+
"file-loader": "^4.2.0",
9193
"glob": "^5.0.13",
9294
"gulp": "^4.0.0",
9395
"gulp-atom-electron": "^1.22.0",
@@ -134,6 +136,7 @@
134136
"rimraf": "^2.2.8",
135137
"sinon": "^1.17.2",
136138
"source-map": "^0.4.4",
139+
"style-loader": "^1.0.0",
137140
"ts-loader": "^4.4.2",
138141
"tslint": "^5.16.0",
139142
"typescript": "3.7.2",

0 commit comments

Comments
 (0)