Webpack 5 Typescript typings caching failed

Viewed 162

I have basic project with typescript it includes several ts files and html code. I'm trying to set rebuild with caching. I have to use file-based cache (it's a requirement). Issue is that after rebuild I can not find typings.

tsconfig.json

{
  "compilerOptions": {
    "outDir": "./build",
    "declarationDir": "./build/types",
    "moduleResolution": "node",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "declaration": true,
    "lib": [
      "es6",
      "es7",
      "dom"
    ]
  }
}

webpack config

module.exports = {
    entry: {index: "./src/index.ts"}, 
    cache: { type: 'filesystem' },
    ....

    output: {
        filename: "[name].js",
        libraryTarget: "commonjs2",
        path: path.resolve("./build"),
    },
    plugins: [
        new CleanWebpackPlugin(),
       ....
    ],
    
    module: {
        rules: [
            {
                test: /\.ts$/,
                include: /src/,
                use:
                    [
                        {
                            loader: 'ng-annotate-loader',
                            options: {
                                add: true
                            }
                        },
                        {
                            loader: 'ts-loader',
                            options: {
                                onlyCompileBundledFiles: true
                            }
                        },
                    ]
            },
            ....
        ]
    }
};

If I would do build I would have bundled js code on output + typings in 'types' folder. After rebuild types folder disappears. For webpack v4 it was working fine.

0 Answers
Related