12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*---------------------------------------------------------------------------------------------
- * 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 terser = require('terser');
- 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', ['vs/language/typescript/monaco.contribution']);
- bundleOne('tsWorker');
- function bundleOne(moduleId, exclude) {
- requirejs.optimize(
- {
- baseUrl: 'out/amd/',
- name: 'vs/language/typescript/' + moduleId,
- out: 'release/dev/' + moduleId + '.js',
- exclude: exclude,
- paths: {
- 'vs/language/typescript': REPO_ROOT + '/monaco-typescript/out/amd',
- 'vs/language/typescript/fillers/monaco-editor-core':
- REPO_ROOT + '/monaco-typescript/out/amd/fillers/monaco-editor-core-amd'
- },
- optimize: 'none'
- },
- async function (buildResponse) {
- const devFilePath = path.join(REPO_ROOT, 'monaco-typescript/release/dev/' + moduleId + '.js');
- const minFilePath = path.join(REPO_ROOT, 'monaco-typescript/release/min/' + moduleId + '.js');
- const fileContents = fs.readFileSync(devFilePath).toString();
- console.log();
- console.log(`Minifying ${devFilePath}...`);
- const result = await terser.minify(fileContents, {
- output: {
- comments: 'some'
- }
- });
- console.log(`Done minifying ${devFilePath}.`);
- try {
- fs.mkdirSync(path.join(REPO_ROOT, 'monaco-typescript/release/min'));
- } catch (err) {}
- fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
- }
- );
- }
|