Skip to content

Commit 344d5b4

Browse files
authored
[core:2.7.0-alpha.4] - Dynamically import Notify and Account Center (#1207)
* Dynamically import notify and account center * Increment core version in vue and react pkg
1 parent 840d8d1 commit 344d5b4

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.7.0-alpha.3",
3+
"version": "2.7.0-alpha.4",
44
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",

packages/core/src/views/Index.svelte

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import Connect from './connect/Index.svelte'
66
import SwitchChain from './chain/SwitchChain.svelte'
77
import ActionRequired from './connect/ActionRequired.svelte'
8-
import AccountCenter from './account-center/Index.svelte'
9-
import Notify from './notify/Index.svelte'
108
import { configuration } from '../configuration'
119
import type { Observable } from 'rxjs'
1210
import type { Notification } from '../types'
@@ -43,6 +41,14 @@
4341
}
4442
}
4543
44+
const accountCenterComponent = $accountCenter$.enabled
45+
? import('./account-center/Index.svelte').then(mod => mod.default)
46+
: Promise.resolve(null)
47+
48+
const notifyComponent = $notify$.enabled
49+
? import('./notify/Index.svelte').then(mod => mod.default)
50+
: Promise.resolve(null)
51+
4652
$: sharedContainer =
4753
$accountCenter$.enabled &&
4854
$notify$.enabled &&
@@ -359,11 +365,16 @@
359365
: ''} "
360366
>
361367
{#if $notify$.position.includes('bottom') && $accountCenter$.position.includes('bottom') && samePositionOrMobile}
362-
<Notify
363-
notifications={$notifications$}
364-
position={$notify$.position}
365-
{sharedContainer}
366-
/>
368+
{#await notifyComponent then Notify}
369+
{#if Notify}
370+
<svelte:component
371+
this={Notify}
372+
notifications={$notifications$}
373+
position={$notify$.position}
374+
{sharedContainer}
375+
/>
376+
{/if}
377+
{/await}
367378
{/if}
368379
<div
369380
style={!$accountCenter$.expanded &&
@@ -376,14 +387,23 @@
376387
? 'margin-right: auto'
377388
: ''}
378389
>
379-
<AccountCenter settings={$accountCenter$} />
390+
{#await accountCenterComponent then AccountCenter}
391+
{#if AccountCenter}
392+
<svelte:component this={AccountCenter} settings={$accountCenter$} />
393+
{/if}
394+
{/await}
380395
</div>
381396
{#if $notify$.position.includes('top') && $accountCenter$.position.includes('top') && samePositionOrMobile}
382-
<Notify
383-
notifications={$notifications$}
384-
position={$notify$.position}
385-
{sharedContainer}
386-
/>
397+
{#await notifyComponent then Notify}
398+
{#if Notify}
399+
<svelte:component
400+
this={Notify}
401+
notifications={$notifications$}
402+
position={$notify$.position}
403+
{sharedContainer}
404+
/>
405+
{/if}
406+
{/await}
387407
{/if}
388408
</div>
389409
{/if}
@@ -410,7 +430,11 @@
410430
: ''}
411431
>
412432
{#if $accountCenter$.enabled && $wallets$.length}
413-
<AccountCenter settings={$accountCenter$} />
433+
{#await accountCenterComponent then AccountCenter}
434+
{#if AccountCenter}
435+
<svelte:component this={AccountCenter} settings={$accountCenter$} />
436+
{/if}
437+
{/await}
414438
{/if}
415439
</div>
416440
</div>
@@ -426,10 +450,15 @@
426450
? 'padding-top:0;'
427451
: ''} "
428452
>
429-
<Notify
430-
notifications={$notifications$}
431-
position={$notify$.position}
432-
{sharedContainer}
433-
/>
453+
{#await notifyComponent then Notify}
454+
{#if Notify}
455+
<svelte:component
456+
this={Notify}
457+
notifications={$notifications$}
458+
position={$notify$.position}
459+
{sharedContainer}
460+
/>
461+
{/if}
462+
{/await}
434463
</div>
435464
{/if}

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"typescript": "^4.5.5"
6363
},
6464
"dependencies": {
65-
"@web3-onboard/core": "^2.7.0-alpha.3",
65+
"@web3-onboard/core": "^2.7.0-alpha.4",
6666
"@web3-onboard/common": "^2.1.8-alpha.1",
6767
"use-sync-external-store": "1.0.0"
6868
},

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@vueuse/core": "^8.4.2",
6464
"@vueuse/rxjs": "^8.2.0",
6565
"@web3-onboard/common": "^2.1.8-alpha.1",
66-
"@web3-onboard/core": "^2.7.0-alpha.3",
66+
"@web3-onboard/core": "^2.7.0-alpha.4",
6767
"vue-demi": "^0.12.4"
6868
},
6969
"peerDependencies": {

0 commit comments

Comments
 (0)