forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
59 lines (51 loc) · 1.98 KB
/
bundle.js
File metadata and controls
59 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const requirejs = require('requirejs');
const path = require('path');
const fs = require('fs');
const UglifyJS = require('uglify-js');
const helpers = require('monaco-plugin-helpers');
const REPO_ROOT = path.resolve(__dirname, '..');
const sha1 = helpers.getGitVersion(REPO_ROOT);
const semver = require('../package.json').version;
const headerVersion = semver + '(' + sha1 + ')';
const BUNDLED_FILE_HEADER = [
'/*!-----------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * monaco-typescript version: ' + headerVersion,
' * Released under the MIT license',
' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
' *-----------------------------------------------------------------------------*/',
''
].join('\n');
bundleOne('monaco.contribution');
bundleOne('tsMode');
bundleOne('tsWorker');
function bundleOne(moduleId, exclude) {
requirejs.optimize({
baseUrl: 'release/dev/',
name: 'vs/language/typescript/' + moduleId,
out: 'release/min/' + moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/typescript': REPO_ROOT + '/release/dev',
},
packages: [],
optimize: 'none'
}, function(buildResponse) {
console.log(buildResponse)
const filePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
const fileContents = fs.readFileSync(filePath).toString();
console.log();
console.log(`Minifying ${filePath}...`);
const result = UglifyJS.minify(fileContents, {
output: {
comments: 'some'
}
});
console.log(`Done.`);
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
})
}