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.

Cannot read property '__esModule' of undefined

See original GitHub issue

Bug report

What is the current behavior? We have a components library where we have multiple entry points setup for components. Since we had nesting of components as well, we were ending up duplicating the code.

Hence we used the optimization block inside the config.

optimization: {
    splitChunks: {
      chunks: 'all',
      minChunks: 1,
      minSize: 1000,
      maxInitialRequests: Infinity,
      cacheGroups: {
        vendorCss: {
          test: /[\\/]node_modules[\\/](@hotstar\/isomorphic-style-loader|css-loader)[\\/]/,
          name: 'vendor_css_loaders',
          chunks: 'all',
        },
      }
    },

But after using this to bundle our components lib, and using this library inside the next.js app we get the error

TypeError: Cannot read property '__esModule' of undefined
    at /Users/ajayjaggi/Desktop/Hotstar/web-website/node_modules/@hotstar/web-ui-components-lib/modern/components/Molecule/CustomError/src/index.js:328:34
    at Object.<anonymous> (/Users/ajayjaggi/Desktop/Hotstar/web-website/node_modules/@hotstar/web-ui-components-lib/modern/components/Molecule/CustomError/src/index.js:330:12)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.@hotstar/web-ui-components-lib/modern/components/Molecule/CustomError/src (/Users/ajayjaggi/Desktop/Hotstar/web-website/packages/website/.next/server/pages/_app.js:1273:18)
    at __webpack_require__ (/Users/ajayjaggi/Desktop/Hotstar/web-website/packages/website/.next/server/webpack-runtime.js:33:42)

which arises from here at 192 line. Screenshot 2022-08-04 at 12 34 19 PM

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

What is the expected behavior? It should run without giving any errors

Other relevant information: webpack version: 5.40 Node.js version: 14.0.0 Operating System: mac os next.js version: 12.0.7

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vankopcommented, Aug 4, 2022

please create small reproducible repo, thanks

0reactions
webpack-botcommented, Dec 6, 2022

This issue had no activity for at least three months.

It’s subject to automatic issue closing if there is no activity in the next 15 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property '__esModule' of undefined ...
Got an answer from webpack. It's a bug in webpack. PR to fix (not yet accepted, but works as patch).
Read more >
Cannot read property '__esModule' of undefined-Vue.js
Coding example for the question Dynamic Component gives TypeError: Cannot read property '__esModule' of undefined-Vue.js.
Read more >
Liferay.Loader.define of undefined - Forums
Uncaught TypeError : Cannot read property 'define' of undefined ... defineProperty(exports, "__esModule", { value: true }); exports.default = function (msg) ...
Read more >
Vue-hot-reload-api Cannot read property '__esModule' of ...
js:15 Uncaught TypeError: Cannot read property '__esModule' of undefined at Object../node_modules/vue-hot-reload-api/dist/index.js.exports.
Read more >
Gotchas - Remix
It almost always means that server code made it into browser bundles. TypeError: Cannot read properties of undefined (reading 'root'). For example, you...
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