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.

Build issues with v3. TypeError: Class extends value undefined is not a constructor or null

See original GitHub issue

Describe the bug

After updating to version 3 we started getting the following error in our bundle script:

account_multisig.js:48 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at account_multisig.js:48:41
    at requireAccount_multisig (account_multisig.js:453:2)
    at common-index.js:34:31
    at requireCommonIndex (common-index.js:53:136)
    at requireRpc_errors (rpc_errors.js:10:24)
    at json-rpc-provider.js:20:22
    at requireJsonRpcProvider (json-rpc-provider.js:356:27)
    at index.js:9:29
    at requireProviders (index.js:12:131)
    at requireAccount (account.js:10:21)

This does not occur in v2. It does also not happen while we are in “dev” mode in v3.

It appears to be an issue with how things are being bundled in the newer version- as the new code is unable to create a specific class in a library near-api-js as it used to, and the output code does look a little strange.

Reproduction

https://github.com/lostpebble/vite-class-undefined-error

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 4.29 GB / 15.79 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 104.0.5112.81
    Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.54)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vite: ^3.0.8 => 3.0.8

Used Package Manager

yarn

Logs

No response

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
sapphi-redcommented, Aug 16, 2022

It seems it’s related to @rollup/plugin-commonjs v22.

For a workaround, use Esbuild Deps Optimization at Build Time. Set optimizeDeps.disabled = false and build.commonjsOptions.include = [].

4reactions
sapphi-redcommented, Aug 16, 2022

I think you forgot to set build.commonjsOptions.include = [] which disables commonjs plugin v22 used inside Vite. https://stackblitz.com/edit/github-g2azcc?file=package.json,vite.config.ts

what is the point of using the Rollup commonjs plugin?

There’s some tree-shaking issues with it but we’re going to make it default in future. See https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class extends value undefined is not a function or null - Stack ...
I am getting the following error when trying to create these entities. TypeError: Class extends value undefined is ...
Read more >
TypeError: Class extends value undefined is not a ... - Drupal
Initial searching seems to imply that this indicates an issue with a circular dependency. Might have to be a separate issue, but there...
Read more >
TypeError: Class extends value undefined is not a constructor ...
[moved to issue] Tutorial problem: TypeError: Class extends value undefined is not a constructor or null - Get Help and Help Others -...
Read more >
typeerror: class extends value undefined is not a ... - You.com
TypeError : Class extends value undefined is not a function or null. Start > Run > AppWiz.cpl > Uninstall node.js. Delete the node...
Read more >
Class extends value #<Object> is not a constructor or null ...
Hi there,. can anyone help me to figure out what´s the issue with this error?
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