React-hot-reload with typescript

1k Views Asked by At

I'm trying to add hot-reload with typescript on a codebase that is 90% tsx. For that, i'm following https://github.com/TypeStrong/ts-loader/tree/master/examples/react-hot-boilerplate.

I've added

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

So i started to get weird compilation errors:

ERROR in ./client/main.tsx // <-- my entrypoint

Module build failed (from ./node_modules/ts-loader/index.js): TypeError: Cannot read property 'getEmitOutput' of undefined at Object.getEmitOutput (....../node_modules/ts-loader/dist/instances.js:190:41)

No idea why... On my dependency tree, there are tsx, ts and also js files. Without these options, ts-loader compiles successfully.

{
    "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"
    ]
}
0

There are 0 best solutions below