Code Monkey home page Code Monkey logo

preboot's Introduction

preboot

NOTE: This package is no longer maintained and is unnecessary with the recent versions of Angular.

The purpose of this library is to help manage the transition of state (i.e. events, focus, data) from a server-generated web view to a client-generated web view. This library works with any front end JavaScript framework (i.e. React, Vue, Ember, etc.), but does have a few extra convenience modules for Angular apps.

The key features of preboot include:

  1. Record and play back events
  2. Respond immediately to certain events in the server view
  3. Maintain focus even page is re-rendered
  4. Buffer client-side re-rendering for smoother transition
  5. Freeze page until bootstrap complete for certain events (ex. form submission)

In essence, this library is all about managing the user experience from the time from when a server view is visible until the client view takes over control of the page.

Installation

cd into your app root and run the following command:

npm i preboot --save

The following sections covers the three different configurations of preboot:

  • Angular Configuration
  • Non-Angular Server Configuration
  • Non-Angular Browser Configuration

Angular Configuration

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { PrebootModule } from 'preboot';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule.withServerTransition({ appId: 'foo' }),
    PrebootModule.withConfig({ appRoot: 'app-root' })
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

The key part here for preboot is to include PrebootModule.withConfig({ appRoot: 'app-root' }) where the appRoot is the selector(s) to find the root of your application. The options you can pass into withConfig() are in the PrebootOptions section below. In most cases, however, you will only need to specify the appRoot.

Non-Angular Server Configuration

import { getInlineDefinition, getInlineInvocation } from 'preboot';

const prebootOptions = {};  // see PrebootRecordOptions section below
const inlineCodeDefinition = getInlineDefinition(prebootOptions);
const inlineCodeInvocation = getInlineInvocation();

// now insert `inlineCodeDefinition` into a `<script>` tag in `<head>` and 
// an `inlineCodeInvocation` copy just after the opening tag of each app root
<html>
  <head>
    <script><%= inlineCodeDefinition %></script>
  </head>
  <body>
    <app1-root>
      <script><%= inlineCodeInvocation %></script>
      <h2>App1 header</h2>
      <div>content</div>
    </app1-root>
    <app2-root>
      <script><%= inlineCodeInvocation %></script>
      <h2>App2 header</h2>
      <span>content</span>
    </app2-root>
  </body>
</html>

Non-Angular Browser Configuration

import { EventReplayer } from 'preboot';

const replayer = new EventReplayer();

// once you are ready to replay events (usually after client app fully loaded)
replayer.replayAll();

PrebootOptions

  • appRoot (required) - One or more selectors for apps in the page (i.e. so one string or an array of strings).
  • buffer (default true) - If true, preboot will attempt to buffer client rendering to an extra hidden div. In most cases you will want to leave the default (i.e. true) but may turn off if you are debugging an issue.
  • minify (deprecated) - minification has been removed in v6. Minification should be handled by the end-user
  • disableOverlay (default true) - If true, freeze overlay would not get injected in the DOM.
  • eventSelectors (defaults below) - This is an array of objects which specify what events preboot should be listening for on the server view and how preboot should replay those events to the client view. See Event Selector section below for more details but note that in most cases, you can just rely on the defaults and you don't need to explicitly set anything here.
  • replay (default true) - The only reason why you would want to set this to false is if you want to manually trigger the replay yourself. This contrasts with the event selector replay, because this option is global

This comes in handy for situations where you want to hold off on the replay and buffer switch until AFTER some async events occur (i.e. route loading, http calls, etc.). By default, replay occurs right after bootstrap is complete. In some apps, there are more events after bootstrap however where the page continues to change in significant ways. Basically if you are making major changes to the page after bootstrap then you will see some jank unless you set replay to false and then trigger replay yourself once you know that all async events are complete.

To manually trigger replay, inject the EventReplayer like this:

import { Injectable } from '@angular/core';
import { EventReplayer } from 'preboot';

@Injectable()
class Foo {
  constructor(private replayer: EventReplayer) {}

  // you decide when to call this based on what your app is doing
  manualReplay() {
    this.replayer.replayAll();
  }
}

Event Selectors

This part of the options drives a lot of the core behavior of preboot. Each event selector has the following properties:

  • selector - The selector to find nodes under the server root (ex. input, .blah, #foo)
  • events - An array of event names to listen for (ex. ['focusin', 'keyup', 'click'])
  • keyCodes - Only do something IF event includes a key pressed that matches the given key codes. Useful for doing something when user hits return in a input box or something similar.
  • preventDefault - If true, event.preventDefault() will be called to prevent any further event propagation.
  • freeze - If true, the UI will freeze which means displaying a translucent overlay which prevents any further user action until preboot is complete.
  • action - This is a function callback for any custom code you want to run when this event occurs in the server view.
  • replay - If false, the event won't be recorded or replayed. Useful when you utilize one of the other options above.

Here are some examples of event selectors from the defaults:

var eventSelectors = [

  // for recording changes in form elements
  { selector: 'input,textarea', events: ['keypress', 'keyup', 'keydown', 'input', 'change'] },
  { selector: 'select,option', events: ['change'] },

  // when user hits return button in an input box
  { selector: 'input', events: ['keyup'], preventDefault: true, keyCodes: [13], freeze: true },
  
  // when user submit form (press enter, click on button/input[type="submit"])
  { selector: 'form', events: ['submit'], preventDefault: true, freeze: true },

  // for tracking focus (no need to replay)
  { selector: 'input,textarea', events: ['focusin', 'focusout', 'mousedown', 'mouseup'], replay: false },

  // user clicks on a button
  { selector: 'button', events: ['click'], preventDefault: true, freeze: true }
];

Using with manual bootstrap (e.g. with ngUpgrade)

Preboot registers its reply code at the APP_BOOTSTRAP_LISTENER token which is called by Angular for every component that is bootstrapped. If you don't have the bootstrap property defined in your AppModule's NgModule but you instead use the ngDoBootrap method (which is done e.g. when using ngUpgrade) this code will not run at all.

To make Preboot work correctly in such a case you need to specify replay: false in the Preboot options and replay the events yourself. That is, import PrebootModule like this:

PrebootModule.withConfig({
  appRoot: 'app-root',
  replay: false,
})

and replay events in AppComponent like this:

import { isPlatformBrowser } from '@angular/common';
import { Component, OnInit, PLATFORM_ID, Inject, ApplicationRef } from '@angular/core';
import { Router } from '@angular/router';
import { filter, take } from 'rxjs/operators';
import { EventReplayer } from 'preboot';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  constructor(
    private router: Router,
    @Inject(PLATFORM_ID) private platformId: string,
    private appRef: ApplicationRef,
    private replayer: EventReplayer,
  ) {}

  ngOnInit() {
    this.router.initialNavigation();
    if (isPlatformBrowser(this.platformId)) {
      this.appRef.isStable
        .pipe(
          filter(stable => stable),
          take(1),
        ).subscribe(() => {
        this.replayer.replayAll();
      });
    }
  }
}

PrebootComplete

