Comments (7)
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.
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.
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.
perfect! tnx again
from angular-rollup-starter.
no problem, were you able to solve it?
from angular-rollup-starter.
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.
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)
- spawn npm ENOENT HOT 19
- How to include rxjs map operator in vendor.ts ? HOT 4
- Karma tests not working HOT 4
- How to: use javascript library with Angular2 + Rollup ? HOT 12
- Error headling HOT 4
- How to include 3rd party libs HOT 2
- [Feature] Istanbul
- How to use .scss syntax, and also compile scss in components? HOT 7
- How do we setup universal for dynamic routes like event/dynamiceventid ?
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 angular-rollup-starter.