Coder Social home page Coder Social logo

Comments (7)

jkuri avatar jkuri commented on September 27, 2024

hi @sebastianmacias. check out src/app/app.module.universal.ts file, should look similar to yours src/app/app.module.ts but with UniversalModule on top.

from angular-rollup-starter.

sebastianmacias avatar sebastianmacias commented on September 27, 2024

Thanks for the tip @jkuri, that took care of the issue. However I'm now getting:

`--------------------------------------------
✔ SASS Build Time: 131ms
✔ AoT Build Time: 17.12s
✔ Build time: 6.85s
✔ Optimizing time: 14.10s

app.js (838.679 KB) -> app.js.gz (164.706 KB)

Build: 39108.421ms

[email protected] prerender /home/dev/Tests/angular-rollup-starter
node ./scripts/index.js --prerender


EXCEPTION: element.addEventListener is not a function
ORIGINAL STACKTRACE:
TypeError: element.addEventListener is not a function
at /home/dev/Tests/angular-rollup-starter/node_modules/@angular/material/bundles/material.umd.js:450:78
at Map.forEach (native)
....
`

This is how my app.module.universal.ts looks like (UniversalModule on top)

`import { UniversalModule } from 'angular2-universal';
import { MaterialModule } from '@angular/material';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
UniversalModule,
FormsModule,
MaterialModule.forRoot()
],
entryComponents: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
`

from angular-rollup-starter.

jkuri avatar jkuri commented on September 27, 2024

thats because universal works in node and not in browser, which means addEventListener is not recognized. in most cases jsdom takes care of that, for example if you do window.addEventListener it should work, but looks like not on an element.
if you place that listener somewhere in your code, try putting this in front;

if (typeof window === 'undefined') { 
  return;
}

I am using this workaround when getting similar errors and it works.
hovever, if this listener comes from material I believe only way is to open an issue there about universal or to create your own build with workaround above.

from angular-rollup-starter.

sebastianmacias avatar sebastianmacias commented on September 27, 2024

perfect! tnx again

from angular-rollup-starter.

jkuri avatar jkuri commented on September 27, 2024

no problem, were you able to solve it?

from angular-rollup-starter.

sebastianmacias avatar sebastianmacias commented on September 27, 2024

Unfortunately I ran into additional compatibility issues of Angular Material with Angular Universal. Everything should work once this issue is closed.

from angular-rollup-starter.

jkuri avatar jkuri commented on September 27, 2024

cool 👍 actually with a release of Angular 4 Universal will be built-in (Match 1st) and I will drop support on this starter since universal better works with webpack. I personally liked the speed of rebuilds with rollup but webpack improved that alot. there's no big difference in rebuilds lately.

actually universal is built-in Angular 4 since beta 8, if you are interested in demo please check https://github.com/robwormald/ng-universal-demo.
Closing this now.

from angular-rollup-starter.

Related Issues (10)

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.