question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack 5 cache - typings not cached

See original GitHub issue

Bug report

What is the current behavior? d.ts files are not emitted after removing the output folder and running webpack again. I use ts-loader and have set declaration: true and outDir: ‘dist’ in tsconfig.json.

If the current behavior is a bug, please provide the steps to reproduce.

Run webpack build for the first time - bundle.js and typings are emitted. Remove ‘dist’ folder and run webpack again.

webpack.config.js:

{
  mode: isDevelopment ? 'development' : 'production',
  entry: {
    main: ['./src/index.tsx'],
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    publicPath: '/',
  },
  cache: {
    type: 'filesystem',
    buildDependencies: {
      sources: [path.resolve(process.cwd(), 'src') + '/'],
      tsConfig: [path.resolve(process.cwd(), 'tsconfig.json')],
      config: [__filename]
    },
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        include: path.join(__dirname, 'src'),
        use: {
          loader: 'ts-loader'
        }
      },
      {
        test: /\.jsx?$/,
        include: path.join(__dirname, 'src'),
        use: 'babel-loader',
      },
    ],
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
  },
};

What is the expected behavior? I expect idempotent behavior - set of files emitted by webpack build is the same regardless if the cache is utilized or not.

Other relevant information: webpack version: 5.37.1 Node.js version: 14.15.4 Operating System: Ubuntu 20.04 Additional tools: ts-loader: 9.2.2, typescript: 4.0.3


This issue was moved from webpack/webpack#13465 by @alexander-akait. Original issue was by @MBelniak.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
johnnyreillycommented, Sep 5, 2022

Reopened - if anyone would like to work on it that’s great. I’m not planning to myself, so we’ll need someone to step up if they want this to progress

1reaction
johnnyreillycommented, May 28, 2021

If you’d like to look at this I’d be happy to look at the PR!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache - webpack
Webpack will avoid hashing and timestamping them, assume the version is unique and will use it as a snapshot (for both memory and...
Read more >
Webpack 5 Typescript typings caching failed - Stack Overflow
I have to use file-based cache (it's a requirement). Issue is that after rebuild I can not find typings. tsconfig.json
Read more >
Improving Webpack Performance via Caching
Note: as of this writing, file system caching did not work completely with Webpack development builds — it would cause periodic rebuilds ...
Read more >
Long-term caching of static assets with Webpack - codeburst
The second issue is how webpack requires modules: by default the order of modules in the bundle isn't deterministic for the same set...
Read more >
webpack/webpack - Gitter
And the build is not caching (it always reads [emitted] for both sub-projects). ... Hi All! I'm trying to setup webpack 5 library...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found