Comments (5)
@michalbujalski Are you getting that error after running yarn preview
? Can you show what your config looks like for the optimizeDeps
option? You could also try changing your definition of global
to globalThis
:
define: {
global: "globalThis",
},
Also, if you see any errors in the dev tools console about require
, you might need to add the following to your build
option:
commonjsOptions: {
transformMixedEsModules: true,
},
from hashconnect.
@michalbujalski Have you tried adding the rollup-plugin-node-polyfills
plugin to the rollupOptions
?
import nodePolyfills from "rollup-plugin-node-polyfills";
export default defineConfig({
// add the following to the rest of your config:
build: {
rollupOptions: {
plugins: [ nodePolyfills() as any],
}
}
})
from hashconnect.
Yes, I got the same result
from hashconnect.
any update on a fix
from hashconnect.
I ran into a similar set of issues with a Vite+React application. A local build worked as expected but the same build deployed to Netlify would throw the following errors in the Chrome DevTools console:
Uncaught ReferenceError: global is not defined
Uncaught ReferenceError: require is not defined
Uncaught ReferenceError: Buffer is not defined
Setting the transformMixedEsModules
field to true
and adding global node polyfills fixed these issues:
/* vite.config.ts */
import { nodePolyfills } from "vite-plugin-node-polyfills";
/* ... other config ... */
export default defineConfig({
/* ... other config ... */
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
plugins: [
nodePolyfills({
globals: {
Buffer: true,
global: true,
process: true,
},
}),
]
})
transformMixedEsModules: true
enables mixed module transformations. This is useful for scenarios where modules include a mix of ES import
statements and CommonJS require
statements. Setting transformMixedEsModules
to true
transforms require
statements to import
statements (and vice versa for false
). This is useful for bundling hashconnect
since the ES esm/hashconnect.js
file uses a CommonJS 'require' statement to import buffer
: global.Buffer = global.Buffer || require('buffer').Buffer;
.
The node polyfills should fix the errors related to the 'not defined' global variables.
from hashconnect.
Related Issues (20)
- React Demo is using outdated version - Example app also uses outdated version HOT 1
- any one Help me what is this issuer??? HOT 1
- Login using ECDSA key in Hashpack
- Relay can receive non-JSON messages but does not handle them gracefully
- Excessive 'Failed to parse source map' Warnings HOT 1
- lack of documentation
- Decryption error when connecting wallet. HOT 4
- Issue signing data. Approve button not working HOT 1
- Wallet Agnostic option HOT 1
- Property 'signTransaction' does not exist on type 'TransferTransaction' HOT 1
- Can't build the project because of nodejs dependencies HOT 1
- Error: Cannot find module "crypto" with Next.js 14 and Node 20.10.0
- TypeError: bufferUtil.mask is not a function
- The chrome extension is not injected into iframes
- HashConnect signTransaction returns wrong signature
- HashConnect signTransaction returns wrong signature
- getRecord bug : body.data was not set in the protobuf.
- Hashpack Wallet is unable to connect on mobile devices.
- Build Fails with @hashgraph/sdk and hashconnect in Next.js TypeScript Project HOT 1
- Error: No matching key. history: 1716990896575755 for AccountAllowanceApproveTransaction HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashconnect.