Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw an Error with type: 'asset', parser.dataUrlCondition.maxSize #13827

Closed
richardchen85 opened this issue Jul 20, 2021 · 7 comments · Fixed by #13837
Closed

throw an Error with type: 'asset', parser.dataUrlCondition.maxSize #13827

richardchen85 opened this issue Jul 20, 2021 · 7 comments · Fixed by #13837

Comments

@richardchen85
Copy link

Bug report

What is the current behavior?

I got an TypeError: Cannot read property 'get' of undefined when rebuild with config type: 'asset', parser.dataUrlCondition.maxSize=1000

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

  • webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.png/,
        type: 'asset',
        parser: {
          dataUrlCondition: {
            maxSize: 10000
          }
        }
      }
    ]
  }
}
  • require a image with size under 10000
  • rebuild and got error
ERROR in [entry] [initial]
Cannot read property 'get' of undefined
TypeError: Cannot read property 'get' of undefined
    at /Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/asset/AssetModulesPlugin.js:183:29
    at Hook.eval (eval at create (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:10:16)
    at Hook.CALL_DELEGATE [as _call] (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/tapable/lib/Hook.js:14:14)
    at Compilation.getRenderManifest (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/Compilation.js:3774:36)
    at /Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/Compilation.js:3793:22
    at symbolEach (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/neo-async/async.js:2444:9)
    at Object.each (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/neo-async/async.js:2849:16)
    at Compilation.createChunkAssets (/Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/Compilation.js:3787:12)
    at /Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/Compilation.js:2548:14
    at /Users/cdchenliqiang/workspace/4a-bdp-fe/mkt-cpm-ui/node_modules/webpack/lib/Compilation.js:2680:5

What is the expected behavior?

rebuild without error

Other relevant information:
webpack version: 5.45.1
Node.js version: 12.20.1
Operating System: macOS 10.14.4
Additional tools:

@alexander-akait
Copy link
Member

Seems you have broken data URI

@richardchen85
Copy link
Author

it works fine if i comment codes below

// webpack/lib/NormalModuleFactory.js

cleanupForCache() {
  for (const module of this._restoredUnsafeCacheEntries) {
    ChunkGraph.clearChunkGraphForModule(module);
    ModuleGraph.clearModuleGraphForModule(module);
    // works fine if comment this line
    // module.cleanupForCache();
  }
}

@alexander-akait
Copy link
Member

never do it

@alexander-akait
Copy link
Member

Please provide code

@richardchen85
Copy link
Author

webpack-learn.zip

Here is my code and reproduce steps:

  • run npm start
  • type some words in ./src/index.js and save
  • get error TypeError: Cannot read property 'get' of undefined

@richardchen85
Copy link
Author

cache.type = 'filesystem' and devServer.hot = true are the key

@alexander-akait
Copy link
Member

alexander-akait commented Jul 21, 2021

Update webpack to v5.45.1, can't reproduce using your repo, works fine reproduce

sokra added a commit that referenced this issue Jul 22, 2021
…d module

fixes #13827

avoid pre-computing source types and sizes on cleanup for not-built modules (e. g. from unsafe cache)
improve eror message when asset rendering fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants