Repository navigation
|
Hi, I am trying to setup webpack on my org's internal vscode extension which uses the zowe node SDKs and zowe explorer API, to reduce extension install size and reduce load times. However, I am getting a bunch of warnings about In the listed source code, I am not using any require statements, so I'm not sure why I am getting these. Here is my // FILE COPIED AND MODIFIED FROM: https://code.visualstudio.com/api/working-with-extensions/bundling-extension#configure-webpack
//@ts-check
'use strict';
const path = require('path');
/**@type {import('webpack').Configuration}*/
const config = {
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: {
// 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',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
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, 📖 -> https://webpack.js.org/configuration/externals/
'@zowe/cli': 'commonjs @zowe/cli',
'cpu-features': 'commonjs cpu-features',
'keytar': 'commonjs keytar',
'./crypto/build/Release/sshcrypto.node': 'commonjs ./crypto/build/Release/sshcrypto.node'
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
},
{
test: /\.js/,
include: /wontache/, // https://gitlab.com/jgonggrijp/wontache/-/issues/68
type: "javascript/auto",
}
]
}
};
module.exports = config;I have some other excluded externals such as and the relevant bits from my "scripts": {
"vscode:prepublish": "npm run package",
"compile": "webpack --mode development",
"watch": "webpack --mode development --watch",
"package": "webpack --mode production --devtool hidden-source-map && npm run copy-webviews",
"lint": "eslint \"src/**/*.ts\"",
"copy-webviews": "copyfiles -u 1 src/webviews/**/* dist && copyfiles walkthroughs/**/* dist"
},
"engines": {
"vscode": "^1.95.0"
},
"dependencies": {
"@types/node": "^20",
"@types/vscode": "^1.95.0",
"@types/vscode-webview": "^1.57.0",
"@zowe/imperative": "^8.10.3",
"@zowe/zos-files-for-zowe-sdk": "^8.8.4",
"@zowe/zos-jobs-for-zowe-sdk": "^8.8.4",
"@zowe/zos-tso-for-zowe-sdk": "8.12.0",
"@zowe/zowe-explorer-api": "^3.0.3"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@stylistic/eslint-plugin": "^2.9.0",
"copyfiles": "^2.4.1",
"eslint": "^9.13.0",
"ts-loader": "^9.5.4",
"typescript": "^5.7.2",
"typescript-eslint": "^8.16.0",
"webpack": "^5.103.0",
"webpack-cli": "^6.0.1"
}Any advice? Thanks |
Replies: 1 comment 4 replies
|
A bit of a d'oh moment, I just added |
I don't think these warnings are as "critical" as Webpack makes them sound. I've seen them several times when packaging Imperative with VS Code extensions, but they've never caused a runtime issue. And for more severe dependency bundling issues, Webpack should flag them as errors rather than warnings.
For Zowe Explorer and the Zowe Remote SSH extensions, we've chosen to disable these warnings:
https://github.com/zowe/zowe-explorer-vscode/blob/35c10eb59a4cfaed7476966fb0987ef92df5391f/packages/zowe-explorer/webpack.config.js#L43-L45
https://github.com/zowe/zowe-native-proto/blob/d42f3ef4a68c82e8533345a001525a3ad66a0f6a/packages/vsce/rspack.config.js#L68-L70