我正在尝试在90% tsx 的代码库上添加带有typescript的热重载 . 为此,我正在关注https://github.com/TypeStrong/ts-loader/tree/master/examples/react-hot-boilerplate .

我已经添加

use: [
          { loader: 'ts-loader', options: { happyPackMode: true } }
],

所以我开始得到奇怪的编译错误:

./client/main.tsx中的错误// < - 我的入口点模块构建失败(来自./node_modules/ts-loader/index.js):TypeError:无法在Object.getEmitOutput处读取未定义的属性'getEmitOutput'( ...... / node_modules / TS-装载器/ DIST / instances.js:190:41)

不知道为什么......在我的依赖树上,有tsx,ts和js文件 . 没有这些选项,ts-loader就能成功编译 .

{
    "compilerOptions": {
        "allowJs": true,
        "checkJs": false,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "target": "es5",
        "jsx": "react",
        "lib": [
            "es2015",
            "es2016",
            "es2017",
            "dom",
            "es7"
        ],
        "downlevelIteration": true,
        "typeRoots": [
            "./@types"
        ],
        "sourceMap": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true
    },
    "include": [
        "./client/**/*",
        "./@types/**/*"
    ],
    "exclude": [
        ".svn"
    ]
}