Bundle AMD using requirejs
parent
f0f1142183
commit
95ad374e88
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,69 @@
|
||||
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-html version: ' + headerVersion,
|
||||
' * Released under the MIT license',
|
||||
' * https://github.com/Microsoft/monaco-html/blob/master/LICENSE.md',
|
||||
' *-----------------------------------------------------------------------------*/',
|
||||
''
|
||||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
bundleOne('htmlMode');
|
||||
bundleOne('htmlWorker');
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
requirejs.optimize({
|
||||
baseUrl: 'out/amd/',
|
||||
name: 'vs/language/html/' + moduleId,
|
||||
out: 'release/dev/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/language/html': REPO_ROOT + '/out/amd'
|
||||
},
|
||||
optimize: 'none',
|
||||
packages: [{
|
||||
name: 'vscode-html-languageservice',
|
||||
location: path.join(REPO_ROOT, 'node_modules/vscode-html-languageservice/lib/umd'),
|
||||
main: 'htmlLanguageService'
|
||||
}, {
|
||||
name: 'vscode-languageserver-types',
|
||||
location: path.join(REPO_ROOT, 'node_modules/vscode-languageserver-types/lib/umd'),
|
||||
main: 'main'
|
||||
}, {
|
||||
name: 'vscode-uri',
|
||||
location: path.join(REPO_ROOT, 'node_modules/vscode-uri/lib/umd'),
|
||||
main: 'index'
|
||||
}, {
|
||||
name: 'vscode-nls',
|
||||
location: path.join(REPO_ROOT, '/out/amd/fillers'),
|
||||
main: 'vscode-nls'
|
||||
}]
|
||||
}, function (buildResponse) {
|
||||
const devFilePath = path.join(REPO_ROOT, 'release/dev/' + moduleId + '.js');
|
||||
const minFilePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${devFilePath}...`);
|
||||
const result = UglifyJS.minify(fileContents, {
|
||||
output: {
|
||||
comments: 'some'
|
||||
}
|
||||
});
|
||||
console.log(`Done.`);
|
||||
try { fs.mkdirSync(path.join(REPO_ROOT, 'release/min')) } catch (err) { }
|
||||
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
|
||||
})
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const REPO_ROOT = path.resolve(__dirname, '..');
|
||||
|
||||
exports.createWebpackConfig = function (isDev) {
|
||||
let targetFolder = isDev ? './release/dev' : './release/min';
|
||||
let mode = isDev ? 'development' : 'production';
|
||||
|
||||
return {
|
||||
entry: {
|
||||
"monaco.contribution": './release/esm/monaco.contribution',
|
||||
"htmlMode": './release/esm/htmlMode',
|
||||
"htmlWorker": './release/esm/htmlWorker'
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.resolve(REPO_ROOT, targetFolder),
|
||||
libraryTarget: "amd"
|
||||
},
|
||||
mode: mode,
|
||||
plugins: [
|
||||
new webpack.optimize.LimitChunkCountPlugin({
|
||||
maxChunks: 1,
|
||||
})
|
||||
],
|
||||
};
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out/esm",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es5",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
module.exports = require('./scripts/webpack').createWebpackConfig(true);
|
@ -1 +0,0 @@
|
||||
module.exports = require('./scripts/webpack').createWebpackConfig(false);
|
Loading…
Reference in New Issue