forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
common.js
67 lines (64 loc) · 2.16 KB
/
common.js
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
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
const glob = require('glob');
const path = require('path');
// eslint-disable-next-line camelcase
const webpack_bundle_analyzer = require('webpack-bundle-analyzer');
const constants = require('../constants');
exports.nodeModulesToExternalize = [
'unicode/category/Lu',
'unicode/category/Ll',
'unicode/category/Lt',
'unicode/category/Lo',
'unicode/category/Lm',
'unicode/category/Nl',
'unicode/category/Mn',
'unicode/category/Mc',
'unicode/category/Nd',
'unicode/category/Pc',
'request',
'request-progress',
'source-map-support',
'diff-match-patch',
'sudo-prompt',
'node-stream-zip',
'xml2js',
];
exports.nodeModulesToReplacePaths = [...exports.nodeModulesToExternalize];
function getDefaultPlugins(name) {
const plugins = [];
// Only run the analyzer on a local machine or if required
if (!constants.isCI || process.env.VSC_PYTHON_FORCE_ANALYZER) {
plugins.push(
new webpack_bundle_analyzer.BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: `${name}.analyzer.html`,
generateStatsFile: true,
statsFilename: `${name}.stats.json`,
openAnalyzer: false, // Open file manually if you want to see it :)
}),
);
}
return plugins;
}
exports.getDefaultPlugins = getDefaultPlugins;
function getListOfExistingModulesInOutDir() {
const outDir = path.join(constants.ExtensionRootDir, 'out', 'client');
const files = glob.sync('**/*.js', { sync: true, cwd: outDir });
return files.map((filePath) => `./${filePath.slice(0, -3)}`);
}
exports.getListOfExistingModulesInOutDir = getListOfExistingModulesInOutDir;
function getTranlationsLoader() {
const loaders = [];
if (process.env.DISABLE_TRANSLATIONS !== 'true') {
loaders.push({
loader: 'vscode-nls-dev/lib/webpack-loader',
options: {
base: constants.ExtensionRootDir,
},
});
}
return loaders;
}
exports.getTranlationsLoader = getTranlationsLoader;