From edc9685bcda26462dc52decce213167af8d2b25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20B=C3=A4umer?= Date: Mon, 8 Jul 2024 06:24:16 +0200 Subject: [PATCH] Bring back webpack config (#1897) --- client/webpack.config.js | 25 +++++++++++++++++ package.json | 6 ++-- server/webpack.config.js | 25 +++++++++++++++++ shared.webpack.config.js | 59 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 client/webpack.config.js create mode 100644 server/webpack.config.js create mode 100644 shared.webpack.config.js diff --git a/client/webpack.config.js b/client/webpack.config.js new file mode 100644 index 00000000..c61edc79 --- /dev/null +++ b/client/webpack.config.js @@ -0,0 +1,25 @@ +/*--------------------------------------------------------------------------------------------- + * 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'); + +module.exports = withDefaults({ + context: path.join(__dirname), + entry: { + extension: './src/extension.ts', + }, + resolve: { + symlinks: false + }, + output: { + filename: 'extension.js', + path: path.join(__dirname, 'out') + } +}); diff --git a/package.json b/package.json index ce628941..9e5ba6a0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-eslint", "displayName": "ESLint", "description": "Integrates ESLint JavaScript into VS Code.", - "version": "3.0.10", + "version": "3.0.11", "author": "Microsoft Corporation", "license": "MIT", "repository": { @@ -628,7 +628,9 @@ ] }, "scripts": { - "vscode:prepublish": "npm run esbuild", + "vscode:prepublish": "npm run webpack", + "webpack": "npm run clean && webpack --mode production --config ./client/webpack.config.js && webpack --mode production --config ./server/webpack.config.js", + "webpack:dev": "npm run clean && webpack --mode none --config ./client/webpack.config.js && webpack --mode none --config ./server/webpack.config.js", "esbuild": "npm run clean && node ./esbuild.js", "compile": "tsc -b", "compile:client": "tsc -b ./client/tsconfig.json", diff --git a/server/webpack.config.js b/server/webpack.config.js new file mode 100644 index 00000000..0e968695 --- /dev/null +++ b/server/webpack.config.js @@ -0,0 +1,25 @@ +/*--------------------------------------------------------------------------------------------- + * 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'); + +module.exports = withDefaults({ + context: path.join(__dirname), + entry: { + extension: './src/eslintServer.ts', + }, + resolve: { + symlinks: false + }, + output: { + filename: 'eslintServer.js', + path: path.join(__dirname, 'out') + } +}); diff --git a/shared.webpack.config.js b/shared.webpack.config.js new file mode 100644 index 00000000..b508f1df --- /dev/null +++ b/shared.webpack.config.js @@ -0,0 +1,59 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +//@ts-check +/** @typedef {import('webpack').Configuration} WebpackConfig **/ + +'use strict'; + +const path = require('path'); +const merge = require('merge-options'); + +module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) { + + /** @type WebpackConfig */ + let defaultConfig = { + mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + target: 'node', // extensions run in a node context + node: { + __dirname: false // leave the __dirname-behaviour intact + }, + resolve: { + conditionNames: ['import', 'require', 'node'], + mainFields: ['module', 'main'], + extensions: ['.ts', '.js'] // support ts-files and js-files + }, + module: { + rules: [{ + test: /\.ts$/, + exclude: /node_modules/, + use: [{ + // configure TypeScript loader: + // * enable sources maps for end-to-end source maps + loader: 'ts-loader', + options: { + compilerOptions: { + "sourceMap": true, + } + } + }] + }] + }, + externals: { + 'vscode': 'commonjs vscode', // ignored because it doesn't exist + }, + output: { + // all output goes into `dist`. + // packaging depends on that and this must always be like it + filename: '[name].js', + path: path.join(extConfig.context, 'out'), + libraryTarget: "commonjs", + }, + // yes, really source maps + devtool: 'source-map' + }; + + return merge(defaultConfig, extConfig); +};