Skip to content

Commit 819d859

Browse files
committed
dynamic imports
1 parent 9a06097 commit 819d859

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

apps/remix-ide/src/app.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
'use strict'
22
import { RunTab, makeUdapp } from './app/udapp'
3-
import { RemixEngine } from './remixEngine'
43
import { RemixAppManager } from './remixAppManager'
5-
import { ThemeModule } from './app/tabs/theme-module'
6-
import { NetworkModule } from './app/tabs/network-module'
7-
import { Web3ProviderModule } from './app/tabs/web3-provider'
8-
import { SidePanel } from './app/components/side-panel'
9-
import { HiddenPanel } from './app/components/hidden-panel'
10-
import { VerticalIcons } from './app/components/vertical-icons'
11-
import { LandingPage } from './app/ui/landing-page/landing-page'
12-
import { MainPanel } from './app/components/main-panel'
13-
import { PermissionHandlerPlugin } from './app/plugins/permission-handler-plugin'
144

155
import { WalkthroughService } from './walkthroughService'
166

@@ -95,7 +85,7 @@ class AppComponent {
9585
const pluginLoader = self.appManager.pluginLoader
9686
self.panels = {}
9787
self.workspace = pluginLoader.get()
98-
self.engine = new RemixEngine()
88+
self.engine = new (await import('./remixEngine')).RemixEngine
9989
self.engine.register(appManager)
10090

10191
const matomoDomains = {
@@ -126,7 +116,7 @@ class AppComponent {
126116
// ----------------- gist service ---------------------------------
127117
self.gistHandler = new GistHandler()
128118
// ----------------- theme service ---------------------------------
129-
self.themeModule = new ThemeModule()
119+
self.themeModule = new (await import('./app/tabs/theme-module')).ThemeModule()
130120
Registry.getInstance().put({ api: self.themeModule, name: 'themeModule' })
131121

132122
// ----------------- editor service ----------------------------
@@ -159,9 +149,9 @@ class AppComponent {
159149
// service which fetch contract artifacts from sourve-verify, put artifacts in remix and compile it
160150
const fetchAndCompile = new FetchAndCompile()
161151
// ----------------- network service (resolve network id / name) -----
162-
const networkModule = new NetworkModule(blockchain)
152+
const networkModule = new (await import('./app/tabs/network-module')).NetworkModule(blockchain)
163153
// ----------------- represent the current selected web3 provider ----
164-
const web3Provider = new Web3ProviderModule(blockchain)
154+
const web3Provider = new (await import('./app/tabs/web3-provider')).Web3ProviderModule(blockchain)
165155
const hardhatProvider = new HardhatProvider(blockchain)
166156
// ----------------- convert offset to line/column service -----------
167157
const offsetToLineColumnConverter = new OffsetToLineColumnConverter()
@@ -192,7 +182,7 @@ class AppComponent {
192182
const configPlugin = new ConfigPlugin()
193183
self.layout = new Layout()
194184

195-
const permissionHandler = new PermissionHandlerPlugin()
185+
const permissionHandler = new (await import('./app/plugins/permission-handler-plugin')).PermissionHandlerPlugin()
196186

197187
self.engine.register([
198188
permissionHandler,
@@ -219,22 +209,22 @@ class AppComponent {
219209
])
220210

221211
// LAYOUT & SYSTEM VIEWS
222-
const appPanel = new MainPanel()
212+
const appPanel = new (await import('./app/components/main-panel')).MainPanel()
223213
Registry.getInstance().put({ api: self.mainview, name: 'mainview' })
224214
const tabProxy = new TabProxy(fileManager, editor)
225215
self.engine.register([appPanel, tabProxy])
226216

227217
// those views depend on app_manager
228-
self.menuicons = new VerticalIcons()
229-
self.sidePanel = new SidePanel()
230-
self.hiddenPanel = new HiddenPanel()
218+
self.menuicons = new (await import('./app/components/vertical-icons')).VerticalIcons()
219+
self.sidePanel = new (await import('./app/components/side-panel')).SidePanel()
220+
self.hiddenPanel = new (await import('./app/components/hidden-panel')).HiddenPanel()
231221

232222
const pluginManagerComponent = new PluginManagerComponent(
233223
appManager,
234224
self.engine
235225
)
236226
const filePanel = new FilePanel(appManager)
237-
const landingPage = new LandingPage(
227+
const landingPage = new (await import('./app/ui/landing-page/landing-page')).LandingPage(
238228
appManager,
239229
self.menuicons,
240230
fileManager,

apps/remix-ide/src/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import AppComponent from './app'
66
const RemixApp = lazy(() => import ('@remix-ui/app'));
77

88
const appComponent = new AppComponent()
9-
appComponent.run()
10-
11-
ReactDOM.render(
12-
<React.StrictMode>
13-
<Suspense fallback={<div>Loading...</div>}>
14-
<RemixApp app={appComponent} />
15-
</Suspense>
16-
</React.StrictMode>,
17-
document.getElementById('root')
18-
)
9+
appComponent.run().then(() => {
10+
ReactDOM.render(
11+
<React.StrictMode>
12+
<Suspense fallback={<div>Loading...</div>}>
13+
<RemixApp app={appComponent} />
14+
</Suspense>
15+
</React.StrictMode>,
16+
document.getElementById('root')
17+
)
18+
})

0 commit comments

Comments
 (0)