Convert extension webpack scripts to modules

This commit is contained in:
Matt Bierner
2025-08-07 17:20:22 -07:00
parent 86ff5cd43b
commit ed71020bfc
58 changed files with 303 additions and 527 deletions

View File

@@ -522,7 +522,7 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
const webpack = require('webpack');
const webpackConfigs = [];
for (const { configPath, outputRoot } of webpackConfigLocations) {
const configOrFnOrArray = require(configPath);
const configOrFnOrArray = require(configPath).default;
function addConfig(configOrFnOrArray) {
for (const configOrFn of Array.isArray(configOrFnOrArray) ? configOrFnOrArray : [configOrFnOrArray]) {
const config = typeof configOrFn === 'function' ? configOrFn({}, {}) : configOrFn;

View File

@@ -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;
@@ -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) {

View File

@@ -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';
'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'
},
@@ -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'),
}
}
});

View File

@@ -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';
'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',
},

View File

@@ -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';
'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')
}
});

View File

@@ -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';
'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')
}
});

View File

@@ -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';
'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'
}

View File

@@ -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';
'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'),
}
});

View File

@@ -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';
'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',
},

View File

@@ -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';
'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',
},

View File

@@ -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';
'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'
},

View File

@@ -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';
'use strict';
import withDefaults from '../shared.webpack.config.mjs';
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'
}
});

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extensionEditingBrowserMain.ts'
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extensionEditingMain.ts',
},

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts'
},

View File

@@ -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';
'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'
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
main: './src/main.ts',
['askpass-main']: './src/askpass-main.ts',

View File

@@ -2,27 +2,23 @@
* 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';
'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,
node: false,
entry: {
extension: './src/extension.ts',
},
resolve: {
alias: {
'uuid': path.resolve(__dirname, 'node_modules/uuid/dist/esm-browser/index.js'),
'./node/authServer': path.resolve(__dirname, 'src/browser/authServer'),
'./node/crypto': path.resolve(__dirname, 'src/browser/crypto'),
'./node/fetch': path.resolve(__dirname, 'src/browser/fetch'),
'./node/buffer': path.resolve(__dirname, 'src/browser/buffer'),
'uuid': path.resolve(import.meta.dirname, 'node_modules/uuid/dist/esm-browser/index.js'),
'./node/authServer': path.resolve(import.meta.dirname, 'src/browser/authServer'),
'./node/crypto': path.resolve(import.meta.dirname, 'src/browser/crypto'),
'./node/fetch': path.resolve(import.meta.dirname, 'src/browser/fetch'),
'./node/buffer': path.resolve(import.meta.dirname, 'src/browser/buffer'),
}
}
});

View File

@@ -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';
'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',
},

View File

@@ -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';
'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'
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
main: './src/main.ts',
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
main: './src/main.ts',
},

View File

@@ -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';
'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/htmlClientMain.ts'
},
output: {
filename: 'htmlClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'browser')
path: path.join(import.meta.dirname, 'client', 'dist', 'browser')
}
});

View File

@@ -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';
'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/htmlClientMain.ts',
},
output: {
filename: 'htmlClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'node')
path: path.join(import.meta.dirname, 'client', 'dist', 'node')
}
});

View File

