Skip to content

Commit

Permalink
Restore hot reload functionality (#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored Dec 7, 2024
1 parent 453f833 commit 21fa88a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mesop/web/src/app/editor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ng_module(
"*.ts",
]),
deps = [
"//mesop/web/src/shell",
"//mesop/web/src/editor",
] + ANGULAR_CORE_DEPS,
)

Expand Down
2 changes: 1 addition & 1 deletion mesop/web/src/app/editor/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {bootstrapApp} from '../../shell/shell';
import {bootstrapApp} from '../../editor/editor';

bootstrapApp();
2 changes: 1 addition & 1 deletion mesop/web/src/app/editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Inject favicon -->
</head>
<body>
<mesop-app ngCspNonce="$$INSERT_CSP_NONCE$$"></mesop-app>
<mesop-editor-app ngCspNonce="$$INSERT_CSP_NONCE$$"></mesop-editor-app>
<!-- Inject livereload script (if needed) -->
<!-- Inject experiment settings script (if needed) -->
<script src="zone.js/bundles/zone.umd.js"></script>
Expand Down
20 changes: 20 additions & 0 deletions mesop/web/src/editor/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("//build_defs:defaults.bzl", "ANGULAR_CDK_TS_DEPS", "ANGULAR_CORE_DEPS", "ANGULAR_MATERIAL_TS_DEPS", "ng_module")

package(
default_visibility = ["//build_defs:mesop_internal"],
)

ng_module(
name = "editor",
srcs = glob([
"*.ts",
]),
deps = [
"//mesop/protos:ui_jspb_proto",
"//mesop/web/src/component_renderer",
"//mesop/web/src/error",
"//mesop/web/src/services",
"//mesop/web/src/shell",
"//mesop/web/src/utils",
] + ANGULAR_CORE_DEPS + ANGULAR_CDK_TS_DEPS + ANGULAR_MATERIAL_TS_DEPS,
)
49 changes: 49 additions & 0 deletions mesop/web/src/editor/editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {Component} from '@angular/core';
import {
DefaultHotReloadWatcher,
HotReloadWatcher,
} from '../services/hot_reload_watcher';
import {bootstrapApplication} from '@angular/platform-browser';
import {provideAnimations} from '@angular/platform-browser/animations';
import {RouterOutlet, Routes, provideRouter} from '@angular/router';
import {
DebugErrorDialogService,
ErrorDialogService,
} from '../services/error_dialog_service';
import {Shell, registerComponentRendererElement} from '../shell/shell';
// Keep the following comment to ensure there's a hook for adding TS imports in the downstream sync.
// ADD_TS_IMPORT_HERE

@Component({
selector: 'mesop-editor',
template: '<mesop-shell></mesop-shell>',
standalone: true,
imports: [Shell],
providers: [{provide: HotReloadWatcher, useClass: DefaultHotReloadWatcher}],
})
class Editor {
constructor(
private readonly hotReloadWatcher: HotReloadWatcher /* Inject hotReloadWatcher to ensure it's instantiated. */,
) {}
}

const routes: Routes = [{path: '**', component: Editor}];

@Component({
selector: 'mesop-editor-app',
template: '<router-outlet></router-outlet>',
imports: [Editor, RouterOutlet],
standalone: true,
})
class MesopEditorApp {}

export async function bootstrapApp() {
const app = await bootstrapApplication(MesopEditorApp, {
providers: [
provideAnimations(),
provideRouter(routes),
{provide: ErrorDialogService, useClass: DebugErrorDialogService},
],
});
registerComponentRendererElement(app);
}

0 comments on commit 21fa88a

Please sign in to comment.