Skip to content

Commit

Permalink
Treat webpack warnings as errors
Browse files Browse the repository at this point in the history
This should prevent accidental regression related to use of webpack.

Related: #748
  • Loading branch information
ssbarnea committed Jan 4, 2023
1 parent 9480097 commit a815179
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"vscode-extension-tester": "^5.2.1",
"warnings-to-errors-webpack-plugin": "^2.3.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"yarn-audit-fix": "^9.3.7"
Expand Down
62 changes: 32 additions & 30 deletions webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
"use strict";
const WarningsToErrorsPlugin = require("warnings-to-errors-webpack-plugin");

/* eslint @typescript-eslint/no-var-requires: "off" */
const path = require("path");

const config = {
mode: "none",
stats: {
preset: "minimal",
moduleTrace: true,
errorDetails: true,
},
target: "node", // vscode extensions run in a Node.js-context
node: {
__dirname: false, // leave the __dirname-behavior intact
},
devtool: "source-map",
entry: {
client: "./src/extension.ts",
server:
"./node_modules/@ansible/ansible-language-server/out/server/src/server.js",
},
output: {
filename: (pathData: { chunk: { name: string } }) => {
return pathData.chunk.name === "client"
? "[name]/src/extension.js"
: "[name]/src/[name].js";
},
path: path.resolve(__dirname, "out"),
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: (info: { id: string }) => {
return info.id === "client"
? "../[resource-path]"
: "../../../[resource-path]";
},
},
// stats: 'verbose', // doesn't help with watcher
devtool: "source-map",
externals: {
vscode: "commonjs vscode", // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed
},
resolve: {
// support reading TypeScript and JavaScript files
extensions: [".ts", ".js"],
},
mode: "none",
module: {
rules: [
{
Expand All @@ -62,6 +36,34 @@ const config = {
},
],
},
node: {
__dirname: false, // leave the __dirname-behavior intact
},
output: {
filename: (pathData: { chunk: { name: string } }) => {
return pathData.chunk.name === "client"
? "[name]/src/extension.js"
: "[name]/src/[name].js";
},
path: path.resolve(__dirname, "out"),
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: (info: { id: string }) => {
return info.id === "client"
? "../[resource-path]"
: "../../../[resource-path]";
},
},
plugins: [new WarningsToErrorsPlugin()],
resolve: {
// support reading TypeScript and JavaScript files
extensions: [".ts", ".js"],
},
stats: {
errorDetails: true,
moduleTrace: true,
preset: "minimal",
},
target: "node", // vscode extensions run in a Node.js-context
};

module.exports = config;
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ __metadata:
untildify: ^4.0.0
vscode-extension-tester: ^5.2.1
vscode-languageclient: ^8.0.2
warnings-to-errors-webpack-plugin: ^2.3.0
webpack: ^5.75.0
webpack-cli: ^5.0.1
yaml: ^2.2.1
Expand Down Expand Up @@ -6540,6 +6541,15 @@ __metadata:
languageName: node
linkType: hard

"warnings-to-errors-webpack-plugin@npm:^2.3.0":
version: 2.3.0
resolution: "warnings-to-errors-webpack-plugin@npm:2.3.0"
peerDependencies:
webpack: ^2.2.0-rc || ^3 || ^4 || ^5
checksum: fb575eeb013d71bc2ba7419a8221855168a87d3cdb062e7014aff9ed3fddec56ec695915115249555f51931aa9ed786df95e65c3611e78dd71a42ca55cc839d6
languageName: node
linkType: hard

"watchpack@npm:^2.4.0":
version: 2.4.0
resolution: "watchpack@npm:2.4.0"
Expand Down

0 comments on commit a815179

Please sign in to comment.