ES2015 support
Bug Report
What is the expected behavior?
To make FlexLayoutServerModule work under firebase cloud function.
What is the current behavior?
Getting an error after successful deploy to a firebase.
What are the steps to reproduce?
- Create Angular repo with SSR
- Add FlexLayout
- Use firebase to deploy cloud function
functions/package.json
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "index.js",
"dependencies": {
"@angular/animations": "^7.1.0",
"@angular/cdk": "^7.1.0",
"@angular/common": "^7.1.0",
"@angular/compiler": "^7.1.0",
"@angular/core": "^7.1.0",
"@angular/flex-layout": "^7.0.0-beta.22",
"@angular/forms": "^7.1.0",
"@angular/http": "^7.1.0",
"@angular/platform-browser": "^7.1.0",
"@angular/platform-browser-dynamic": "^7.1.0",
"@angular/platform-server": "^7.1.0",
"@angular/router": "^7.1.0",
"@nguniversal/common": "^7.0.2",
"@nguniversal/express-engine": "^7.0.2",
"@nguniversal/module-map-ngfactory-loader": "^7.0.2",
"@types/smoothscroll-polyfill": "^0.3.0",
"firebase-admin": "^6.4.0",
"firebase-functions": "^2.1.0",
"compression": "^1.7.3",
"core-js": "^2.5.4",
"express": "^4.16.4",
"hammerjs": "^2.0.8",
"rxjs": "^6.3.3",
"smoothscroll-polyfill": "^0.4.3",
"ts-loader": "^5.3.0",
"zone.js": "^0.8.26",
"reflect-metadata": "^0.1.12"
},
"devDependencies": {
"tslint": "^5.11.0",
"typescript": "^3.1.6"
},
"private": true
}
app.server.module.ts
imports: [
AppModule,
ServerModule,
ModuleMapLoaderModule,
ServerTransferStateModule,
FlexLayoutServerModule,
],
bootstrap: [AppComponent],
})
export class AppServerModule {}
error I am getting
TypeError: this.marshal.init is not a function
at LayoutAlignDirective.BaseDirective2.init (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-core.umd.js:2416:22)
at new LayoutAlignDirective (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-flex.umd.js:1529:15)
at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:20747:24)
at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:20616:24)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21842:40)
at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22158:17)
at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22077:17)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21870:9)
at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:21756:9)
at Object.createProdRootView [as createRootView] (/user_code/node_modules/@angular/core/bundles/core.umd.js:22268:16)
at resolvePromise (/user_code/node_modules/zone.js/dist/zone-node.js:814:31)
at resolvePromise (/user_code/node_modules/zone.js/dist/zone-node.js:771:17)
at /user_code/node_modules/zone.js/dist/zone-node.js:873:17
at ZoneDelegate.invokeTask (/user_code/node_modules/zone.js/dist/zone-node.js:421:31)
at Object.onInvokeTask (/user_code/node_modules/@angular/core/bundles/core.umd.js:16192:37)
at ZoneDelegate.invokeTask (/user_code/node_modules/zone.js/dist/zone-node.js:420:36)
at Zone.runTask (/user_code/node_modules/zone.js/dist/zone-node.js:188:47)
at drainMicroTaskQueue (/user_code/node_modules/zone.js/dist/zone-node.js:595:35)
at ZoneTask.invokeTask (/user_code/node_modules/zone.js/dist/zone-node.js:500:21)
at ZoneTask.invoke (/user_code/node_modules/zone.js/dist/zone-node.js:485:48)
rejection:
TypeError: this.marshal.init is not a function
at LayoutAlignDirective.BaseDirective2.init (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-core.umd.js:2416:22)
at new LayoutAlignDirective (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-flex.umd.js:1529:15)
at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:20747:24)
at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:20616:24)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21842:40)
at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22158:17)
at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22077:17)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21870:9)
at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:21756:9)
at Object.createProdRootView [as createRootView] (/user_code/node_modules/@angular/core/bundles/core.umd.js:22268:16),
promise:
ZoneAwarePromise {
__zone_symbol__state: 0,
__zone_symbol__value:
TypeError: this.marshal.init is not a function
at LayoutAlignDirective.BaseDirective2.init (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-core.umd.js:2416:22)
at new LayoutAlignDirective (/user_code/node_modules/@angular/flex-layout/bundles/flex-layout-flex.umd.js:1529:15)
at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:20747:24)
at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:20616:24)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21842:40)
at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22158:17)
at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22077:17)
at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21870:9)
at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:21756:9)
at Object.createProdRootView [as createRootView] (/user_code/node_modules/@angular/core/bundles/core.umd.js:22268:16) },
zone:
Zone {
_properties: { isAngularZone: true },
_parent:
Zone {
_properties: {},
_parent: null,
_name: '<root>',
_zoneDelegate: [Object] },
_name: 'angular',
_zoneDelegate:
ZoneDelegate {
_taskCounts: [Object],
zone: [Circular],
_parentDelegate: [Object],
_forkZS: null,
_forkDlgt: null,
_forkCurrZone: [Object],
_interceptZS: null,
_interceptDlgt: null,
_interceptCurrZone: [Object],
_invokeZS: [Object],
_invokeDlgt: [Object],
_invokeCurrZone: [Circular],
_handl
Can you post a minimal reproduction repository for this? SSR issues are tough to debug unless we have the while picture.
I am afraid that I can do that only after holidays. I can try to create a demo but my hopes are very low during the holidays sorry.
Didn't notice this was a duplicate at first. Thanks for pointing out @CaerusKaru hopefully I added some helpful info in the other issue.
Anyways @Layyy you should be able to workaround for now if you can get the firebase project to target es5.
@epelc No worries, it was non-obvious. Thanks for identifying the root cause, I'll work with Paul to track this down.
Marking this as blocked on https://github.com/angular/angular/issues/27267. Workaround for now is as @epelc said, use ES5. Alternatively, you could reimplement the directives using explicit constructors, and declare those instead. We're opting not to in order to cut down on complexity and breaking changes for people using custom breakpoints.
I have similar issue #959. I solve the problem by downgrade version to beta.19 for now.
In my project for flex-layout I use this workaround from material.
@dima11221122 Be advised that Material reverted that change, see here. The workaround may still work for you if you don't use Closure Compiler, but for those who do beware.
At least for angular-cli projects it works properly:)
Angular cli projects default to es5. I’m actually using an angular cli project but wanted to target es2015 instead.
@CaerusKaru - Has this been fixed with @devversion UMD Build improvements ?
@ThomasBurleson Nope, this is a deeper issue involving the Angular compiler
"La solución": Volver a es5 "target": "es6" to "target": "es5", Eso es una simple solutions cerebritos
angular/angular#27267 has been patched, so this should be fixed in the next release.
Should be fixed with the latest release.
@CaerusKaru I'm sorry I missed that, which release version you are saying this is fixed? Is it 8.x? If so does that mean we need to upgrade everything to latest 8.x
@CaerusKaru Do you know why this would be popping up again(with angular 8 and flex-layout beta 26) when building using the following options? I think the fix would be in that release.
npx ng build --prod --aot=false --build-optimizer=false
It works fine if you do a regular prod build with aot and the build optimizer enabled but a prod build without that doesn't work. Also works in dev mode or if you target es5 instead of es2015(differential loading in angular 8).
Maybe it is a bug with the fix that it works in full aot+prod but not in prod with aot+build optimizer turned off?

fyi - for me this issue occurs for using flex layout v7.0.0-beta.24 with angular 7.2.15 (i.e. not just an angular 8 issue as suggested above). I had rolled back a failed ng 8 upgrade, but my tsconfig was still targeting es2015, and that's when this flex layout issue cropped up for me. I changed my tsconfig.json's back to targeting es5 and the issue cleared up in my dev build (ng build --dev).
Having same issue as @epelc
Using flex beta 26 and angular 8
And this is set in my prod build
"optimization": true,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
Only solution I have found is to set "optimization": false, and then it will run but then that isnt really ideal. Is there any update on a resolution for this?
Update:
I set target to es5 in the tsconfig.json and build worked, but es2015 does not
@CaerusKaru can we get this reopened?