Use the new loader format for web selfhost (#130592)
* Update workbench html and bump distro * Bump distro * Add web node paths to the build task too * Split task for reuse * Bump distro
This commit is contained in:
parent
2ee9010437
commit
279c4d8fcb
|
@ -14,6 +14,7 @@ const compilation = require('./lib/compilation');
|
||||||
const compileBuildTask = task.define('compile-build',
|
const compileBuildTask = task.define('compile-build',
|
||||||
task.series(
|
task.series(
|
||||||
util.rimraf('out-build'),
|
util.rimraf('out-build'),
|
||||||
|
util.buildWebNodePaths('out-build'),
|
||||||
compilation.compileTask('src', 'out-build', true)
|
compilation.compileTask('src', 'out-build', true)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,10 +16,10 @@ const { monacoTypecheckTask/* , monacoTypecheckWatchTask */ } = require('./gulpf
|
||||||
const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions');
|
const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions');
|
||||||
|
|
||||||
// Fast compile for development time
|
// Fast compile for development time
|
||||||
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths(), compilation.compileTask('src', 'out', false)));
|
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.compileTask('src', 'out', false)));
|
||||||
gulp.task(compileClientTask);
|
gulp.task(compileClientTask);
|
||||||
|
|
||||||
const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths(), compilation.watchTask('out', false)));
|
const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.watchTask('out', false)));
|
||||||
gulp.task(watchClientTask);
|
gulp.task(watchClientTask);
|
||||||
|
|
||||||
// All
|
// All
|
||||||
|
|
|
@ -274,7 +274,7 @@ function getElectronVersion() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
exports.getElectronVersion = getElectronVersion;
|
exports.getElectronVersion = getElectronVersion;
|
||||||
function buildWebNodePaths() {
|
function buildWebNodePaths(outDir) {
|
||||||
const result = () => new Promise((resolve, _) => {
|
const result = () => new Promise((resolve, _) => {
|
||||||
var _a;
|
var _a;
|
||||||
const root = path.join(__dirname, '..', '..');
|
const root = path.join(__dirname, '..', '..');
|
||||||
|
@ -300,7 +300,7 @@ function buildWebNodePaths() {
|
||||||
nodePaths[key] = entryPoint;
|
nodePaths[key] = entryPoint;
|
||||||
}
|
}
|
||||||
// Now we write the node paths to out/vs
|
// Now we write the node paths to out/vs
|
||||||
const outDirectory = path.join(root, 'out', 'vs');
|
const outDirectory = path.join(root, outDir, 'vs');
|
||||||
fs.mkdirSync(outDirectory, { recursive: true });
|
fs.mkdirSync(outDirectory, { recursive: true });
|
||||||
const headerWithGeneratedFileWarning = `/*---------------------------------------------------------------------------------------------
|
const headerWithGeneratedFileWarning = `/*---------------------------------------------------------------------------------------------
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
|
@ -341,32 +341,37 @@ export function getElectronVersion(): string {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildWebNodePaths() {
|
export function acquireWebNodePaths() {
|
||||||
|
const root = path.join(__dirname, '..', '..');
|
||||||
|
const webPackageJSON = path.join(root, '/remote/web', 'package.json');
|
||||||
|
const webPackages = JSON.parse(fs.readFileSync(webPackageJSON, 'utf8')).dependencies;
|
||||||
|
const nodePaths: { [key: string]: string } = {};
|
||||||
|
for (const key of Object.keys(webPackages)) {
|
||||||
|
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
|
||||||
|
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
|
||||||
|
let entryPoint = packageData.browser ?? packageData.main;
|
||||||
|
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
|
||||||
|
if (!entryPoint) {
|
||||||
|
console.warn(`No entry point for ${key} assuming dist/${key}.min.js`);
|
||||||
|
entryPoint = `dist/${key}.min.js`;
|
||||||
|
}
|
||||||
|
// Remove any starting path information so it's all relative info
|
||||||
|
if (entryPoint.startsWith('./')) {
|
||||||
|
entryPoint = entryPoint.substr(2);
|
||||||
|
} else if (entryPoint.startsWith('/')) {
|
||||||
|
entryPoint = entryPoint.substr(1);
|
||||||
|
}
|
||||||
|
nodePaths[key] = entryPoint;
|
||||||
|
}
|
||||||
|
return nodePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildWebNodePaths(outDir: string) {
|
||||||
const result = () => new Promise<void>((resolve, _) => {
|
const result = () => new Promise<void>((resolve, _) => {
|
||||||
const root = path.join(__dirname, '..', '..');
|
const root = path.join(__dirname, '..', '..');
|
||||||
const webPackageJSON = path.join(root, '/remote/web', 'package.json');
|
const nodePaths = acquireWebNodePaths();
|
||||||
const webPackages = JSON.parse(fs.readFileSync(webPackageJSON, 'utf8')).dependencies;
|
|
||||||
const nodePaths: { [key: string]: string } = {};
|
|
||||||
for (const key of Object.keys(webPackages)) {
|
|
||||||
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
|
|
||||||
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
|
|
||||||
let entryPoint = packageData.browser ?? packageData.main;
|
|
||||||
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
|
|
||||||
if (!entryPoint) {
|
|
||||||
console.warn(`No entry point for ${key} assuming dist/${key}.min.js`);
|
|
||||||
entryPoint = `dist/${key}.min.js`;
|
|
||||||
}
|
|
||||||
// Remove any starting path information so it's all relative info
|
|
||||||
if (entryPoint.startsWith('./')) {
|
|
||||||
entryPoint = entryPoint.substr(2);
|
|
||||||
} else if (entryPoint.startsWith('/')) {
|
|
||||||
entryPoint = entryPoint.substr(1);
|
|
||||||
}
|
|
||||||
nodePaths[key] = entryPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we write the node paths to out/vs
|
// Now we write the node paths to out/vs
|
||||||
const outDirectory = path.join(root, 'out', 'vs');
|
const outDirectory = path.join(root, outDir, 'vs');
|
||||||
fs.mkdirSync(outDirectory, { recursive: true });
|
fs.mkdirSync(outDirectory, { recursive: true });
|
||||||
const headerWithGeneratedFileWarning = `/*---------------------------------------------------------------------------------------------
|
const headerWithGeneratedFileWarning = `/*---------------------------------------------------------------------------------------------
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "code-oss-dev",
|
"name": "code-oss-dev",
|
||||||
"version": "1.60.0",
|
"version": "1.60.0",
|
||||||
"distro": "1a48bc9e1d4b74944a0721212e078bf24b2cbf79",
|
"distro": "0daa48b9b8ac455e8d47a401b305cbd093b8c375",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Microsoft Corporation"
|
"name": "Microsoft Corporation"
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,11 @@
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<!-- Startup (do not modify order of script tags!) -->
|
<!-- Startup (do not modify order of script tags!) -->
|
||||||
|
<script src="./static/out/vs/webPackagePaths.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
Object.keys(self.webPackagePaths).map(function (key, index) {
|
||||||
|
self.webPackagePaths[key] = `${window.location.origin}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
|
||||||
|
});
|
||||||
self.require = {
|
self.require = {
|
||||||
baseUrl: `${window.location.origin}/static/out`,
|
baseUrl: `${window.location.origin}/static/out`,
|
||||||
recordStats: true,
|
recordStats: true,
|
||||||
|
@ -40,19 +44,7 @@
|
||||||
throw new Error(`Invalid script url: ${value}`)
|
throw new Error(`Invalid script url: ${value}`)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
paths: {
|
paths: self.webPackagePaths
|
||||||
'@microsoft/applicationinsights-web': `${window.location.origin}/static/remote/web/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js`,
|
|
||||||
'@vscode/vscode-languagedetection': `${window.location.origin}/static/remote/web/node_modules/@vscode/vscode-languagedetection/dist/lib/index.js`,
|
|
||||||
'vscode-textmate': `${window.location.origin}/static/remote/web/node_modules/vscode-textmate/release/main`,
|
|
||||||
'vscode-oniguruma': `${window.location.origin}/static/remote/web/node_modules/vscode-oniguruma/release/main`,
|
|
||||||
'xterm': `${window.location.origin}/static/remote/web/node_modules/xterm/lib/xterm.js`,
|
|
||||||
'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
|
|
||||||
'xterm-addon-unicode11': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,
|
|
||||||
'xterm-addon-webgl': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
|
|
||||||
'tas-client-umd': `${window.location.origin}/static/remote/web/node_modules/tas-client-umd/lib/tas-client-umd.js`,
|
|
||||||
'iconv-lite-umd': `${window.location.origin}/static/remote/web/node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`,
|
|
||||||
'jschardet': `${window.location.origin}/static/remote/web/node_modules/jschardet/dist/jschardet.min.js`,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script src="./static/out/vs/loader.js"></script>
|
<script src="./static/out/vs/loader.js"></script>
|
||||||
|
|
|
@ -27,7 +27,11 @@
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<!-- Startup (do not modify order of script tags!) -->
|
<!-- Startup (do not modify order of script tags!) -->
|
||||||
|
<script src="./static/out/vs/webPackagePaths.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
Object.keys(self.webPackagePaths).map(function (key, index) {
|
||||||
|
self.webPackagePaths[key] = `${window.location.origin}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
|
||||||
|
});
|
||||||
self.require = {
|
self.require = {
|
||||||
baseUrl: `${window.location.origin}/static/out`,
|
baseUrl: `${window.location.origin}/static/out`,
|
||||||
recordStats: true,
|
recordStats: true,
|
||||||
|
@ -39,19 +43,7 @@
|
||||||
throw new Error(`Invalid script url: ${value}`)
|
throw new Error(`Invalid script url: ${value}`)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
paths: {
|
paths: self.webPackagePaths
|
||||||
'@microsoft/applicationinsights-web': `${window.location.origin}/static/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js`,
|
|
||||||
'@vscode/vscode-languagedetection': `${window.location.origin}/static/node_modules/@vscode/vscode-languagedetection/dist/lib/index.js`,
|
|
||||||
'vscode-textmate': `${window.location.origin}/static/node_modules/vscode-textmate/release/main`,
|
|
||||||
'vscode-oniguruma': `${window.location.origin}/static/node_modules/vscode-oniguruma/release/main`,
|
|
||||||
'xterm': `${window.location.origin}/static/node_modules/xterm/lib/xterm.js`,
|
|
||||||
'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
|
|
||||||
'xterm-addon-unicode11': `${window.location.origin}/static/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,
|
|
||||||
'xterm-addon-webgl': `${window.location.origin}/static/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
|
|
||||||
'tas-client-umd': `${window.location.origin}/static/node_modules/tas-client-umd/lib/tas-client-umd.js`,
|
|
||||||
'iconv-lite-umd': `${window.location.origin}/static/node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`,
|
|
||||||
'jschardet': `${window.location.origin}/static/node_modules/jschardet/dist/jschardet.min.js`,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script src="./static/out/vs/loader.js"></script>
|
<script src="./static/out/vs/loader.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue