-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve and document code splitting
- Loading branch information
1 parent
05a4063
commit d3142db
Showing
25 changed files
with
81 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Code Splitting | ||
|
||
As explained in [this link](https://legacy.reactjs.org/docs/code-splitting.html), Code-Splitting is a feature supported by some bundlers that allows the creation of multiple bundles that can be loaded dynamically at runtime. This technique enables us to "lazily-load" only the necessary components for the user's current needs, significantly enhancing the performance of the application. | ||
|
||
|
||
## What we did | ||
|
||
- Splitting Signers from initial bundle | ||
|
||
|
||
## What we are going to do | ||
|
||
Currently, we've achieved a good initial bundle size based on analyses conducted using tools like `lighthouse`. Some potential future works that could contribute to the journey ahead are listed below: | ||
|
||
- Implement retry mechanisms for dynamic imports to address issues with failing to import certain chunks. | ||
- Maintain the applied changes to prevent future modifications from undoing the achieved results. | ||
- Identify potential areas that can be dynamically imported. | ||
- Attempt to enhance clients that have integrated widgets (like dapp) to improve overall performance. | ||
|
||
|
||
## Technical Consideration | ||
|
||
- Avoid small chunks, they don't add any value to user. they will have network overhead as well. | ||
- Chunks will be built using esbuild's [splitting](https://esbuild.github.io/api/#splitting) option. | ||
- Code splitting for libraries is off by default. To enable the option, add the "--splitting" parameter to the "build" script of that package. | ||
|
||
|
||
## Notes | ||
|
||
The `@rango-dev/signer-solana` package is not dynamically imported because it has a major dependency ("@solana/web3.js") that is also a dependency in `@solflare-wallet/sdk`, which is used in `provider-solflare`. This dependency cannot be dynamically imported, so importing `@rango-dev/signer-solana` dynamically would only result in a very small reduction in the bundle size. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { SignerFactory } from 'rango-types'; | ||
|
||
import { DefaultStarknetSigner } from '@rango-dev/signer-starknet'; | ||
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types'; | ||
|
||
export default async function getSigners( | ||
provider: any | ||
): Promise<SignerFactory> { | ||
const signers = new DefaultSignerFactory(); | ||
const { DefaultStarknetSigner } = await import('@rango-dev/signer-starknet'); | ||
signers.registerSigner(TxType.STARKNET, new DefaultStarknetSigner(provider)); | ||
return signers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { SignerFactory } from 'rango-types'; | ||
|
||
import { DefaultStarknetSigner } from '@rango-dev/signer-starknet'; | ||
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types'; | ||
|
||
export default async function getSigners( | ||
provider: any | ||
): Promise<SignerFactory> { | ||
const signers = new DefaultSignerFactory(); | ||
const { DefaultStarknetSigner } = await import('@rango-dev/signer-starknet'); | ||
signers.registerSigner(TxType.STARKNET, new DefaultStarknetSigner(provider)); | ||
return signers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import type { TonProvider } from './types.js'; | ||
import type { SignerFactory } from 'rango-types'; | ||
|
||
import { DefaultTonSigner } from '@rango-dev/signer-ton'; | ||
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types'; | ||
|
||
export default async function getSigners( | ||
provider: TonProvider | ||
): Promise<SignerFactory> { | ||
const signers = new DefaultSignerFactory(); | ||
const { DefaultTonSigner } = await import('@rango-dev/signer-ton'); | ||
signers.registerSigner(TxType.TON, new DefaultTonSigner(provider)); | ||
return signers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.