Comments (6)
@mohamedaarab1994 Have you got any updates on this?
Angular doesn't bootstrap client side at all, therefore there is no JS code at all. Only links work.
Preboot works as it should when you run:
"dev:ssr": "ng run frontend:serve-ssr"
It is really frustrating 😞
from preboot.
@CaerusKaru any update on this? I'm facing the same issue in angular 9
from preboot.
I am facing the same issue, can you please update us on this please.
from preboot.
I had the same issue until I realized that appId
and appRoot
need to be the same:
In my AppModule:
BrowserModule.withServerTransition({ appId: 'app-root' }),
PrebootModule.withConfig({ appRoot: 'app-root' })
After that, everything worked like a charm.
from preboot.
I had the same issue until I realized that
appId
andappRoot
need to be the same:In my AppModule:
BrowserModule.withServerTransition({ appId: 'app-root' }), PrebootModule.withConfig({ appRoot: 'app-root' })
After that, everything worked like a charm.
It works for me .Thanks.
from preboot.
Ok another reason why this might fail: preboot uses the observable appRef.isStable
, which might never get stable because according to the documentation:
the application will never be stable if you start any kind of recurrent asynchronous task when the application starts (for example for a polling process, started with a setInterval, a setTimeout or using RxJS operators like interval);
These asynchronous tasks can be in your code (setTimeout, setInterval, or interval operator), or in any of your external libraries... making it very hard to debug.
A solution is to manually do the cleanup:
- Inject
EventReplayer
in your code - call
this.eventReplayer.replayAll();
This will make the replay of events, and then the cleanup of the server side application. You will be responsible for making sure that your app is loaded, otherwise you'll see a nice FOC when it switches from one app to the other...
If you're not replaying events, you can directly call this.eventReplayer.cleanup();
To help you detect pending async events such as setInterval
, you can use the following code in your main.ts file:
document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(moduleInstance => {
// Ensure Angular destroys itself on hot reloads.
if (window['ngRef']) {
window['ngRef'].destroy();
}
window['ngRef'] = moduleInstance;
const ngZone = moduleInstance.injector.get(NgZone);
setInterval(() => {
const taskTrackingZone = (<any>ngZone)._inner.getZoneWith('TaskTrackingZone');
if (!taskTrackingZone) {
throw new Error(
`'TaskTrackingZone' zone not found! Have you loaded 'node_modules/zone.js/dist/task-tracking.js'?`
);
}
let tasks: any[] = taskTrackingZone._properties.TaskTrackingZone.getTasksFor('macroTask');
tasks = clone(tasks);
if (size(tasks) > 0) {
console.log('ZONE pending tasks', tasks);
}
}, 1000);
// Otherwise, log the boot error
})
.catch((error: string) => {
/* tslint:disable-next-line */
console.error(error);
});
});
And add import 'zone.js/dist/task-tracking';
in your polyfill.ts file
from preboot.
Related Issues (20)
- Setting Focus is not applying to screenreader elements, only TextArea and Input elements HOT 5
- question: a clicks by default event selector HOT 1
- New version changelog? What's in v5.1.7? HOT 1
- Adding Preboot to Angular SSR causes webpack error
- Prebootoverlay doesn't removed in mobile view
- Angular Component styles not linked properly during preboot (_ngcontent-serverApp-c16 vs _ngcontent-sc16) HOT 1
- Generic type 'ModuleWithProviders<T>' requires 1 type argument(s). Angular 11 HOT 3
- Is this repository still maintained? HOT 2
- Module not found Angular 11 + Universal SSR HOT 2
- Flicker due to styles reload HOT 2
- Illegal invocation calling window.getComputedStyle HOT 29
- Angular 13 support HOT 4
- Project Status?
- Preboot buffer: Application bootstrap on the server generated node. HOT 6
- Error: Cannot set property 'prebootData' of undefined HOT 2
- Inline start function uses wrong 'currentScript'. HOT 5
- Cleanup is not removing event listeners HOT 6
- Support for Angular 7
- Support Angular 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preboot.