When you are manually replaying events, you often will want to know when Preboot is done replaying events and switching the buffers. To do this, use the following code in your app:

window.document.addEventListener('PrebootComplete', () => {
  // put your code here that you want to run once preboot is complete
});

Adding a nonce

If you're using a CSP, you'll need to add a nonce property to preboot's inline script. Preboot allows you to configure this by exporting an optional PREBOOT_NONCE token. Example usage is as follows (for an Express server):

import {PREBOOT_NONCE} from 'preboot';
import * as express from 'express';
import {v4} from 'uuid';
import * as csp from 'helmet-csp';

const app = express();

app.use((req, res, next) => {
  res.locals.nonce = v4();
  next();
});

app.use(csp({
  directives: {
    scriptSrc: [`'self'`, (req, res) => `'nonce-${ res.locals.nonce }'`],
    ...
  }
});

... express boilerplate ...

/* when it comes time to render the request, we can inject our new token */

app.get('*', (req, res) => {
  res.render('index', {
    req,
    res,
    providers: [
      {
        provide: PREBOOT_NONCE,
        useValue: res.locals.nonce
      }
    ]
  });
});

... other express route handling (see Universal guide for details) ...

Please note that only the nonce tag will appear on the script, the value is not rendered in modern browsers. If you want to make sure your nonce is generating correctly, you can add a callback onto your render method to examine the resultant HTML as follows:

res.render('index', (req, res) => {
  ...
}, function(error, html) {
  console.log(html.substring(0, 50)); // we only care about the top part
  res.send(html);
});

Browser support

If you wish to support Internet Explorer 9-11, you will need to include a Polyfill for CustomEvent.

preboot's People

Contributors

alan-agius4 avatar andersdjohnson avatar ankitu avatar ashsidhu avatar caeruskaru avatar dependabot[bot] avatar dockleryxk avatar jeffwhelpley avatar johngorter avatar josephliccini avatar laskoviymishka avatar leoaraujocosta avatar manekinekko avatar markpieszak avatar mgol avatar patrickjs avatar quovadisqc avatar splaktar avatar stefanrein avatar trotyl avatar valorkin avatar vvakame avatar wesleycho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

preboot's Issues

Flattened module structure broke imports on projects that don't contain Angular

Note: for support questions, please use the Universal Slack Channel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • Do you want to request a feature or report a bug?

Bug

  • What is the current behavior?
Error: Cannot find module '@angular/core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at /usr/src/app/node_modules/preboot/bundles/preboot.umd.js:2:82
    at Object.<anonymous> (/usr/src/app/node_modules/preboot/bundles/preboot.umd.js:5:2)
    at Module._compile (module.js:635:30)
    at Module._compile (/usr/src/app/node_modules/pirates/lib/index.js:91:24)
    at Module._extensions..js (module.js:646:10)
    at Object.newLoader [as .js] (/usr/src/app/node_modules/pirates/lib/index.js:96:7)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/src/app/build/webpack:/external "preboot":1:1)```

It seems that when the structure of the imports was flattened, the imports weren't made... optional? I'm not sure how these sorts of things actually work.

* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** by creating a github repo.

Use preboot in a repo that doesn't contain angular.

* **What is the expected behavior?**

The relevant modules import successfully and the missing peer dependencies are ignored.

* **What is the motivation / use case for changing the behavior?**

See above.

* **Please tell us about your environment:**

- Browser: [all]
- Language: [ ES6/7 | ES5 ]
- OS:  [ Linux ]
- Platform: [NodeJs]

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Preboot buffer doesn't start angular2 app after rendering

Transfer of issue for @jaumard from angular/universal#482

  • I'm submitting a ...
  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.
  • What is the current behavior?
    When we load a page, server rendering render the page correctly (the first time only because of this bu angular/universal#481) But once rendering is done angular 2 app doesn't seems to be started because if we click on router link the page is loaded instead of just the component.
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    Demo is here https://github.com/jaumard/trails-angular2-isomorphic, go to api/controllers/ViewController and enable the buffer option, then npm start and go to localhost:3000 if you click on Home or About you'll see the page is reload, router doesn't do his job.
  • What is the expected behavior?
    Once page is rendered angular2 app should take the lead like when buffer option is false
  • Please tell us about your environment:
  • Angular version: 2.0.0-rc4
  • Browser: [all]
  • Language: [all]
  • OS: [Mac OS X]
  • Platform: [NodeJs]

Build error with angular/universal

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    yarn build:dynamic and yarn build:static on the angular/universal app with prebuilt added errors out

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

Add preboot to the angular/universal app and run yarn build:dynamic or yarn build:static

  • What is the expected behavior?

Successful build

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Browser: N/A
  • Language: TS 2.5
  • OS: OS X
  • Platform: NodeJS
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
ERROR in ./node_modules/preboot/src/browser/browser-preboot.module.ts
Module build failed: Error: Typescript emitted no output for [REDACTED]/node_modules/preboot/src/browser/browser-preboot.module.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More https://github.com/Microsoft/TypeScript/issues/12358
    at successLoader [REDACTED]/node_modules/ts-loader/dist/index.js:47:15)
    at Object.loader ([REDACTED]/node_modules/ts-loader/dist/index.js:29:12)
 @ ./dist/server/main.bundle.js 1:17532-17585
 @ ./server.ts

ERROR in ./node_modules/preboot/src/browser/event.replayer.ts
Module build failed: Error: Typescript emitted no output for [REDACTED]/node_modules/preboot/src/browser/event.replayer.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More https://github.com/Microsoft/TypeScript/issues/12358
    at successLoader ([REDACTED]/node_modules/ts-loader/dist/index.js:47:15)
    at Object.loader ([REDACTED]/node_modules/ts-loader/dist/index.js:29:12)
 @ ./dist/server/main.bundle.js 1:73717-73762
 @ ./server.ts

ERROR in ./node_modules/preboot/src/server/server-preboot.module.ts
Module build failed: Error: Typescript emitted no output for [REDACTED]/node_modules/preboot/src/server/server-preboot.module.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More https://github.com/Microsoft/TypeScript/issues/12358
    at successLoader ([REDACTED]/node_modules/ts-loader/dist/index.js:47:15)
    at Object.loader ([REDACTED]/node_modules/ts-loader/dist/index.js:29:12)
 @ ./dist/server/main.bundle.js 1:73512-73563
 @ ./server.ts

new Event does not work in IE11, and unfortunately neither does the polyfill from MDN and this question: Internet Explorer 9, 10 & 11 Event constructor doesn't work, since they rely on document.createEvent.

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    A bug

  • What is the current behavior?
    'new Event' does not work in IE11, and unfortunately neither does the polyfill from MDN.
    The error raised is: Object doesn't support this action

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    Just launch the application on IE11 with buffer enabled.

  • What is the expected behavior?
    It should work for IE11 I think.

  • What is the motivation / use case for changing the behavior?
    It should work for IE11 I think.

  • Please tell us about your environment:

  • Browser: [ IE 11 ]
  • Language: [ ES5 ]
  • OS: [ Windows ]
  • Platform: [all | NodeJs | Java | PHP | .Net | Ruby]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

https://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
https://stackoverflow.com/questions/41575405/event-constructor-in-worker-on-ie11

http requests being called twice

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Report a bug

  • What is the current behavior?
    When loading a page with preboot installed, http calls are being run twice, once by the server and then again when the client app takes over.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

  1. Load a page which makes a http call (in this case using a resolve using the router)
  2. The page is correctly loaded but when checking logs, you will notice that the http call has been made twice

image

  • What is the expected behavior?
    The data to be cached instead of the request being called twice

  • Please tell us about your environment:

  • Browser: [Chrome 58.0.3029.110 (64-bit)]
  • Language: [TypeScript 2.3.4]
  • OS: [Mac OS X]
  • Platform: [NodeJs 6.9.4]

Component CSS Disappears from Components During Preboot

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests

My beautiful server-side rendered Angular 5 application (using Universal with a node express.js server) is having problems with styling during the bootstrap (preboot) phase. The global CSS stylesheet seems to be fine, but the component-specific styles disappear once bootstrapping begins.

This probably isn't the right way to report this issue, but please see my stackoverflow question for more details:
https://stackoverflow.com/questions/47701349/component-css-disappears-from-components-during-app-bootsrapping-with-preboot

window is not defined

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?
    Server side errors when loading page
ReferenceError: window is not defined                                                                                
    at EventReplayer.getWindow (/home/ubuntu/myapp/node_modules/preboot/src/browser/event.replayer.ts:31:35)     
    at EventReplayer.replayAll (/home/ubuntu/myapp/node_modules/preboot/src/browser/event.replayer.ts:47:30)     
    at SafeSubscriber._next (/home/ubuntu/myapp/node_modules/preboot/src/browser/browser-preboot.module.ts:24:20)
    at SafeSubscriber.__tryOrUnsub (/home/ubuntu/myapp/node_modules/rxjs/src/Subscriber.ts:254:10)               
    at SafeSubscriber.next (/home/ubuntu/myapp/node_modules/rxjs/src/Subscriber.ts:204:14)                       
    at Subscriber._next (/home/ubuntu/myapp/node_modules/rxjs/src/Subscriber.ts:135:22)                          
    at Subscriber.next (/home/ubuntu/myapp/node_modules/rxjs/src/Subscriber.ts:95:12)                            
    at FirstSubscriber._emitFinal (/home/ubuntu/myapp/node_modules/rxjs/src/operator/first.ts:157:19)            
    at FirstSubscriber._emit (/home/ubuntu/myapp/node_modules/rxjs/src/operator/first.ts:139:10)                 
    at FirstSubscriber._next (/home/ubuntu/myapp/node_modules/rxjs/src/operator/first.ts:117:12)   
  • If the current behavior is a bug, please provide the steps to reproduce

angular universal following this guide https://github.com/Gorniv/universal/tree/cli

app.server.module.ts

import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppModule } from './app.module';
import { AppComponent } from './components/app.component';
import {ServerPrebootModule} from "preboot/src/server/server-preboot.module";
import {BrowserModule} from "@angular/platform-browser";

@NgModule({
  imports: [
    BrowserModule.withServerTransition({ appId: 'uniapp' }),
    ServerModule,
    AppModule,
    ServerPrebootModule.recordEvents({ appRoot: 'app-root' })
  ],
  bootstrap: [AppComponent]
})
export class AppServerModule { }

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './components/app.component';
import { HomeComponent } from './components/home/home.component';
import { FilterPipe } from './pipes/filter.pipe';
import { DataService } from './services/data.service';
import { HttpModule } from '@angular/http';
import { LayoutService } from './services/layout.service';
import { SanitizeHtmlPipe } from './pipes/sanitize-html.pipe';
import { AppRoutingModule } from './app-routing.module';
import { Subject } from 'rxjs/Subject';
import { FormsModule } from '@angular/forms';
import { ApiService } from './services/api.service';
import {BrowserPrebootModule} from "preboot/src/browser/browser-preboot.module";

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    FilterPipe,
    SanitizeHtmlPipe,
 ],
  imports: [
    BrowserModule,
    HttpModule,
    AppRoutingModule,
    FormsModule,
    BrowserPrebootModule.replayEvents()
  ],
  providers: [
    DataService,
    ApiService,
    LayoutService,
    Subject,
  ],
  bootstrap: [AppComponent],
})
export class AppModule {
}

  • Please tell us about your environment:
  • Angular: 4.4.3

  • preboot: 5.0.0

  • Browser: Google Chrome 61.0.3163.100

  • Language: TypeScript 2.3.3

  • OS: Windows | Linux

  • Platform: NodeJs 8.5.0

notSupportedError on event creation for certain events in IE 11

  • I'm submitting a ...
    bug report

  • Which parts of preboot are affected by this issue?
    client side

  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    I received a Sentry error for notSupportedError shortly after implementing preboot on my project. All of the errors came from IE11. After doing some research, it seems like it's an issue with IE11 not supporting certain createEvent calls. I haven't found documentation on which calls are and aren't supported, but I figured I'd let you know about this.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    I don't have reproduction steps, on account of not having IE to run against and being unable to find that documentation.

  • What is the expected behavior?
    No error.

  • What is the motivation / use case for changing the behavior?
    Errors!

  • Please tell us about your environment:

  • Browser: IE 11 | Safari XX ]
  • OS: Windows
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
    See above.

This was the stackOverflow page that I found that had me thinking what I wrote above:
https://stackoverflow.com/questions/23142816/how-to-resolve-the-javascript-error-of-ckeditor-in-ie-11

Typescript compiler throws 'Cannot find require' error

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

bug

  • What is the current behavior?

I get an error and can't build the app.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

Follow the steps of this article https://medium.com/@evertonrobertoauler/angular-4-universal-app-with-angular-cli-db8b53bba07d to create a ssr. Add preboot following the instruction of the readme.md (Will provide a demo repo later this week if necessary)

  • Please tell us about your environment:
  • Browser: [--]
  • Language: [TypeScript 2.3.4]
  • OS: [Mac OS X]
  • Platform: [NodeJs 7.8.0]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

When I add declare var require: any; to the top of server/inline.preboot.code.ts The error is solved. Seems like my attemp to compile my app with ngc also compiles server.ts (because of the import in app.server.module.ts) instead of taking the precompiled files

inject inlinePrebootCode in HEAD? or immediately after appRoot

  • I'm submitting a ...
  • bug report
  • Which parts of preboot are affected by this issue?
  • server side
  • inline

According to the README:

You then inject inlinePrebootCode into the HEAD section of your server-side template.

But that doesn't work, at least, in the following cases:

  • With Angular 2x auto bootstrap (using ng-app or data-ng-app attr on your app root), this inline script seems to only work at the very end of the <body> (presumably because Angular waits for DOM ready event before executing)
    • in other words, the waitUntilReady must not (even with setTimeout of 1) be getting executed fast enough
  • With Angular 4x, where Angular's bootstrapModule code can happen before DOM ready event, then this inline script only works when immediately after the app root.

So I'm proposing, assuming someone can corroborate, that the guidance be changed to insert the "inlinePrebootCode" immediately after the app root element (so it works in most (all?) cases)

Cannot read property 'prebootData' of undefined

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?

I have added preboot to my angular 4.1.3 isomorphic application and it's returning these two following errors on the console;

  • ERROR TypeError: Cannot read property 'prebootData' of undefined

  • ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'prebootData' of undefined. TypeError: Cannot read property 'prebootData' of undefined

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

// app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
import {AppRouting} from './app.routing';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    AppRouting,
    BrowserModule.withServerTransition({
      appId: 'universal-demo'
    })
  ]
})
export class AppModule {}
// app-server.module.ts

import {NgModule} from '@angular/core';
import {ServerModule} from '@angular/platform-server';
import {ServerPrebootModule} from 'preboot/server';
import {AppComponent} from './app.component';
import {AppModule} from './app.module';

@NgModule({
  bootstrap: [
    AppComponent
  ],
  imports: [
    AppModule,
    ServerModule,
    ServerPrebootModule.recordEvents({
      appRoot: 'universal-demo'
    })
  ]
})
export class AppServerModule {}
// app-browser.module.ts

import {NgModule} from '@angular/core';
import {BrowserPrebootModule} from 'preboot/browser';
import {AppComponent} from './app.component';
import {AppModule} from './app.module';

@NgModule({
  bootstrap: [
    AppComponent
  ],
  imports: [
    AppModule,
    BrowserPrebootModule.replayEvents()
  ]
})
export class AppBrowserModule {}
  • Please tell us about your environment:
  • Browser: [Chrome 58.0.3029.110 (64-bit)]
  • Language: [TypeScript 2.3.4]
  • OS: [Mac OS X]
  • Platform: [NodeJs 6.9.4]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
// package.json

"dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/platform-server": "^4.0.2",
    "@angular/router": "^4.0.0",
    "@nguniversal/express-engine": "^1.0.0-beta.2",
    "angular2-jwt": "^0.2.0",
    "bootstrap": "^4.0.0-alpha.6",
    "core-js": "^2.4.1",
    "preboot": "^5.0.0-rc.8",
    "rxjs": "5.0.1",
    "webpack-node-externals": "^1.6.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/compiler": "^4.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@mogusbi/gulp-starter": "github:mogusbi/gulp-starter#version2",
    "@ngtools/webpack": "^1.3.0",
    "@types/express": "^4.0.35",
    "@types/jasmine": "^2.5.35",
    "@types/node": "^6.0.45",
    "@types/uglify-js": "^2.6.28",
    "angular-router-loader": "^0.5.0",
    "angular2-template-loader": "^0.6.2",
    "awesome-typescript-loader": "^3.1.2",
    "express": "^4.15.2",
    "express-history-api-fallback": "^2.1.0",
    "express-http-proxy": "^0.11.0",
    "html-loader": "^0.4.5",
    "istanbul-instrumenter-loader": "^2.0.0",
    "jasmine-core": "^2.5.2",
    "karma": "^1.5.0",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.1.0",
    "karma-mocha-reporter": "^2.2.2",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-remap-coverage": "^0.1.4",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^2.0.3",
    "rev-replace-loader": "^0.1.4",
    "tslib": "^1.6.0",
    "typescript": "^2.2.1",
    "webpack": "^2.2.1",
    "webpack-merge": "^4.1.0"
  }

Preboot is not working with `app-shell` (pre-rendering)

I'm submitting a ...

  • bug report

Which parts of preboot are affected by this issue?

  • client side (Application Shell)

What is the current behavior?

When building an app shell, the preboot script present in that pre-rendered document causes undesired behavior:

  • While the client app bootstraps (no PWA), preboot doesn't capture events (or, if it does, it doesn't replay them after the client app bootstraps); The first obvious thing that can be noticed is that pressing of a button before the client app bootstraps doesn't trigger the preboot overlay.
  • Sometimes (while emulating a Slow 3G connection), Preboot doesn't make the switch to the client app (easily noticeable in the example repo, since the header brand and menu button don't get some styles applied in the server rendered view - material 5.2.x bug)
  • Even after the client app bootstraps, the pressing of a button (like the menu button in the example repo) triggers the preboot overlay;

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

https://github.com/MrCroft/ng-app-shell-preboot
Just npm install, npm run build:ssr & npm run serve:ssr

What is the expected behavior?

  1. Preboot should still work when using an App Shell (no PWA).
  2. Not sure what should happen in case of a PWA, when the app shell is served by the Service Worker. How would Preboot know which scenario is the current one?

What is the motivation / use case for changing the behavior?

SSR and PWA are not mutually exclusive. We still need SSR for SEO and first load of the app. The Service Worker needs a document to cache (ideally, a document with the main layout present - like header/navigation/footer).
Initially I thought that the preboot script should not even be present in the prerendered app shell document, but when thinking about it: one might use an App Shell and not use SSR. Or, in case of a PWA - you still want both.

Please tell us about your environment:

Preboot: 6.0.0-beta.2
Angular: 5.2.5
Angular CLI: 1.7.0
Node: 8.9.4
OS: All

Rename noReplay to replay

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

A feature (renaming an existing feature).

  • What is the current behavior?

PrebootModule.withConfig accepts noReplay as a parameter, false by default.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

N/A

  • What is the expected behavior?

The property should be named replay and be true by default, just like buffer.

  • What is the motivation / use case for changing the behavior?

It's well established that negatives are more difficult to read, especially when assigned a negative value, creating a double negative. Current API is also inconsistent with the buffer option that is set to true by default.

  • Please tell us about your environment:

N/A

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Preboot 6 requires a different way of importing inside of an Angular NgModule so people upgrading will have to change their imports anyway. That's a good opportunity to rename the confusingly named option.

cc @CaerusKaru as we talked about it outside of GitHub.

https api url fail in ssr for meta tags

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

  • What is the current behavior?
    For meta information we pulling from api.
    Using http SSR working perfect
    Using https SSR not working.

Any help

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

  • What is the expected behavior?

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5 ]
  • OS: [all | Mac OS X | Windows | Linux ]
  • Platform: [all | NodeJs | Java | PHP | .Net | Ruby]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Flattened module structure broke imports on projects that don't contain Angular

Note: for support questions, please use the Universal Slack Channel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • Do you want to request a feature or report a bug?

Bug

  • What is the current behavior?
Error: Cannot find module '@angular/core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at /usr/src/app/node_modules/preboot/bundles/preboot.umd.js:2:82
    at Object.<anonymous> (/usr/src/app/node_modules/preboot/bundles/preboot.umd.js:5:2)
    at Module._compile (module.js:635:30)
    at Module._compile (/usr/src/app/node_modules/pirates/lib/index.js:91:24)
    at Module._extensions..js (module.js:646:10)
    at Object.newLoader [as .js] (/usr/src/app/node_modules/pirates/lib/index.js:96:7)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/src/app/build/webpack:/external "preboot":1:1)

It seems that when the structure of the imports was flattened, the imports weren't made... optional? I'm not sure how these sorts of things actually work. The code it's complaining about is here.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

Use preboot in a repo that doesn't contain angular.

  • What is the expected behavior?

The relevant modules import successfully and the missing peer dependencies are ignored.

  • What is the motivation / use case for changing the behavior?

See above.

  • Please tell us about your environment:
  • Browser: [all]
  • Language: [ ES6/7 | ES5 ]
  • OS: [ Linux ]
  • Platform: [NodeJs]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Preboot with buffer true causes crash

Transferred over from angular/universal#458. Originally entered by @sittingbool

Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

  • I'm submitting a ...
  • [x ] bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.
  • What modules are related to this pull-request
  • express-engine
  • grunt-prerender
  • gulp-prerender
  • hapi-engine
  • [x ] preboot
  • universal-preview
  • universal
  • webpack-prerender
  • Do you want to request a feature or report a bug?

Report a bug.

  • What is the current behavior?

I am using the current universal-starter project. I wanted to see if buffering helps avoid the page to be re-rendered on client. So I set this option to true.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
  1. change preboot: false to preboot: { appRoot: 'app', buffer: true }
  2. restart server and relpad page
  3. see server console output, which shows:

TypeError: Cannot read property 'unsubscribe' of undefined
at Router.dispose (/Users/myUser/myProject/node_modules/@angular/router/router.js:117:71)
Rendering Document Error: [TypeError: Cannot read property 'unsubscribe' of undefined]
at /Users/myUser/myProject/node_modules/@angular/router/common_router_providers.js:16:56
at /Users/myUser/myProject/node_modules/@angular/core/src/application_ref.js:428:68
at Array.forEach (native)
at Object.Call (/Users/myUser/myProject/node_modules/angular2-universal/node_modules/angular2-universal-polyfills/node_modules/es6-shim/es6-shim.js:289:14)
at Array.forEach (/Users/myUser/myProject/node_modules/angular2-universal/node_modules/angular2-universal-polyfills/node_modules/es6-shim/es6-shim.js:1295:17)
at ApplicationRef_.dispose (/Users/myUser/myProject/node_modules/@angular/core/src/application_ref.js:428:32)
at /Users/myUser/myProject/node_modules/angular2-universal/dist/node/bootloader.js:156:45
at ZoneDelegate.invoke (/Users/myUser/myProject/node_modules/angular2-universal/node_modules/angular2-universal-polyfills/node_modules/zone.js/dist/zone-node.js:281:29)
at Zone.run (/Users/myUser/myProject/node_modules/angular2-universal/node_modules/angular2-universal-polyfills/node_modules/zone.js/dist/zone-node.js:174:44)

  • What is the expected behavior?

No error on server-side

  • What is the motivation / use case for changing the behavior?

I hope buffering so the page doesn't re-render on client.

  • Please tell us about your environment:
  • Angular version: 2.0.0-beta.2
  • Browser: [Chrome Version 51.0.2704.103 (64-bit) ]
  • Language: [TypeScript 1.8.10 ]
  • OS: [Mac OS X ]
  • Platform: [NodeJs]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Error: Cannot set property 'prebootData' of undefined

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?
    After adding [email protected], in my [email protected] application, getting this error on SSR,
    'Uncaught TypeError: Cannot set property 'prebootData' of undefined'

screen shot 2018-09-22 at 3 06 02 pm

screen shot 2018-09-22 at 3 06 39 pm

screen shot 2018-09-22 at 3 07 15 pm

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

I have added PrebootModule in my root.module.ts like this:-

import { BrowserModule } from "@angular/platform-browser";
import { PrebootModule } from 'preboot';
import { ServerTransition } from "./server-transition.module";
import { RootComponent } from "./root.component";
...

@NgModule({
  imports: [
    ...,
    BrowserModule.withServerTransition({ appId: 'ng-web-app' }),
    PrebootModule.withConfig({ appRoot: 'root'}),    // 'root' is the selector of root component
    ...

  ],
  declarations: [
    RootComponent,
    ...
  ]
})
export class RootModule {}

and my root.server.module.ts :-

import {NgModule} from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';
import { RouterModule } from '@angular/router';

import {RootModule} from '../client/root.module';
import {Root} from '../client/root.component';

@NgModule({
  imports: [
    RootModule,
    ServerModule,
    ModuleMapLoaderModule
  ],
  bootstrap: [Root],
  providers: []
})
export class RootServerModule {}

  • What is the expected behavior?
    This error should not occur and the transition between SSR and CSR should be smooth.

  • Please tell us about your environment:

  • Language: [TypeScript ]
  • Platform: [ NodeJs | Angular-5.2.1 ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Server module exceedes call stack

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    bug

  • What is the current behavior?

RangeError: Maximum call stack size exceeded
at _createProviderInstance$1 (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9531:35)
at resolveNgModuleDep (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9520:17)
at _createClass (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9561:29)
at _createProviderInstance$1 (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9535:26)
at resolveNgModuleDep (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9520:17)
at _createClass (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9561:29)
at _createProviderInstance$1 (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9535:26)
at resolveNgModuleDep (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9520:17)
at _createClass (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9561:29)
at _createProviderInstance$1 (/home/ubuntu/stack/angular/node_modules/@angular/core/bundles/core.umd.js:9535:26)

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    use the ServerModule with recordEvents({ appRoot: 'app-root' })

  • What is the expected behavior?
    angular should be able to bootstrap without errors

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Browser: all
  • Language: TypeScript
  • OS: Mac OS X | Linux
  • Platform: NodeJs
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

feat(csp): add nonce to preboot to avoid CSP conflict

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

Bug report

  • What is the current behavior?

Currently preboot injects a script into the HTML which is blocked from running if the CSP does not contain unsafe-inline.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

Load preboot, add CSP header script-src: 'self' 'unsafe-eval', receive error

  • What is the expected behavior?

Preboot should add a nonce to its script, randomly generated on each load

  • What is the motivation / use case for changing the behavior?

It allows for better security in writing CSP rules to not have to accommodate preboot

Object doesn't support property or method 'from': IE11

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Report a bug

  • What is the current behavior?
    On IE11, Win 10. The following code will give a 'error: Object doesn't support property or method 'from''. It is part of the inline script.

// we want to add an event listener for each node and each event for (var _i = 0, _a = Array.from(nodes); _i < _a.length; _i++) { var node = _a[_i]; _loop_1(node); }

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    Just refresh the webpage with debugger catching the error.

  • What is the expected behavior?
    The error should not be there.

  • What is the motivation / use case for changing the behavior?
    I am debugging a problem where the whole node is deleted when client tries to bootstrap, leaving the webpage a solid white screen. This happens 9/10 times after refresh, on IE10/11/Edge, but sometimes also on Safari.

  • Please tell us about your environment:

  • Browser: [IE 11 ]
  • Language: [ ES5 ]
  • OS: [ Mac OS X ]
  • Platform: [browser]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Preboot 6.0.0-beta.1 doesn't seem to do anything when used with Angular Upgrade (ngUpgrade)

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

A bug. There was already a question about that above in the issue template...

  • What is the current behavior?

Preboot doesn't seem to do anything when hooked up as described in README in an app using Angular Upgrade. Input focus is not preserved, its value is lost. I've also noticed AppComponent#ngOnInit is fired twice.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
  1. Clone https://github.com/mgol/angular-preboot-bug and follow README instructions to run the app.
  2. Open Chrome DevTools and enable network throttling, setting it to "Slow 3G".
  3. Load the page and when the input appears, write something in it.
  4. Wait for the JS to finish downloading and Angular to kick in.
  • What is the expected behavior?

Input focus state & its value should be preserved.

  • What is the motivation / use case for changing the behavior?

Core functionality of Preboot doesn't work due to this bug.

  • Please tell us about your environment:
  • Browser: Chrome 64
  • Language: TypeScript 2.6.2
  • OS: macOS
  • Platform: Node.js
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

If you disable Angular Upgrade (in the linked reproduction repo you can revert to the previous commit on master) AppComponent#ngOnInit is fired only once but Preboot still doesn't work due to #66.

Angular 6

Is there some plans to make it Angular 6 and rxjs comaptible?
If this is the case - when?

add condition to check that the application root is available in the DOM before prebooting

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

bug

  • What is the current behavior?

To me it seems there is a big conceptual problem:

Currently the preboot-code is injected into the documents head and waits until document.body evaluates to a positive value (is reachable).
Ok but this does not mean that the entire applications dom is already available:
The body is available before their children (observed in latetest chrome browser: Version 64.0.3282.140 (Developer-Build) (64-Bit)).

<body> <!-- document.body is true before document.querySelect('application') gets a value other than null -->
    <application></application>
</body>

So we will get a "No server node found for selector: ...".

Even if somebody uses the body itself as application's mount point:

<body application></body>
  • We have two bodies (client and server one) during preboot: This may introduces some other problems.
  • We have no switching buffer caused by:
if (!clientView || !serverView || serverView === clientView || serverView.nodeName === 'BODY') {
    return;
}

Don't understand why but you will have your reasons for this condition. The comment "if no client view or the server view is the body or client and server view are the same, then don't do anything and return" only re-describes the code but not why it is necessary.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

In my optionion there does not actually exists an example where this lib works without any monkey patches (no buffer switch or "No server node found ..." issue).

  • What is the expected behavior?

This lib should start recording events right after the application's dom is available. In my optinion this would only work if we inject the preboot code right after the applications root dom node (mountpoint). Maybe we would have an application specific preboot code.

  • What is the motivation / use case for changing the behavior?

Making this library and cool idea work.

  • Please tell us about your environment:
  • Browser: [Chrome 64]
  • Language: [TypeScript X.X | ES6/7]
  • OS: [Linux]
  • Platform: [NodeJs|Chrome]

refactor: change project structure to Angular Library format

Currently the package is built in such a way that a lot of files are duplicated as both ts and js files. The project should be refactored to use a build process similar to Angular core, Material, and Flex-Layout, with multiple bundles for ES5 and ES2015.

At the very least, it would allow for top-level imports instead of import * from 'preboot/src' as currently required.

Add lifecycle hook for BufferSwitchComplete

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

Request a feature

  • What is the current behavior?

The preboot module switches from the server view to the client view silently

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

  • What is the expected behavior?

Allow for detection in the client app for transition from server view to client view

  • What is the motivation / use case for changing the behavior?

Writing a carousel component that requires calculating the size of the component at the point of rendering. As the component is (very usefully) hidden, it has no size, so as the component initialises it returns a width of 0.

  • Please tell us about your environment:
  • Browser: [all]
  • Language: [all]
  • OS: [all]
  • Platform: [NodeJs]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Does preboot support Angular 4?

  • I'm submitting a ...
  • bug report
  • feature request
  • question
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests

I think the title is clear, and I want to ask if Preboot supports Angular 4 (or users should just use platform-server) then we need to specify that in docs, or talking about how to implement it with different versions of Angular (actually preboot seems to work with any front-end framework but still need some explanation)

inline.preboot.code.ts throws warning with Webpack

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    When building the server side application Webpack throws this warning

WARNING in /Volumes/Data/Users/mo/Repos/universal-test/~/preboot/src/server/inline.preboot.code.ts
41:12-40 "export 'hasOwnProperty' (imported as 'eventRecorder') was not found in './event.recorder'
  • What is the expected behavior?
    No warnings to be thrown

  • Please tell us about your environment:

  • Browser: n/a
  • Language: TypeScript 2.4.2
  • OS: Mac OS X
  • Platform: NodeJs

Big FOUC as server side styles removed before the switch to client side

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

A bug.

  • What is the current behavior?

Server-side styles are in some scenarios removed by Angular before Preboot switches the app to the client-side one, causing a potentially huge flash of unstyled content.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
  1. Clone https://github.com/mgol/angular-server-bug and follow README instructions to run the app.
  2. Load the page & observe it (it may take ~15 seconds).
  • What is the expected behavior?

There should be no visible app swap. Styles shouldn't disappear before the app is switched to the client side one.

  • What is the motivation / use case for changing the behavior?

Current behavior looks really broken to the end user.

  • Please tell us about your environment:
  • Browser: Chrome 64
  • Language: TypeScript 2.6.2
  • OS: macOS
  • Platform: Node.js
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

This issue happens if a component is hidden behind *ngIf and the condition is set to a truthy one only after some time - in particular, when waiting for a specific HTTP request to finish. Angular thinks the client side app is ready as it bootstrapped correctly and it just waits for the HTTP request to finish to swap the flag. However, Preboot still waits for the app to get stable so it shows the server-side generated one. Unfortunately, its inline styles are already removed and the new ones are not loaded yet as Angular haven't created the component yet client side.

preboot with appRoot being the root HTML tag

Hello,

I'm trying do make some basic seo with an angular application.
My index.html is:

<!doctype html>
<html lang="en"></html>

The application root component from a universal perspective is the html component.

The issue is the preboot code is append after the closing html tag which makes preboot unavailable to the global scope:

<!doctype html>
<html>
 generated by universal
</html>
<div>
    <style>preboot css</style>
    <script>preboot js</script
</div>

In this case, it should generate:

<!doctype html>
<html>
 generated by universal
<div>
    <style>preboot css</style>
    <script>preboot js</script
</div>
</html>

Is there a trick to make it work?
I tried to load preboot_browser in the browser via the html component and call preboot.complete but I couldn't end up with something that actually work.

Error after click on checkbox

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    Error in console after click on checkbox
    angularuniversal 2017-06-05 10-24-58

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    Create app with one or more checkboxes and try to check preboot clicking on it

  • What is the expected behavior?
    No errors in console, correct replay click on checkbox event

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX ]
  • Language: [all | TypeScript 2.3.3 | ES6/7 | ES5 ]
  • OS: [all | Mac OS X | Windows | Linux ]
  • Platform: [all | NodeJs | Java | PHP | .Net | Ruby]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

bug(webpack): Typescript emitted no output

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

Bug report

  • What is the current behavior?

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

  1. Prepare a Universal bundle as specified here
  2. Attempt to compile using npm run build:dynamic
  3. Receive the below error
  • What is the expected behavior?

Should be able to compile a bundle that relies on preboot

  • What is the motivation / use case for changing the behavior?

Unable to use webpack to build a nodejs bundle from a TypeScript source

  • Please tell us about your environment:
  • Language: [all | TypeScript 2.5.2 | ES6/7 | ES5 ]
  • OS: [all | Mac OS X | Windows | Linux ]
  • Platform: [all | NodeJs | Java | PHP | .Net | Ruby]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
ERROR in ./node_modules/preboot/src/server/server-preboot.module.ts
Module build failed: Error: Typescript emitted no output for /home/debian/angular2/ngvirtualgrade/node_modules/preboot/src/server/server-preboot.module.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More https://github.com/Microsoft/TypeScript/issues/12358

ng serve & ng e2e fails when using preboot with angular CLI

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    ng serve and ng e2e are failing with the following error log in the console:

C:\Users\PrebootPC\Desktop\Projects\Preboot\Preboot>ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-11-06T10:04:48.102Z
Hash: 3d6f41a2627365d2252f
Time: 11686ms
chunk {auth.module} test.module.chunk.js, auth.module.chunk.js.map () 148 kB  [rendered]
chunk {email.module} auth.module.chunk.js, email.module.chunk.js.map () 3.61 kB  [rendered]
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 82.5 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 217 kB [initial] [rendered]
chunk {settings.module} settings.module.chunk.js, settings.module.chunk.js.map () 6.87 kB  [rendered]
chunk {storage.module} welcome.module.chunk.js, welcome2.module.chunk.js.map () 3.66 kB  [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 77.1 kB [initial] [rendered]
chunk {tasks.module} home.module.chunk.js, core.module.chunk.js.map () 51.7 kB  [rendered]
chunk {updates.module} test2.module.chunk.js, updates.module.chunk.js.map () 3.66 kB  [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 7.39 MB [initial] [rendered]

ERROR in ./node_modules/preboot/src/browser/browser-preboot.module.ts
Module build failed: Error: C:\Users\PrebootPC\Desktop\Projects\Preboot\Preboot\node_modules\preboot\src\browser\browser-preboot.module.ts is not part of the compilation output. Please check the other error messages for details.
    at AngularCompilerPlugin.getCompiledFile (C:\Users\PrebootPC\Desktop\Projects\Preboot\Preboot\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
    at plugin.done.then (C:\Users\PrebootPC\Desktop\Projects\Raya\raya\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
 @ ./src/app/app.module.ts 15:0-82
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

webpack: Failed to compile.
Build did not succeed. Please fix errors before running e2e task
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

  • What is the expected behavior?
    app should serve with ng serve
    e2e tests should pass.

  • Please tell us about your environment:

  • Browser: [Chrome 63]
  • Language: [TypeScript 2.6.1]
  • OS: [Windows]
  • Platform: [NodeJs]

image

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

ng build --prod & ng test do not emit the error described.

Preboot buffer: Application bootstrap on the server generated node.

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?
    Sometime the application bootstrap on server generated DOM node, leaving the hidden buffer empty.
    When this happened, once the app is stable, preboot will delete the node containing the booted application and leave the empty buffer node.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    So here is the code causing the issue:

  • app.module.ts

const eventSelectors: any[] = [
  { selector: 'input,textarea', events: ['keypress', 'keyup', 'keydown', 'input', 'change'] },
  { selector: 'select,option', events: ['change'] },
  { selector: 'input', events: ['keyup'], preventDefault: true, keyCodes: [13], freeze: true },
  { selector: 'form', events: ['submit'], preventDefault: true, freeze: true },
  { selector: 'input,textarea', events: ['focusin', 'focusout', 'mousedown', 'mouseup'], replay: false },
  { selector: 'button,hg-event-bet-type-item', events: ['click'], preventDefault: true, freeze: true }
];
@NgModule({
  imports: [
    AppRoutingModule,
    BrowserTransferStateModule,
    HttpClientModule,
    BrowserModule,
    ServerTransition.forRoot({ appId: 'hg-customer' }),
    PrebootModule.withConfig({ appRoot: 'hg-root', replay: false, eventSelectors }),
  ],
  declarations: [ ],
  providers: [{ provide: HTTP_INTERCEPTORS, useClass: TransferHttpCacheInterceptor, multi: true }]
})
export class AppModule { }
  • app.server.module.ts
@NgModule({
  imports: [ServerModule, AppModule, ServerTransferStateModule],
  bootstrap: [AppComponent]
})
export class AppServerModule {}
  • app.browser.module.ts
@NgModule({
  imports: [AppModule],
  bootstrap: [AppComponent]
})
export class AppBrowserModule {  }
  • app.component.ts
@Component({
  selector: 'hg-root',
  template: `<router-outlet></router-outlet>`
})
export class AppComponent {
  constructor(
    @Inject(PLATFORM_ID) private platformId: string,
    private eventReplayer: EventReplayer,
    private appRef: ApplicationRef
  ) {
    if (isPlatformBrowser(this.platformId)) {
      this.appRef.isStable.pipe(filter((isStable: boolean) => isStable), take(1))
        .toPromise()
        .then(() => {
          if (!document.querySelector('hg-root').innerHTML.length) {
            debugger;
            console.log(document.body.innerHTML);
          }
          this.eventReplayer.replayAll();
        });
    }
  }
}
  • body part of index.html:
<body>
  <hg-root>Loading...</hg-root>
</body>
  • What is the expected behavior?
    The application should boot everytime in the buffer DOM node

  • Please tell us about your environment:

  • Browser: Chrome 67
  • Language: TypeScript 2.7.1
  • OS: Windows
  • Platform: Nodejs
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
    As you can see in the file app.component.ts, I trigger a debugger; when the buffer is empty while the app is stable. When this is the case, the DOM look like this:
    booted
    Once the replayAll() is done, it's only leaving the empty hg-root node in the DOM.
    To be sur that the app was boostrapping in the wrong node, I changed some string the client main.js file. Those string were changed in the second hg-root DOM node, proving the application is well booted but in the wrong node.

After futher search, it appear that the bootstrap of the application is started before preboot can create the buffer node. The bootstrap was done in the event DOMContentLoaded, for now I had a setTimeout(10) to go with the waitUntilReady preboot function and it seems to be ok.

Preboot suffers from race conditions

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?

A bug.

  • What is the current behavior?

Currently Preboot suffers from various race conditions:

  1. It waits for the document.body to be available and then applies its logic. However, the application root may not be available at this point - see issue #72.
  2. Even if application root exists when Preboot starts listening for events the server node may not be available in full yet. Since Preboots searches for nodes matching desired selectors inside of the existsing serverNode, it may skip some of them if the server node hasn't loaded fully. This is especially common if the internet connection is slow.
  3. Preboot waits for body in a tight loop, checking every 10 milliseconds. This starves the browser but may also be clamped by it to a larger delay (around 1 second); that's what happens in modern browsers if the tab where the page loads is inactive, e.g. if you open a link in a new tab in Chrome or Firefox. This means Preboot may start listening for events after Angular reports the app is stable and the PrebootComplete event fires. This then leaves the server node active, never transferring to the client one which makes for a broken site.
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

I don't have a quick test case at hand; however, the description from the previous point shows how to reproduce it.

  • What is the expected behavior?

Preboot shouldn't suffer from race conditions.

  • What is the motivation / use case for changing the behavior?

The current behavior is buggy as described above.

  • Please tell us about your environment:
  • Browser: all
  • Language: all
  • OS: all
  • Platform: all
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
  1. Since we want to attach event listeners as soon as possible when the server node starts being available (so that it can be shallow-cloned) we cannot wait for it to be available in full. Therefore, we need to use delegated event handlers on document instead of on specific nodes.
  2. As we support multiple app roots, to not duplicate large inline preboot code, we'll split getInlinePrebootCode into two parts: function definitions to be put in <head> and the invocation separate for each app root put just after the app root opening tag. We'll maintain getInlinePrebootCode for backwards compatibility but we'll no longer use it internally.
  3. To maintain children offset numbers (otherwise selectors won't match between the client & the server) we'll remove the in-app-root script immediately when it starts executing; this won't stop execution. document.currentScript is a good way to find the currently running script but it doesn't work in IE. We'll need to apply a fallback behavior for IE, perhaps by tagging each script with a unique attribute value and injecting this value as a variable into the script.
  4. We'll remove waitUntilReady as there's no reliable way to wait; we'll invoke the init code immediately instead.
  5. We'll attach the overlay used for freeing the UI to document.documentElement instead of document.body so that we don't have to wait for body.

Lazy loaded routes makes page flicker

  • I'm submitting a ...
  • bug report
  • Which parts of preboot are affected by this issue?
  • client side
  • What is the current behavior?
    When injector.get(ApplicationInitStatus).donePromise resolves
    angular removes all styles with 'ng-transition' from the header.
    And if you use lazy route for current page you can see
    the messing on the page for some time (depends on amount
    of components on the page).
    You can see it like a short flicker when reload the page.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    https://github.com/misticwonder/preboot-bug2

  • What is the expected behavior?
    No flicker

  • Please tell us about your environment:

  • Browser: [Chrome Version 62.0.3202.75 (Official Build) (64-bit) ]
  • OS: [ Linux ]

[Issue] when browser refresh, rendered DOM is gone

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?
    Chrome 60: browser refresh

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    https://github.com/gmanio/ng-ssr

  • What is the expected behavior?
    refresh well

Cleanup PrebootOverlay after preboot finishes.

Note: for support questions, please use the Universal Slack Channel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Request a feature

  • What is the current behavior?
    When prebooting finishes, it leaves a prebootOverlay div behind. I think this should be cleaned up if this has no purpose after preboot is done.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
    Not a bug

  • What is the expected behavior?
    I think this should be cleaned up if this has no purpose after preboot is done.

  • What is the motivation / use case for changing the behavior?
    Cleaner HTML document after preboot

  • Please tell us about your environment:

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5 ]
  • OS: [all | Mac OS X | Windows | Linux ]
  • Platform: [all | NodeJs | Java | PHP | .Net | Ruby]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Preboot 4.3 - cannot find module 'preboot' - Ng_preboot (Universal)

Preboot 4.3 : from angular/universal-starter#142
(Here for reference)

It works well before updating preboot, after updating preboot to v4.3.0, got error:

module.js:442
throw err;
^

Error: Cannot find module 'preboot'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (/xxx/universal-starter/node_modules/angular2-universal/dist/node/ng_preboot.js:3:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
[nodemon] app crashed - waiting for file changes before starting...


It looks like Preboot isn't publishing all the needed files? The d.ts is there, but a lot of things seem missing in dist. Jeff, know you already knew about this, just put it here in case others ran into it!

webpack fails at importing preboot/browser

Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    We get the following error from ts-loder:

Module build failed: Error: Typescript emitted no output for /Users/jeremy/Documents/workspace/zmbSSR/node_modules/preboot/browser.ts.
You should not need to recompile .ts files in node_modules.
Please contact the package author to advise them to use --declaration --outDir.
More microsoft/TypeScript#12358
at successLoader (/Users/jeremy/Documents/workspace/zmbSSR/node_modules/ts-loader/dist/index.js:47:15)
at Object.loader (/Users/jeremy/Documents/workspace/zmbSSR/node_modules/ts-loader/dist/index.js:29:12)
@ ./build/app/app.ts 16:16-42
@ ./build/app/app.ngfactory.ts
@ ./build/app/app.browser.ts

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.

Webpack needs to be configured to load typescript files:

resolve: {
    extensions: ['.ts', '.js']
},
module: {
    loaders: [
        { test: /\.ts$/, loader: 'awesome-typescript-loader' }
    ]
},
  • What is the expected behavior?
    no typescript files should be provided inside the published node module.

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

  • Browser: all
  • Language: TypeScript
  • OS: Mac OS X
  • Platform: NodeJs
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Events not replaying due to mismatched server/client nodes

  • I'm submitting a ...
  • bug report
  • feature request
  • Which parts of preboot are affected by this issue?
  • server side
  • client side
  • inline
  • build process
  • docs
  • tests
  • What is the current behavior?
    Preboot (v. 6.0.0-beta.1) will not replay events on the client-side because client and server nodes do not match. When specifying the eventSelectors, getting the following warnings:

nothing found for INPUT#money-input so using INPUT

No matching client node found for INPUT_app-root_s2_s5_s1_s2_s2_s1_s1_s2_s2. You can fix this by assigning this element a unique id attribute.

and

Trying to dispatch event keydown to node INPUT_app-root_s2_s5_s1_s2_s2_s1_s1_s2_s2 but could not find client node. Server node is: [...]

image

  1. Clone the project and run npm install
  2. Run npm run start-universal to run the application with SSR
  3. Navigate to localhost:3000 and open devtools
  4. Under the network tab, set the network throttling to a slower connection (2G or 3G) and hard-refresh the page
  5. While the server-side page is displayed and client is loading, enter a number in the input field and press enter on the keyboard (there are some dummy callbacks to show that the events are being recorded on the server-side)
  6. Expected behavior is for page to freeze until client is bootstrapped, then events to be replayed (including form submission upon enter), but the warnings above will print the console and events will not replay.
  • What is the expected behavior?
    Client and server nodes should match. The input element in question has a unique ID called #money-input (not sure where INPUT_app-root_s2_s5_s1_s2_s2_s1_s1_s2_s2 is coming from?) and events should replay upon client bootstrap.

  • Environment:

  • Browser: all
  • Language: TypeScript 2.4.2/Angular 5.0.0
  • OS: Windows
  • Platform: NodeJs
  • Other information
    Could this maybe be a Material or minification thing? I tried using Material directives for the event selectors, but that didn't help.

Might be worth mentioning that I tried with an older version of Preboot (5.1.7) and got the keypress events to replay except for the enter key/form submission. That version had no problems with Angular 4 either.

At this point, any info on this is appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.