webpack v5

This commit is contained in:
Dovi Cowan 2022-10-07 17:10:20 +01:00
parent 00734145cd
commit 98f4f4ba74
No known key found for this signature in database
GPG key ID: CC028FE44C985E37
4 changed files with 32 additions and 7 deletions

3
.vscode/launch.json vendored
View file

@ -9,13 +9,14 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"sourceMaps": true,
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
"preLaunchTask": "${defaultBuildTask}",
},
{
"name": "Extension Tests",

7
.vscode/tasks.json vendored
View file

@ -28,6 +28,13 @@
"reveal": "never"
},
"group": "build"
},
{
"type": "npm",
"script": "pretest",
"problemMatcher": [],
"label": "npm: pretest",
"detail": "npm run test-compile && npm run lint"
}
]
}

View file

@ -14,7 +14,10 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
"experimentalDecorators": true
"experimentalDecorators": true,
"types": [
"node"
]
},
"exclude": [
"node_modules",

View file

@ -2,10 +2,16 @@
'use strict';
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const path = require('path');
const webpack = require('webpack');
/**@type {import('webpack').Configuration}*/
const config = {
node: {
__dirname: true
},
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
@ -14,16 +20,24 @@ const config = {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2'
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
devtool: 'nosources-source-map',
devtool: 'eval-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, 📖 -> https://webpack.js.org/configuration/externals/
},
resolve: {
// mainFields: ['browser', 'module', 'main'],
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
extensions: ['.ts', '.js'],
fallback: {
"fs": false
}
},
plugins: [
new NodePolyfillPlugin()
],
module: {
rules: [
{