wessberg / DI-compiler

A Custom Transformer for Typescript that enables compile-time Dependency Injection
MIT License
80 stars 7 forks source link

DI-compiler fails to build due to change in TypeScript and @wessberg/ts-config #28

Open cmidgley opened 3 months ago

cmidgley commented 3 months ago

In a somewhat recent release of TypeScript (I believe in some version around 5.2 but not sure) the rules for module/moduleResolution were tightened up. This causes DI-compiler to fail a build (pnpm build) with an error that module must be nodenext when moduleResolution is nodenext when using a fresh install of DI-compiler (latest TypeScript). The root cause is in @wessberg/ts-config where the following is set:

"moduleResolution": "nodenext",
"module": "esnext",

A workaround that resolves this build issue for just DI-compiler (though perhaps this is best resolved with some change to @wessberg/di-config) is to edit tsconfig.build.json and add moduleResolution: "node" to the compilerOptions:

{
    "extends": "./tsconfig.json",
    "include": [
        "src/**/*.*"
    ],
    "compilerOptions": {
        "declaration": true,
        "declarationMap": false,
        "moduleResolution": "node"
    }
}