diff --git a/extensions/json-language-features/extension.webpack.config.js b/extensions/json-language-features/extension.webpack.config.js index b5811e6f527..2e1d251fd33 100644 --- a/extensions/json-language-features/extension.webpack.config.js +++ b/extensions/json-language-features/extension.webpack.config.js @@ -9,7 +9,6 @@ const withDefaults = require('../shared.webpack.config'); const path = require('path'); -const webpack = require('webpack'); const config = withDefaults({ context: path.join(__dirname, 'client'), diff --git a/extensions/json-language-features/server/extension.webpack.config.js b/extensions/json-language-features/server/extension.webpack.config.js index f307e4408e1..2c2133ec895 100644 --- a/extensions/json-language-features/server/extension.webpack.config.js +++ b/extensions/json-language-features/server/extension.webpack.config.js @@ -9,7 +9,6 @@ const withDefaults = require('../../shared.webpack.config'); const path = require('path'); -const webpack = require('webpack'); const config = withDefaults({ context: path.join(__dirname), diff --git a/extensions/microsoft-authentication/extension.webpack.config.js b/extensions/microsoft-authentication/extension.webpack.config.js index e18229a8e17..a513ac5c3b5 100644 --- a/extensions/microsoft-authentication/extension.webpack.config.js +++ b/extensions/microsoft-authentication/extension.webpack.config.js @@ -7,7 +7,6 @@ 'use strict'; -const path = require('path'); const withDefaults = require('../shared.webpack.config'); module.exports = withDefaults({ diff --git a/extensions/npm/extension.webpack.config.js b/extensions/npm/extension.webpack.config.js index 1c6d9493e33..320956abe3d 100644 --- a/extensions/npm/extension.webpack.config.js +++ b/extensions/npm/extension.webpack.config.js @@ -7,8 +7,6 @@ 'use strict'; -const path = require('path'); - const withDefaults = require('../shared.webpack.config'); module.exports = withDefaults({ diff --git a/extensions/shared.webpack.config.js b/extensions/shared.webpack.config.js index cf069463962..73e5036c7fb 100644 --- a/extensions/shared.webpack.config.js +++ b/extensions/shared.webpack.config.js @@ -64,13 +64,13 @@ function withNodeDefaults(/**@type WebpackConfig*/extConfig) { }, // yes, really source maps devtool: 'source-map', - plugins: getDefaultNodePlugins(extConfig.context), + plugins: nodePlugins(extConfig.context), }; return merge(defaultConfig, extConfig); } -function getDefaultNodePlugins(context) { +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'); @@ -136,31 +136,30 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig) { }, // yes, really source maps devtool: 'source-map', - plugins: getDefaultBrowserPlugins() + plugins: browserPlugins }; return merge(defaultConfig, extConfig); } -function getDefaultBrowserPlugins() { - return [ - new CopyWebpackPlugin({ - patterns: [ - { from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true } - ] - }), - new DefinePlugin({ - 'process.env': JSON.stringify({}), - 'process.env.BROWSER_ENV': JSON.stringify('true') - }) - ]; -} +const browserPlugins = [ + new CopyWebpackPlugin({ + patterns: [ + { from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true } + ] + }), + new DefinePlugin({ + 'process.env': JSON.stringify({}), + 'process.env.BROWSER_ENV': JSON.stringify('true') + }) +]; + module.exports = withNodeDefaults; module.exports.node = withNodeDefaults; module.exports.browser = withBrowserDefaults; -module.exports.getNodePlugins = getDefaultNodePlugins; -module.exports.getBrowserPlugins = getDefaultBrowserPlugins; +module.exports.nodePlugins = nodePlugins; +module.exports.browserPlugins = browserPlugins; diff --git a/extensions/typescript-language-features/extension-browser.webpack.config.js b/extensions/typescript-language-features/extension-browser.webpack.config.js index a96e3fc8736..e7ad156bf94 100644 --- a/extensions/typescript-language-features/extension-browser.webpack.config.js +++ b/extensions/typescript-language-features/extension-browser.webpack.config.js @@ -9,9 +9,9 @@ const CopyPlugin = require('copy-webpack-plugin'); const Terser = require('terser'); -const defaultConnfig = require('../shared.webpack.config'); -const withBrowserDefaults = defaultConnfig.browser; -const getBrowserPlugins = defaultConnfig.getBrowserPlugins; +const defaultConfig = require('../shared.webpack.config'); +const withBrowserDefaults = defaultConfig.browser; +const browserPlugins = defaultConfig.browserPlugins; const languages = [ 'zh-tw', @@ -34,13 +34,8 @@ module.exports = withBrowserDefaults({ entry: { extension: './src/extension.browser.ts', }, - resolve: { - fallback: { - os: false - } - }, plugins: [ - ...getBrowserPlugins(), // add plugins, don't replace inherited + ...browserPlugins, // add plugins, don't replace inherited // @ts-ignore new CopyPlugin({