Skip to content

Commit fdd3fee

Browse files
committed
feat: add @rollup/plugin-inject for improved dependency handling and update Vite configuration for better global variable support
1 parent 8304fe6 commit fdd3fee

File tree

10 files changed

+47
-56
lines changed

10 files changed

+47
-56
lines changed

dist/404.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
<title>Demo Dapp with @tonconnect/ui-react</title>
99

1010
<script data-consolejs-channel="57e95ad4-4a89-7cf9-106a-51106eb4d73d" src="https://remotejs.com/agent/agent.js"></script>
11-
<script type="module" crossorigin src="/demo-dapp-with-wallet/relayers/assets/index-DGrSjRsz.js"></script>
11+
<script type="module" crossorigin src="/demo-dapp-with-wallet/relayers/assets/index-BjVcfrst.js"></script>
1212
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-react-Drc5ga--.js">
1313
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-ton-DCgIeIEq.js">
14-
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-crypto-BaViaJl1.js">
1514
<link rel="stylesheet" crossorigin href="/demo-dapp-with-wallet/relayers/assets/index-C6qF6Nog.css">
1615
</head>
1716
<body>

dist/assets/index-BjVcfrst.js

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/index-DGrSjRsz.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

dist/assets/vendor-crypto-BaViaJl1.js

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import"./vendor-react-Drc5ga--.js";import"./vendor-ton-DCgIeIEq.js";

dist/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
<title>Demo Dapp with @tonconnect/ui-react</title>
99

1010
<script data-consolejs-channel="57e95ad4-4a89-7cf9-106a-51106eb4d73d" src="https://remotejs.com/agent/agent.js"></script>
11-
<script type="module" crossorigin src="/demo-dapp-with-wallet/relayers/assets/index-DGrSjRsz.js"></script>
11+
<script type="module" crossorigin src="/demo-dapp-with-wallet/relayers/assets/index-BjVcfrst.js"></script>
1212
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-react-Drc5ga--.js">
1313
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-ton-DCgIeIEq.js">
14-
<link rel="modulepreload" crossorigin href="/demo-dapp-with-wallet/relayers/assets/vendor-crypto-BaViaJl1.js">
1514
<link rel="stylesheet" crossorigin href="/demo-dapp-with-wallet/relayers/assets/index-C6qF6Nog.css">
1615
</head>
1716
<body>

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
}
3232
},
3333
"devDependencies": {
34+
"@rollup/plugin-inject": "^5.0.5",
3435
"@types/node": "^22.13.10",
3536
"@types/react": "^18.0.26",
3637
"@types/react-dom": "^18.0.9",

src/polyfills.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
import { Buffer as BufferPolyfill } from 'buffer'
2-
import process from 'process'
3-
4-
const g: any = globalThis as any
5-
6-
if (!g.Buffer || typeof g.Buffer.alloc !== 'function') {
7-
g.Buffer = BufferPolyfill
8-
}
9-
10-
if (!g.process) {
11-
g.process = process
12-
}
1+
import { Buffer } from 'buffer'

vite.config.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ export default defineConfig(({ command }) => {
5454
return {
5555
plugins: [
5656
react(),
57-
nodePolyfills({ globals: { Buffer: true }, protocolImports: true }),
57+
nodePolyfills({
58+
globals: {
59+
Buffer: true,
60+
global: true,
61+
process: true,
62+
},
63+
protocolImports: true,
64+
}),
5865
isBuild && create404Plugin()
5966
].filter(Boolean),
6067

@@ -65,7 +72,7 @@ export default defineConfig(({ command }) => {
6572
manualChunks: {
6673
'vendor-react': ['react', 'react-dom'],
6774
'vendor-ton': ['@ton/core', '@tonconnect/ui-react'],
68-
'vendor-crypto': ['crypto-browserify', 'tweetnacl', 'buffer']
75+
'vendor-crypto': ['crypto-browserify', 'tweetnacl', 'buffer', 'process']
6976
}
7077
}
7178
}
@@ -81,8 +88,6 @@ export default defineConfig(({ command }) => {
8188
},
8289
},
8390

84-
optimizeDeps: { include: ['process', 'buffer'] },
85-
8691
base: isBuild
8792
? (branch === 'main'
8893
? '/demo-dapp-with-wallet/'
@@ -91,6 +96,8 @@ export default defineConfig(({ command }) => {
9196

9297
server: { fs: { allow: ['../sdk', './'] } },
9398

94-
define: { __APP_BRANCH__: JSON.stringify(branch) },
99+
define: {
100+
__APP_BRANCH__: JSON.stringify(branch),
101+
},
95102
}
96103
})

0 commit comments

Comments
 (0)