webpack: TypeError: Cannot read properties of undefined (reading 'call')

Bug report

When building an application for production in complex dependency chains some dependencies that are required by the application can be accidentally tree shaken causing the application to not load.

What is the current behavior?

Webpack will tree shake a file/dependency accidentally causing the application to not load with the error ->

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')
    at u (bootstrap:19:32)
    at 75282 (reservationRuleUtil.js:39:5)
    at u (bootstrap:19:32)
    at 87962 (profileParseUtil.js:64:5)
    at u (bootstrap:19:32)
    at 8407 (availabilityFilterChips.js:3:109)
    at u (bootstrap:19:32)
    at 93439 (914.ede21470d6d91f13d1b5.js:1:220)
    at Function.u (bootstrap:19:32)

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

Clone the repro git repository (I have made the repo private as this project contains some code that I do not want to publicly share. This is a high priority issue for us at my company though, so we are willing to share the code with individuals that are looking to debug the problem).

I have created three branches with a different version of webpack installed in each and committed the node_modules folder (sorry about the size of the clone)… This was necessary due to some of the libraries required to debug being only on a private npm registry.

The first branch has the last working version of webpack that this project works on ->

https://github.com/bmarti44/webpack-tree-shaking-issue/tree/version/5.24.0

Then the version of webpack where things started braking ->

https://github.com/bmarti44/webpack-tree-shaking-issue/tree/version/5.24.1

Finally the latest version (things are still broken with the very latest) ->

https://github.com/bmarti44/webpack-tree-shaking-issue/tree/version/5.80.0

What is the expected behavior?

The application should build in production mode with all default optimizations without issue.

Other relevant information: webpack versions: 524.1-5.80.0
Node.js version: 16.15.1 Operating System: macOS Monterey Additional tools:

It looks like there has been another report of this issue here -> https://github.com/webpack/webpack/discussions/15369

Diff of changes that I’ve been looking over (I’ve been trying to nail it down to the exact commit) -> https://github.com/webpack/webpack/compare/v5.24.0...v5.24.1

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 20 (6 by maintainers)

Most upvoted comments

You can try to enable runtime chunk or disable optimization to undestand where is a bug, I will look at this late

Yeah, PR welcome