@@ -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
'use strict';
const withBrowserDefaults = require('../../shared.webpack.config').browser;
const path = require('path');
import { browser as withBrowserDefaults } from '../../shared.webpack.config.mjs';
import path from 'path';
const serverConfig = withBrowserDefaults({
context: __dirname,
context: import.meta.dirname,
entry: {
extension: './src/browser/htmlServerWorkerMain.ts',
},
@@ -23,7 +19,7 @@ const serverConfig = withBrowserDefaults({
},
output: {
filename: 'htmlServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
path: path.join(import.meta.dirname, 'dist', 'browser'),
libraryTarget: 'var',
library: 'serverExportVar'
},
@@ -38,9 +34,9 @@ serverConfig.module.rules.push({
test: /javascriptLibs.ts$/,
use: [
{
loader: path.resolve(__dirname, 'build', 'javaScriptLibraryLoader.js')
loader: path.resolve(import.meta.dirname, 'build', 'javaScriptLibraryLoader.js')
}
]
});
module.exports = serverConfig;
export default serverConfig;

View File

@@ -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 withDefaults from '../../shared.webpack.config.mjs';
import path from 'path';
'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/htmlServerNodeMain.ts',
},
output: {
filename: 'htmlServerMain.js',
path: path.join(__dirname, 'dist', 'node'),
path: path.join(import.meta.dirname, 'dist', 'node'),
},
externals: {
'typescript': 'commonjs typescript'

View File

@@ -2,37 +2,33 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
const path = require('path');
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
import path from 'path';
const mainConfig = withBrowserDefaults({
context: __dirname,
context: import.meta.dirname,
entry: {
extension: './src/ipynbMain.browser.ts'
},
output: {
filename: 'ipynbMain.browser.js',
path: path.join(__dirname, 'dist', 'browser')
path: path.join(import.meta.dirname, 'dist', 'browser')
}
});
const workerConfig = withBrowserDefaults({
context: __dirname,
context: import.meta.dirname,
entry: {
notebookSerializerWorker: './src/notebookSerializerWorker.web.ts',
},
output: {
filename: 'notebookSerializerWorker.js',
path: path.join(__dirname, 'dist', 'browser'),
path: path.join(import.meta.dirname, 'dist', 'browser'),
libraryTarget: 'var',
library: 'serverExportVar'
},
});
module.exports = [mainConfig, workerConfig];
export default [mainConfig, workerConfig];

View File

@@ -2,25 +2,21 @@
* 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, { nodePlugins } from '../shared.webpack.config.mjs';
import path from 'path';
'use strict';
const withDefaults = require('../shared.webpack.config');
const path = require('path');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
['ipynbMain.node']: './src/ipynbMain.node.ts',
notebookSerializerWorker: './src/notebookSerializerWorker.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(import.meta.dirname, 'dist'),
filename: '[name].js'
},
plugins: [
...withDefaults.nodePlugins(__dirname), // add plugins, don't replace inherited
...nodePlugins(import.meta.dirname), // add plugins, don't replace inherited
]
});

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
main: './src/main.ts',
},

View File

@@ -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';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
const path = require('path');
module.exports = withBrowserDefaults({
export default withBrowserDefaults({
target: 'webworker',
context: path.join(__dirname, 'client'),
context: path.join(import.meta.dirname, 'client'),
entry: {
extension: './src/browser/jsonClientMain.ts'
},
output: {
filename: 'jsonClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'browser')
path: path.join(import.meta.dirname, 'client', 'dist', 'browser')
}
});

View File

@@ -2,24 +2,20 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
const path = require('path');
import withDefaults from '../shared.webpack.config.mjs';
import path from 'path';
const config = withDefaults({
context: path.join(__dirname, 'client'),
context: path.join(import.meta.dirname, 'client'),
entry: {
extension: './src/node/jsonClientMain.ts'
},
output: {
filename: 'jsonClientMain.js',
path: path.join(__dirname, 'client', 'dist', 'node')
path: path.join(import.meta.dirname, 'client', 'dist', 'node')
}
});
module.exports = config;
export default config;

View File

@@ -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';
'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/jsonServerWorkerMain.ts',
},
output: {
filename: 'jsonServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
path: path.join(import.meta.dirname, 'dist', 'browser'),
libraryTarget: 'var',
library: 'serverExportVar'
}

View File

@@ -2,23 +2,19 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
const withDefaults = require('../../shared.webpack.config');
const path = require('path');
import withDefaults from '../../shared.webpack.config.mjs';
import path from 'path';
const config = withDefaults({
context: path.join(__dirname),
context: path.join(import.meta.dirname),
entry: {
extension: './src/node/jsonServerNodeMain.ts',
},
output: {
filename: 'jsonServerMain.js',
path: path.join(__dirname, 'dist', 'node'),
path: path.join(import.meta.dirname, 'dist', 'node'),
}
});
module.exports = config;
export default config;

View File

@@ -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 CopyPlugin from 'copy-webpack-plugin';
import { browser, browserPlugins } from '../shared.webpack.config.mjs';
'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const { browserPlugins, browser } = require('../shared.webpack.config');
module.exports = browser({
context: __dirname,
export default browser({
context: import.meta.dirname,
entry: {
extension: './src/extension.browser.ts'
},
plugins: [
...browserPlugins(__dirname), // add plugins, don't replace inherited
...browserPlugins(import.meta.dirname), // add plugins, don't replace inherited
new CopyPlugin({
patterns: [
{

View File

@@ -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 CopyPlugin from 'copy-webpack-plugin';
import withDefaults, { nodePlugins } from '../shared.webpack.config.mjs';
'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},
@@ -19,7 +15,7 @@ module.exports = withDefaults({
extension: './src/extension.ts',
},
plugins: [
...withDefaults.nodePlugins(__dirname), // add plugins, don't replace inherited
...nodePlugins(import.meta.dirname), // add plugins, don't replace inherited
new CopyPlugin({
patterns: [
{

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts'
}

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts'
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/mergeConflictMain.ts'
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/mergeConflictMain.ts'
},

View File

@@ -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';
'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,
node: {
global: true,
__filename: false,
@@ -22,10 +18,10 @@ module.exports = withBrowserDefaults({
},
resolve: {
alias: {
'./node/authServer': path.resolve(__dirname, 'src/browser/authServer'),
'./node/buffer': path.resolve(__dirname, 'src/browser/buffer'),
'./node/fetch': path.resolve(__dirname, 'src/browser/fetch'),
'./node/authProvider': path.resolve(__dirname, 'src/browser/authProvider'),
'./node/authServer': path.resolve(import.meta.dirname, 'src/browser/authServer'),
'./node/buffer': path.resolve(import.meta.dirname, 'src/browser/buffer'),
'./node/fetch': path.resolve(import.meta.dirname, 'src/browser/fetch'),
'./node/authProvider': path.resolve(import.meta.dirname, 'src/browser/authProvider'),
}
}
});

View File

@@ -2,19 +2,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
import withDefaults, { nodePlugins } from '../shared.webpack.config.mjs';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import path from 'path';
const isWindows = process.platform === 'win32';
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts'
},
@@ -26,11 +22,11 @@ module.exports = withDefaults({
},
resolve: {
alias: {
'keytar': path.resolve(__dirname, 'packageMocks', 'keytar', 'index.js')
'keytar': path.resolve(import.meta.dirname, 'packageMocks', 'keytar', 'index.js')
}
},
plugins: [
...withDefaults.nodePlugins(__dirname),
...nodePlugins(import.meta.dirname),
new CopyWebpackPlugin({
patterns: [
{

View File

@@ -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
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
const config = withBrowserDefaults({
context: __dirname,
context: import.meta.dirname,
entry: {
extension: './src/npmBrowserMain.ts'
},
@@ -24,4 +20,4 @@ const config = withBrowserDefaults({
}
});
module.exports = config;
export default config;

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/npmMain.ts',
},

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/phpMain.ts',
},

View File

@@ -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';
'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/extension.ts'
},
output: {
filename: 'extension.js',
path: path.join(__dirname, 'dist')
path: path.join(import.meta.dirname, 'dist')
}
});

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -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';
'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/extension.ts'
},
output: {
filename: 'extension.js',
path: path.join(__dirname, 'dist')
path: path.join(import.meta.dirname, 'dist')
}
});

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -2,17 +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 path from 'node:path';
import fs from 'node:fs';
import merge from 'merge-options';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import webpack from 'webpack';
import { createRequire } from 'node:module';
/** @typedef {import('webpack').Configuration} WebpackConfig **/
'use strict';
const path = require('path');
const fs = require('fs');
const merge = require('merge-options');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { DefinePlugin, optimize } = require('webpack');
const require = createRequire(import.meta.url);
const tsLoaderOptions = {
compilerOptions: {
@@ -48,7 +48,7 @@ function withNodeDefaults(/**@type WebpackConfig & { context: string }*/extConfi
loader: 'ts-loader',
options: tsLoaderOptions
}, {
loader: path.resolve(__dirname, 'mangle-loader.js'),
loader: path.resolve(import.meta.dirname, 'mangle-loader.js'),
options: {
configFile: path.join(extConfig.context, 'tsconfig.json')
},
@@ -85,8 +85,8 @@ function withNodeDefaults(/**@type WebpackConfig & { context: string }*/extConfi
*/
function nodePlugins(context) {
// Need to find the top-most `package.json` file
const folderName = path.relative(__dirname, context).split(/[\\\/]/)[0];
const pkgPath = path.join(__dirname, folderName, 'package.json');
const folderName = path.relative(import.meta.dirname, context).split(/[\\\/]/)[0];
const pkgPath = path.join(import.meta.dirname, folderName, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const id = `${pkg.publisher}.${pkg.name}`;
return [
@@ -136,7 +136,7 @@ function withBrowserDefaults(/**@type WebpackConfig & { context: string }*/extCo
}
},
{
loader: path.resolve(__dirname, 'mangle-loader.js'),
loader: path.resolve(import.meta.dirname, 'mangle-loader.js'),
options: {
configFile: path.join(extConfig.context, additionalOptions?.configFile ?? 'tsconfig.json')
},
@@ -184,7 +184,7 @@ function browserPlugins(context) {
// const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
// const id = `${pkg.publisher}.${pkg.name}`;
return [
new optimize.LimitChunkCountPlugin({
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
new CopyWebpackPlugin({
@@ -192,7 +192,7 @@ function browserPlugins(context) {
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
]
}),
new DefinePlugin({
new webpack.DefinePlugin({
'process.platform': JSON.stringify('web'),
'process.env': JSON.stringify({}),
'process.env.BROWSER_ENV': JSON.stringify('true')
@@ -200,8 +200,5 @@ function browserPlugins(context) {
];
}
module.exports = withNodeDefaults;
module.exports.node = withNodeDefaults;
module.exports.browser = withBrowserDefaults;
module.exports.nodePlugins = nodePlugins;
module.exports.browserPlugins = browserPlugins;
export default withNodeDefaults;
export { withNodeDefaults as node, withBrowserDefaults as browser, nodePlugins, browserPlugins };

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.ts'
}

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -2,14 +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
'use strict';
import withDefaults from '../shared.webpack.config.mjs';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
entry: {
extension: './src/terminalSuggestMain.ts'
},

View File

@@ -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';
'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',
},

View File

@@ -2,16 +2,10 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const defaultConfig = require('../shared.webpack.config');
const withBrowserDefaults = defaultConfig.browser;
const browserPlugins = defaultConfig.browserPlugins;
import CopyPlugin from 'copy-webpack-plugin';
import path from 'path';
import defaultConfig, { browser as withBrowserDefaults, browserPlugins } from '../shared.webpack.config.mjs';
const languages = [
'zh-tw',
@@ -28,13 +22,13 @@ const languages = [
'tr',
'zh-cn',
];
module.exports = [withBrowserDefaults({
context: __dirname,
export default [withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.browser.ts',
},
plugins: [
...browserPlugins(__dirname), // add plugins, don't replace inherited
...browserPlugins(import.meta.dirname), // add plugins, don't replace inherited
// @ts-ignore
new CopyPlugin({
@@ -63,7 +57,7 @@ module.exports = [withBrowserDefaults({
}),
],
}), withBrowserDefaults({
context: __dirname,
context: import.meta.dirname,
entry: {
'typescript/tsserver.web': './web/src/webServer.ts'
},
@@ -75,7 +69,7 @@ module.exports = [withBrowserDefaults({
// all output goes into `dist`.
// packaging depends on that and this must always be like it
filename: '[name].js',
path: path.join(__dirname, 'dist', 'browser'),
path: path.join(import.meta.dirname, 'dist', 'browser'),
libraryTarget: undefined,
},
externals: {

View File

@@ -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';
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
export default withDefaults({
context: import.meta.dirname,
resolve: {
mainFields: ['module', 'main']
},

View File

@@ -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 { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
'use strict';
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
context: __dirname,
export default withBrowserDefaults({
context: import.meta.dirname,
entry: {
extension: './src/extension.browser.ts'
},