Skip to content

[pull] main from microsoft:main #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions build/lib/extensions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions build/lib/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string,
const packagedDependencies: string[] = [];
const packageJsonConfig = require(path.join(extensionPath, 'package.json'));
if (packageJsonConfig.dependencies) {
const webpackRootConfig = require(path.join(extensionPath, webpackConfigFileName));
const webpackRootConfig = require(path.join(extensionPath, webpackConfigFileName)).default;
for (const key in webpackRootConfig.externals) {
if (key in packageJsonConfig.dependencies) {
packagedDependencies.push(key);
Expand Down Expand Up @@ -145,7 +145,7 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string,
}
};

const exportedConfig = require(webpackConfigPath);
const exportedConfig = require(webpackConfigPath).default;
return (Array.isArray(exportedConfig) ? exportedConfig : [exportedConfig]).map(config => {
const webpackConfig = {
...config,
Expand Down Expand Up @@ -561,12 +561,12 @@ const extensionsPath = path.join(root, 'extensions');

// Additional projects to run esbuild on. These typically build code for webviews
const esbuildMediaScripts = [
'markdown-language-features/esbuild-notebook.js',
'markdown-language-features/esbuild-preview.js',
'markdown-math/esbuild.js',
'notebook-renderers/esbuild.js',
'ipynb/esbuild.js',
'simple-browser/esbuild-preview.js',
'markdown-language-features/esbuild-notebook.mjs',
'markdown-language-features/esbuild-preview.mjs',
'markdown-math/esbuild.mjs',
'notebook-renderers/esbuild.mjs',
'ipynb/esbuild.mjs',
'simple-browser/esbuild-preview.mjs',
];

export async function webpackExtensions(taskName: string, isWatch: boolean, webpackConfigLocations: { configPath: string; outputRoot?: string }[]) {
Expand All @@ -575,7 +575,7 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
const webpackConfigs: webpack.Configuration[] = [];

for (const { configPath, outputRoot } of webpackConfigLocations) {
const configOrFnOrArray = require(configPath);
const configOrFnOrArray = require(configPath).default;
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;
Expand All @@ -587,6 +587,7 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
}
addConfig(configOrFnOrArray);
}

function reporter(fullStats: any) {
if (Array.isArray(fullStats.children)) {
for (const stats of fullStats.children) {
Expand Down
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import pluginJsdoc from 'eslint-plugin-jsdoc';
import pluginHeader from 'eslint-plugin-header';
pluginHeader.rules.header.meta.schema = false;

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ignores = fs.readFileSync(path.join(__dirname, '.eslint-ignore'), 'utf8')
const ignores = fs.readFileSync(path.join(import.meta.dirname, '.eslint-ignore'), 'utf8')
.toString()
.split(/\r\n|\n/)
.filter(line => line && !line.startsWith('#'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import path from 'path';
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';

//@ts-check

'use strict';

const path = require('path');
const withBrowserDefaults = require('../shared.webpack.config').browser;

module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/configurationEditingMain.ts'
},
Expand All @@ -20,7 +16,7 @@ module.exports = withBrowserDefaults({
},
resolve: {
alias: {
'./node/net': path.resolve(__dirname, 'src', 'browser', 'net'),
'./node/net': path.resolve(import.meta.dirname, 'src', 'browser', 'net'),
}
}
});
Expand Down
12 changes: 4 additions & 8 deletions extensions/configuration-editing/extension.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import withDefaults from '../shared.webpack.config.mjs';

//@ts-check

'use strict';

const withDefaults = require('../shared.webpack.config');

module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/configurationEditingMain.ts',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
import path from 'path';

//@ts-check

'use strict';

const withBrowserDefaults = require('../shared.webpack.config').browser;
const path = require('path');

module.exports = withBrowserDefaults({
context: path.join(__dirname, 'client'),
export default withBrowserDefaults({
context: path.join(import.meta.dirname, 'client'),
entry: {
extension: './src/browser/cssClientMain.ts'
},
output: {
filename: 'cssClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'browser')
path: path.join(import.meta.dirname, 'client', 'dist', 'browser')
}
});
16 changes: 6 additions & 10 deletions extensions/css-language-features/extension.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import withDefaults from '../shared.webpack.config.mjs';
import path from 'path';

//@ts-check

'use strict';

const withDefaults = require('../shared.webpack.config');
const path = require('path');

module.exports = withDefaults({
context: path.join(__dirname, 'client'),
export default withDefaults({
context: path.join(import.meta.dirname, 'client'),
entry: {
extension: './src/node/cssClientMain.ts',
},
output: {
filename: 'cssClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'node')
path: path.join(import.meta.dirname, 'client', 'dist', 'node')
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import { browser as withBrowserDefaults } from '../../shared.webpack.config.mjs';
import path from 'path';

//@ts-check

'use strict';

const withBrowserDefaults = require('../../shared.webpack.config').browser;
const path = require('path');

module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/browser/cssServerWorkerMain.ts',
},
output: {
filename: 'cssServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
path: path.join(import.meta.dirname, 'dist', 'browser'),
libraryTarget: 'var',
library: 'serverExportVar'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import withDefaults from '../../shared.webpack.config.mjs';
import path from 'path';

//@ts-check

'use strict';

const withDefaults = require('../../shared.webpack.config');
const path = require('path');

module.exports = withDefaults({
context: path.join(__dirname),
export default withDefaults({
context: path.join(import.meta.dirname),
entry: {
extension: './src/node/cssServerNodeMain.ts',
},
output: {
filename: 'cssServerMain.js',
path: path.join(__dirname, 'dist', 'node'),
path: path.join(import.meta.dirname, 'dist', 'node'),
}
});
12 changes: 4 additions & 8 deletions extensions/debug-auto-launch/extension.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import withDefaults from '../shared.webpack.config.mjs';

//@ts-check

'use strict';

const withDefaults = require('../shared.webpack.config');

module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts',
},
Expand Down
12 changes: 4 additions & 8 deletions extensions/debug-server-ready/extension.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import withDefaults from '../shared.webpack.config.mjs';

//@ts-check

'use strict';

const withDefaults = require('../shared.webpack.config');

module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts',
},
Expand Down
13 changes: 4 additions & 9 deletions extensions/emmet/extension-browser.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';

//@ts-check

'use strict';

const withBrowserDefaults
= require('../shared.webpack.config').browser;

module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/browser/emmetBrowserMain.ts'
},
Expand Down
16 changes: 6 additions & 10 deletions extensions/emmet/extension.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
import path from 'path';

//@ts-check
import withDefaults from '../shared.webpack.config.mjs';

'use strict';

const path = require('path');

const withDefaults = require('../shared.webpack.config');

module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/node/emmetNodeMain.ts',
},
output: {
path: path.join(__dirname, 'dist', 'node'),
path: path.join(import.meta.dirname, 'dist', 'node'),
filename: 'emmetNodeMain.js'
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check

/**
* @fileoverview Common build script for extension scripts used in in webviews.
*/

const path = require('path');
const esbuild = require('esbuild');
import path from 'node:path';
import esbuild from 'esbuild';

/**
* @typedef {Partial<import('esbuild').BuildOptions> & {
Expand Down Expand Up @@ -62,7 +60,7 @@ async function tryBuild(options, didBuild) {
* @param {string[]} args
* @param {(outDir: string) => unknown} [didBuild]
*/
module.exports.run = async function (config, args, didBuild) {
export async function run(config, args, didBuild) {
let outdir = config.outdir;
const outputRootIndex = args.indexOf('--outputRoot');
if (outputRootIndex >= 0) {
Expand All @@ -84,10 +82,9 @@ module.exports.run = async function (config, args, didBuild) {
const isWatch = args.indexOf('--watch') >= 0;
if (isWatch) {
await tryBuild(resolvedOptions, didBuild);

const watcher = require('@parcel/watcher');
const watcher = await import('@parcel/watcher');
watcher.subscribe(config.srcDir, () => tryBuild(resolvedOptions, didBuild));
} else {
return build(resolvedOptions, didBuild).catch(() => process.exit(1));
}
};
}
Loading
Loading