Visual Studio 2019 将不会使用 webpack-source 构建 TypeScript

Ada*_*ter 5 javascript typescript webpack asp.net-core visual-studio-2019

我的问题似乎是 Visual Studio 正在尝试导入不应该导入的模块。这是我收到的错误。我正在尝试使用 Visual Studio 设置 Webpack。webpack 构建工作正常。Visual Studio TypeScript 构建失败。

Severity    Code    Description Project File    Line    Suppression State
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? Nester.MvcUI    C:\...\MvcUI\node_modules\@types\webpack-sources\lib\CachedSource.d.ts  3   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? Nester.MvcUI    C:\...\MvcUI\node_modules\@types\webpack-sources\lib\CompatSource.d.ts  1   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\ConcatSource.d.ts  4   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\OriginalSource.d.ts    4   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\PrefixSource.d.ts  1   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\RawSource.d.ts 1   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\ReplaceSource.d.ts 1   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\Source.d.ts    4   
Error   TS2792  Build:Cannot find module '.'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? MvcUI   C:\...\MvcUI\node_modules\@types\webpack-sources\lib\SourceMapSource.d.ts   3   

Run Code Online (Sandbox Code Playgroud)

所有代码行都是从“.”导入的

import { SourceLike } from '.';
Run Code Online (Sandbox Code Playgroud)

我找到了这个线程,但这个解决方案不起作用。VS Code 显示模块未找到,即使 WebPack 构建工作正常。如果我更改它,还会引发更多错误。

这是我的 tsconfig.json

{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "ES6",
    "module": "ES6",
    "jsx": "react",
    "allowJs": true,
    "outDir": "./tsdist/",
    "moduleResolution": "Classic"
  },
  "include": [
    "./TSApp/**/*"
  ],
  "exclude": [ "wwwroot", "node_modules" ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的 webpack.config.js

"use strict";
const { join } = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const { HotModuleReplacementPlugin } = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path')

module.exports = {
    entry: "./TSApp/file.ts",
    devtool: 'inline-source-map',
    output: {
        path: path.resolve("wwwroot/js"),
        filename: "site.js"
    },
    resolve: {
        alias: {
            vue: 'vue/dist/vue.esm-browser.js'
        },
        extensions: [ '.tsx', '.ts', '.js' ]
    },
    devServer: {
        contentBase: ".",
        host: "localhost",
        port: 9999
    },
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: "ts-loader"
            },
            {
                test: /\.vue$/,
                loader: "vue-loader"
            },
            {
                test: /\.(scss|css)$/,
                use: ["vue-style-loader", "css-loader", "sass-loader"]
            },
            {
                test: /\.s(c|a)ss$/,
                use: [
                    'vue-style-loader',
                    'css-loader',
                    {
                        loader: 'sass-loader',
                        // Requires sass-loader@^7.0.0
                        options: {
                            implementation: require('sass'),
                            indentedSyntax: true // optional
                        },
                        // Requires sass-loader@^8.0.0
                        options: {
                            implementation: require('sass'),
                            sassOptions: {
                                indentedSyntax: true // optional
                            },
                        },
                    },
                ],
            }
        ]
    },
    //loaders: [
    //    {
    //        test: /\.jsx?$/,
    //        loader: "babel-loader"
    //    }
    //],
    plugins: [
        //new CleanWebpackPlugin(),
        //new HtmlWebpackPlugin({
        //    template: "./src/index.html"
        //}),
        new VueLoaderPlugin(),
        new MiniCssExtractPlugin({
            filename: "css/[name].css"
        })
    ]
};
Run Code Online (Sandbox Code Playgroud)