Skip to content

Commit

Permalink
Merge pull request #164 from radixdlt/async-rdt-instantiation
Browse files Browse the repository at this point in the history
Async RDT instantiation + single file bundle
  • Loading branch information
dawidsowardx authored Nov 27, 2023
2 parents 98fcf47 + c63f387 commit ee8bdc5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"scripts": {
"dev": "vite serve examples",
"build": "tsc && vite build",
"build": "tsc && vite build && vite build --config vite-single-file.config.ts",
"prepare": "npx husky install",
"test": "jest",
"test:watch": "jest --watch"
Expand Down Expand Up @@ -79,7 +79,8 @@
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"vite": "^4.3.5"
"vite": "^4.3.5",
"vite-plugin-singlefile": "^0.13.5"
},
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion src/connect-button/connect-button-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
fromEvent,
map,
merge,
of,
Subscription,
switchMap,
tap,
Expand Down Expand Up @@ -44,7 +45,10 @@ export const ConnectButtonClient = (input: {
const subscriptions = new Subscription()

subscriptions.add(
fromEvent(document, 'onRender')
merge(
fromEvent(document, 'onRender'),
of(getConnectButtonElement()).pipe(filter((e) => !!e))
)
.pipe(
map(() => getConnectButtonElement()),
filter((element): element is ConnectButton => !!element),
Expand Down
3 changes: 3 additions & 0 deletions src/single-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as RadixDappToolkit from './index'

export default RadixDappToolkit
15 changes: 15 additions & 0 deletions vite-single-file.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import { viteSingleFile } from 'vite-plugin-singlefile'

export default defineConfig({
plugins: [viteSingleFile()],
build: {
emptyOutDir: false,
lib: {
entry: 'src/single-file.js',
name: 'RDT',
fileName: 'radix-dapp-toolkit.bundle',
},
},
define: { 'process.env.NODE_ENV': '"production"' },
})

0 comments on commit ee8bdc5

Please sign in to comment.