Build issues with v3. TypeError: Class extends value undefined is not a constructor or null
See original GitHub issueDescribe 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It seems it’s related to @rollup/plugin-commonjs v22.
For a workaround, use Esbuild Deps Optimization at Build Time. Set
optimizeDeps.disabled = falseandbuild.commonjsOptions.include = [].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.tsThere’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