mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Dynamically generate web package paths
This commit is contained in:
@@ -71,6 +71,7 @@ for (let dir of dirs) {
|
||||
|
||||
yarnInstall(dir, opts);
|
||||
}
|
||||
buildWebNodePaths();
|
||||
|
||||
function yarnInstallBuildDependencies() {
|
||||
// make sure we install the deps of build/lib/watch for the system installed
|
||||
@@ -90,5 +91,40 @@ runtime "${runtime}"`;
|
||||
yarnInstall(watchPath);
|
||||
}
|
||||
|
||||
function buildWebNodePaths() {
|
||||
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 = new Object(null);
|
||||
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
|
||||
const outDirectory = path.join(root, 'out', 'vs');
|
||||
const headerWithGeneratedFileWarning = `/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// This file is generated by build/npm/postinstall.js. Do not edit.`;
|
||||
const fileContents = `${headerWithGeneratedFileWarning}\nself.webPackagePaths = ${JSON.stringify(nodePaths, null, 2)};`;
|
||||
fs.writeFileSync(path.join(outDirectory, 'webPackagePaths.js'), fileContents, 'utf8');
|
||||
}
|
||||
|
||||
cp.execSync('git config pull.rebase merges');
|
||||
cp.execSync('git config blame.ignoreRevsFile .git-blame-ignore');
|
||||
|
||||
Reference in New Issue
Block a user