Skip to content

Commit 3d9c962

Browse files
authored
Enable live share support (microsoft#4645)
For #4521, #4529 Finish enabling live share support and add tests for liveshare and color parsing. Fix issue with liveshare not bundling correctly. <!-- If an item below does not apply to you, then go ahead and check it off as "done" and strikethrough the text, e.g.: - [x] ~Has unit tests & system/integration tests~ --> - [x] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR) - [x] Title summarizes what is changing - [x] Has a [news entry](https://github.com/Microsoft/vscode-python/tree/master/news) file (remember to thank yourself!) - [x] Has sufficient logging. - [ ] Has telemetry for enhancements. - [x] Unit tests & system/integration tests are added/updated - [ ] [Test plan](https://github.com/Microsoft/vscode-python/blob/master/.github/test_plan.md) is updated as appropriate - [ ] [`package-lock.json`](https://github.com/Microsoft/vscode-python/blob/master/package-lock.json) has been regenerated by running `npm install` (if dependencies have changed) - [ ] The wiki is updated with any design decisions/details.
1 parent 269eab8 commit 3d9c962

43 files changed

Lines changed: 1724 additions & 672 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/launch.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
"--extensionDevelopmentPath=${workspaceFolder}",
6969
"--extensionTestsPath=${workspaceFolder}/out/test"
7070
],
71+
"env": {
72+
"VSC_PYTHON_CI_TEST_GREP": "" // Modify this to run a subset of the single workspace tests
73+
},
7174
"stopOnEntry": false,
7275
"sourceMaps": true,
7376
"outFiles": [

build/webpack/common.js

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
3-
'use strict';
4-
Object.defineProperty(exports, "__esModule", { value: true });
5-
const glob = require("glob");
6-
const path = require("path");
7-
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
8-
const constants_1 = require("../constants");
9-
exports.nodeModulesToExternalize = [
10-
'unicode/category/Lu',
11-
'unicode/category/Ll',
12-
'unicode/category/Lt',
13-
'unicode/category/Lo',
14-
'unicode/category/Lm',
15-
'unicode/category/Nl',
16-
'unicode/category/Mn',
17-
'unicode/category/Mc',
18-
'unicode/category/Nd',
19-
'unicode/category/Pc',
20-
'@jupyterlab/services',
21-
'azure-storage',
22-
'request',
23-
'request-progress',
24-
'source-map-support',
25-
'diff-match-patch',
26-
'sudo-prompt',
27-
'node-stream-zip',
28-
'xml2js',
29-
'vsls/vscode'
30-
];
31-
function getDefaultPlugins(name) {
32-
const plugins = [];
33-
if (!constants_1.isCI) {
34-
plugins.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
35-
analyzerMode: 'static',
36-
reportFilename: `${name}.analyzer.html`
37-
}));
38-
}
39-
return plugins;
40-
}
41-
exports.getDefaultPlugins = getDefaultPlugins;
42-
function getListOfExistingModulesInOutDir() {
43-
const outDir = path.join(constants_1.ExtensionRootDir, 'out', 'client');
44-
const files = glob.sync('**/*.js', { sync: true, cwd: outDir });
45-
return files.map(filePath => `./${filePath.slice(0, -3)}`);
46-
}
47-
exports.getListOfExistingModulesInOutDir = getListOfExistingModulesInOutDir;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
'use strict';
4+
Object.defineProperty(exports, "__esModule", { value: true });
5+
const glob = require("glob");
6+
const path = require("path");
7+
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
8+
const constants_1 = require("../constants");
9+
exports.nodeModulesToExternalize = [
10+
'unicode/category/Lu',
11+
'unicode/category/Ll',
12+
'unicode/category/Lt',
13+
'unicode/category/Lo',
14+
'unicode/category/Lm',
15+
'unicode/category/Nl',
16+
'unicode/category/Mn',
17+
'unicode/category/Mc',
18+
'unicode/category/Nd',
19+
'unicode/category/Pc',
20+
'@jupyterlab/services',
21+
'azure-storage',
22+
'request',
23+
'request-progress',
24+
'source-map-support',
25+
'diff-match-patch',
26+
'sudo-prompt',
27+
'node-stream-zip',
28+
'xml2js',
29+
'vsls/vscode',
30+
];
31+
exports.nodeModulesToReplacePaths = [
32+
...exports.nodeModulesToExternalize
33+
];
34+
function getDefaultPlugins(name) {
35+
const plugins = [];
36+
if (!constants_1.isCI) {
37+
plugins.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
38+
analyzerMode: 'static',
39+
reportFilename: `${name}.analyzer.html`
40+
}));
41+
}
42+
return plugins;
43+
}
44+
exports.getDefaultPlugins = getDefaultPlugins;
45+
function getListOfExistingModulesInOutDir() {
46+
const outDir = path.join(constants_1.ExtensionRootDir, 'out', 'client');
47+
const files = glob.sync('**/*.js', { sync: true, cwd: outDir });
48+
return files.map(filePath => `./${filePath.slice(0, -3)}`);
49+
}
50+
exports.getListOfExistingModulesInOutDir = getListOfExistingModulesInOutDir;

