使用 webpack 编译 VSCode 扩展现在在 2 年之前编译没有问题后失败

问题描述 投票:0回答:0

我来重新编译一个 VSCode 扩展,现在它失败了,出现了这个错误:

我没有在我的代码中使用 wontache(似乎是一个 mustache 模块),但它正在被我正在使用的另一个包使用,并且我在这次编译尝试之前升级到了它。

然后我尝试将节点更新到 V18 并将 Webpack 更新到更新的版本,但错误仍然存在。

我不知道如何解决这个错误。希望能得到一些启发! 我不知道要提供哪些文件来帮助确定解决方案。 然而,这是作为入门者的 webpack.config.js:

"use strict";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

/**@type {import('webpack').Configuration}*/
const config = {
  target: "node", // vscode extensions run in a Node.js-context

  entry: "./src/extension.ts", // the entry point of this extension, 
  output: {
    // the bundle is stored in the 'dist' folder (check package.json) 
    // eslint-disable-next-line no-undef
    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, 
    keytar: "commonjs keytar",
  },

  stats: {
    // Ignore warnings
    warnings: false,
  },
  resolve: {
    // support reading TypeScript and JavaScript files, 
    extensions: [".ts", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "ts-loader",
            options: {
              compilerOptions: {
                module: "es6", // override `tsconfig.json` so that TypeScript emits native JavaScript modules.
              },
            },
          },
        ],
      },
    ],
  },
};
module.exports = config;
visual-studio-code webpack
© www.soinside.com 2019 - 2024. All rights reserved.