Skip to content

Commit

Permalink
Ensure we have the smallest main.js possible (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Oct 19, 2023
1 parent f08db0b commit 256d93e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 17 additions & 0 deletions liquidity/ui/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { safeImport } from '@synthetixio/safe-import/safeImport';

async function bootstrap() {
const { bootstrap } = await safeImport(() =>
import(/* webpackChunkName: "app" */ './src/index.tsx')
);
bootstrap();
}

bootstrap();

if (module.hot) {
module.hot.accept();
module.hot.dispose(() => {
// do nothing
});
}
3 changes: 1 addition & 2 deletions liquidity/ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App } from './App';
import { preserveConnectedWallets, autoConnect } from '@snx-v3/useBlockchain';

const container = document.querySelector('#app');
async function run() {
export async function bootstrap() {
if (!container) {
throw new Error('Container #app does not exist');
}
Expand Down Expand Up @@ -48,4 +48,3 @@ async function run() {
const root = ReactDOM.createRoot(container);
root.render(<App />);
}
run();
2 changes: 1 addition & 1 deletion liquidity/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = {
devtool: isTest ? false : 'source-map',
devServer,
mode: isProd ? 'production' : 'development',
entry: './src/index.tsx',
entry: './index.js',

output: {
path: path.resolve(__dirname, 'dist'),
Expand Down

0 comments on commit 256d93e

Please sign in to comment.