build/webpack/common.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ export const nodeModulesToExternalize = [
2828
'sudo-prompt',
2929
'node-stream-zip',
3030
'xml2js',
31-
'vsls/vscode'
31+
'vsls/vscode',
3232
];
3333

34+
export const nodeModulesToReplacePaths = [
35+
...nodeModulesToExternalize
36+
]
37+
3438
export function getDefaultPlugins(name: 'extension' | 'debugger' | 'dependencies' | 'datascience-ui') {
3539
const plugins = [];
3640
if (!isCI) {
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
3-
'use strict';
4-
Object.defineProperty(exports, "__esModule", { value: true });
5-
const common_1 = require("../common");
6-
function replaceModule(contents, moduleName, quotes) {
7-
const stringToSearch = `${quotes}${moduleName}${quotes}`;
8-
const stringToReplaceWith = `${quotes}./node_modules/${moduleName}${quotes}`;
9-
return contents.replace(new RegExp(stringToSearch, 'gm'), stringToReplaceWith);
10-
}
11-
// tslint:disable:no-default-export no-invalid-this
12-
function default_1(source) {
13-
common_1.nodeModulesToExternalize.forEach(moduleName => {
14-
if (source.indexOf(moduleName) > 0) {
15-
source = replaceModule(source, moduleName, '"');
16-
source = replaceModule(source, moduleName, '\'');
17-
}
18-
});
19-
return source;
20-
}
21-
exports.default = default_1;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
'use strict';
4+
Object.defineProperty(exports, "__esModule", { value: true });
5+
const common_1 = require("../common");
6+
function replaceModule(contents, moduleName, quotes) {
7+
const stringToSearch = `${quotes}${moduleName}${quotes}`;
8+
const stringToReplaceWith = `${quotes}./node_modules/${moduleName}${quotes}`;
9+
return contents.replace(new RegExp(stringToSearch, 'gm'), stringToReplaceWith);
10+
}
11+
// tslint:disable:no-default-export no-invalid-this
12+
function default_1(source) {
13+
common_1.nodeModulesToReplacePaths.forEach(moduleName => {
14+
if (source.indexOf(moduleName) > 0) {
15+
source = replaceModule(source, moduleName, '"');
16+
source = replaceModule(source, moduleName, '\'');
17+
}
18+
});
19+
return source;
20+
}
21+
exports.default = default_1;

build/webpack/loaders/externalizeDependencies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
'use strict';
55

6-
import { nodeModulesToExternalize } from '../common';
6+
import { nodeModulesToReplacePaths } from '../common';
77

88
function replaceModule(contents: string, moduleName: string, quotes: '"' | '\''): string {
99
const stringToSearch = `${quotes}${moduleName}${quotes}`;
@@ -12,7 +12,7 @@ function replaceModule(contents: string, moduleName: string, quotes: '"' | '\'')
1212
}
1313
// tslint:disable:no-default-export no-invalid-this
1414
export default function (source: string) {
15-
nodeModulesToExternalize.forEach(moduleName => {
15+
nodeModulesToReplacePaths.forEach(moduleName => {
1616
if (source.indexOf(moduleName) > 0) {
1717
source = replaceModule(source, moduleName, '"');
1818
source = replaceModule(source, moduleName, '\'');
Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
3-
'use strict';
4-
Object.defineProperty(exports, "__esModule", { value: true });
5-
const path = require("path");
6-
const constants_1 = require("../constants");
7-
const common_1 = require("./common");
8-
const entryItems = {};
9-
common_1.nodeModulesToExternalize.forEach(moduleName => {
10-
entryItems[`node_modules/${moduleName}`] = `./node_modules/${moduleName}`;
11-
});
12-
const config = {
13-
mode: 'production',
14-
target: 'node',
15-
entry: entryItems,
16-
devtool: 'source-map',
17-
node: {
18-
__dirname: false
19-
},
20-
module: {
21-
rules: [
22-
{
23-
// JupyterServices imports node-fetch using `eval`.
24-
test: /@jupyterlab[\\\/]services[\\\/].*js$/,
25-
use: [
26-
{
27-
loader: path.join(__dirname, 'loaders', 'fixEvalRequire.js')
28-
}
29-
]
30-
}
31-
]
32-
},
33-
externals: [
34-
'vscode',
35-
'commonjs'
36-
],
37-
plugins: [
38-
...common_1.getDefaultPlugins('dependencies')
39-
],
40-
resolve: {
41-
extensions: ['.js']
42-
},
43-
output: {
44-
filename: '[name].js',
45-
path: path.resolve(constants_1.ExtensionRootDir, 'out', 'client'),
46-
libraryTarget: 'commonjs2',
47-
devtoolModuleFilenameTemplate: '../../[resource-path]'
48-
}
49-
};
50-
// tslint:disable-next-line:no-default-export
51-
exports.default = config;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
'use strict';
4+
Object.defineProperty(exports, "__esModule", { value: true });
5+
const path = require("path");
6+
const constants_1 = require("../constants");
7+
const common_1 = require("./common");
8+
const copyWebpackPlugin = require("copy-webpack-plugin");
9+
const entryItems = {};
10+
common_1.nodeModulesToExternalize.forEach(moduleName => {
11+
entryItems[`node_modules/${moduleName}`] = `./node_modules/${moduleName}`;
12+
});
13+
const config = {
14+
mode: 'production',
15+
target: 'node',
16+
entry: entryItems,
17+
devtool: 'source-map',
18+
node: {
19+
__dirname: false
20+
},
21+
module: {
22+
rules: [
23+
{
24+
// JupyterServices imports node-fetch using `eval`.
25+
test: /@jupyterlab[\\\/]services[\\\/].*js$/,
26+
use: [
27+
{
28+
loader: path.join(__dirname, 'loaders', 'fixEvalRequire.js')
29+
}
30+
]
31+
}
32+
]
33+
},
34+
externals: [
35+
'vscode',
36+
'commonjs'
37+
],
38+
plugins: [
39+
...common_1.getDefaultPlugins('dependencies'),
40+
// vsls requires our package.json to be next to node_modules. It's how they
41+
// 'find' the calling extension.
42+
new copyWebpackPlugin([
43+
{ from: './package.json', to: '.' }
44+
])
45+
],
46+
resolve: {
47+
extensions: ['.js']
48+
},
49+
output: {
50+
filename: '[name].js',
51+
path: path.resolve(constants_1.ExtensionRootDir, 'out', 'client'),
52+
libraryTarget: 'commonjs2',
53+
devtoolModuleFilenameTemplate: '../../[resource-path]'
54+
}
55+
};
56+
// tslint:disable-next-line:no-default-export
57+
exports.default = config;

build/webpack/webpack.extension.dependencies.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
import * as webpack from 'webpack';
88
import { ExtensionRootDir } from '../constants';
99
import { getDefaultPlugins, nodeModulesToExternalize } from './common';
10+
import copyWebpackPlugin = require('copy-webpack-plugin');
1011

1112
const entryItems: Record<string, string> = {};
1213
nodeModulesToExternalize.forEach(moduleName => {
@@ -31,15 +32,20 @@ const config: webpack.Configuration = {
3132
loader: path.join(__dirname, 'loaders', 'fixEvalRequire.js')
3233
}
3334
]
34-
}
35+
}
3536
]
3637
},
3738
externals: [
3839
'vscode',
3940
'commonjs'
4041
],
4142
plugins: [
42-
...getDefaultPlugins('dependencies')
43+
...getDefaultPlugins('dependencies'),
44+
// vsls requires our package.json to be next to node_modules. It's how they
45+
// 'find' the calling extension.
46+
new copyWebpackPlugin([
47+
{ from: './package.json', to: '.' }
48+
])
4349
],
4450
resolve: {
4551
extensions: ['.js']

news/3 Code Health/4521.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add tests for live share support.

news/3 Code Health/4529.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix running liveshare support in a release build.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)