mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Reapply building of web server (#166391)
* Reapply building of web server
Revert 8b4642ab23
* Fix critical dep error
This commit is contained in:
@@ -121,7 +121,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string):
|
||||
{ ignore: ['**/node_modules'] }
|
||||
));
|
||||
|
||||
const webpackStreams = webpackConfigLocations.map(webpackConfigPath => {
|
||||
const webpackStreams = webpackConfigLocations.flatMap(webpackConfigPath => {
|
||||
|
||||
const webpackDone = (err: any, stats: any) => {
|
||||
fancyLog(`Bundled extension: ${ansiColors.yellow(path.join(path.basename(extensionPath), path.relative(extensionPath, webpackConfigPath)))}...`);
|
||||
@@ -137,29 +137,32 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string):
|
||||
}
|
||||
};
|
||||
|
||||
const webpackConfig = {
|
||||
...require(webpackConfigPath),
|
||||
...{ mode: 'production' }
|
||||
};
|
||||
const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path);
|
||||
const exportedConfig = require(webpackConfigPath);
|
||||
return (Array.isArray(exportedConfig) ? exportedConfig : [exportedConfig]).map(config => {
|
||||
const webpackConfig = {
|
||||
...config,
|
||||
...{ mode: 'production' }
|
||||
};
|
||||
const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path);
|
||||
|
||||
return webpackGulp(webpackConfig, webpack, webpackDone)
|
||||
.pipe(es.through(function (data) {
|
||||
data.stat = data.stat || {};
|
||||
data.base = extensionPath;
|
||||
this.emit('data', data);
|
||||
}))
|
||||
.pipe(es.through(function (data: File) {
|
||||
// source map handling:
|
||||
// * rewrite sourceMappingURL
|
||||
// * save to disk so that upload-task picks this up
|
||||
const contents = (<Buffer>data.contents).toString('utf8');
|
||||
data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) {
|
||||
return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`;
|
||||
}), 'utf8');
|
||||
return webpackGulp(webpackConfig, webpack, webpackDone)
|
||||
.pipe(es.through(function (data) {
|
||||
data.stat = data.stat || {};
|
||||
data.base = extensionPath;
|
||||
this.emit('data', data);
|
||||
}))
|
||||
.pipe(es.through(function (data: File) {
|
||||
// source map handling:
|
||||
// * rewrite sourceMappingURL
|
||||
// * save to disk so that upload-task picks this up
|
||||
const contents = (<Buffer>data.contents).toString('utf8');
|
||||
data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) {
|
||||
return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`;
|
||||
}), 'utf8');
|
||||
|
||||
this.emit('data', data);
|
||||
}));
|
||||
this.emit('data', data);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
es.merge(...webpackStreams, es.readArray(files))
|
||||
@@ -506,20 +509,14 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
|
||||
|
||||
for (const { configPath, outputRoot } of webpackConfigLocations) {
|
||||
const configOrFnOrArray = require(configPath);
|
||||
function addConfig(configOrFn: webpack.Configuration | Function) {
|
||||
let config;
|
||||
if (typeof configOrFn === 'function') {
|
||||
config = (configOrFn as Function)({}, {});
|
||||
function addConfig(configOrFnOrArray: webpack.Configuration | ((env: unknown, args: unknown) => webpack.Configuration) | webpack.Configuration[]) {
|
||||
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
|
||||
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;
|
||||
if (outputRoot) {
|
||||
config.output!.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output!.path!));
|
||||
}
|
||||
webpackConfigs.push(config);
|
||||
} else {
|
||||
config = configOrFn;
|
||||
}
|
||||
|
||||
if (outputRoot) {
|
||||
config.output.path = path.join(outputRoot, path.relative(path.dirname(configPath), config.output.path));
|
||||
}
|
||||
|
||||
webpackConfigs.push(configOrFn);
|
||||
}
|
||||
addConfig(configOrFnOrArray);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user