Skip to content

Webpack cache compatibility problem #16

@constgen

Description

@constgen

When Webpack cache is enabled and file is moved in the file system in such way the its import path is changed in the index.js (barrel) file an error is thrown on the next build

ERROR in ./src/components/Demo/index.js 16:0-119
Module not found: Error: Can't resolve 'C:\Projects\Project_Name\src\components\Common\Choose\ChooseMoney.js' in 'C:\Projects\Project_Name\src\components\Demo'

The issue is relayted somehow to Weback cache invalidation that doesn't happen

Webpack config (partial)

{
cache: {
  type: "filesystem",
  cacheDirectory: path.resolve(__dirname, ".cache/webpack"),
  compression: "brotli",
  maxAge: ONE_WEEK,
  maxMemoryGenerations: Infinity,
  memoryCacheUnaffected: false,
  buildDependencies: {
    // This makes all dependencies of this file - build dependencies
    config: [__filename]
    // By default webpack and loaders are build dependencies
  }
}
experiments: {
  cacheUnaffected: true
},
snapshot: {
  managedPaths: [path.resolve(__dirname, "./node_modules")],
  buildDependencies: {
    hash: true,
    timestamp: true
  },
  module: {
    hash: true,
    timestamp: true
  },
  resolve: {
    hash: true,
    timestamp: true
  },
  resolveBuildDependencies: {
    hash: true,
    timestamp: true
  }
},
recordsPath: path.resolve(__dirname, "./.cache/webpack/records.json")
module: {
    rules: [
      {
        test: /\.jsx?$/,
        include: [sourcePath],
        use: [
          {
            loader: "babel-loader",
            options: {
              sourceType: "unambiguous",
              assumptions: {
                ignoreFunctionLength: true,
                ignoreToPrimitiveHint: true,
                noClassCalls: true,
                noDocumentAll: true,
                privateFieldsAsProperties: true,
                setComputedProperties: true,
                setPublicClassFields: true,
                superIsCallableConstructor: true
              },
              plugins: [
                [
                  require.resolve("babel-plugin-transform-barrels"),
                  {
                    modulesDirs: ["node_modules", "src"],
                    moduleIgnorePatterns: [
                      "react-router",
                      "react-redux",
                      "classnames"
                    ],
                    isCacheEnabled: false
                  }
                ],
              ],
              cacheDirectory: path.resolve(
                __dirname,
                ".cache/babel-loader"
              ),
              cacheCompression: false,
              shouldPrintComment
            }
          }
        ]
      }
    ]
 }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions