Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

build optimizer after optimize not a function error #443

@Mightforanis1938

Description

@Mightforanis1938

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Area

- [x ] devkit
- [ ] schematics

Versions

node --version v8.9.4
npm --version 5.6.0

Repro steps

I have an angular module with an observable timer

private scheduleRefresh() {
       const source = this.tokenStream.flatMap(
           token => {
               return Observable.timer(5000);
           });

       // Once the delay time from above is
       // reached, get a new JWT and schedule
       // additional refreshes
       source.subscribe(() => {
           this.getNewJwt();
       });
   }

module Inports:

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/timer';
import { Injectable, Injector } from '@angular/core';
import { Router } from '@angular/router';
import { TranslationService } from 'angular-l10n';
import { JwtHelperService } from '@auth0/angular-jwt'
import { UILocalStorageOption, UIStateService } from 'app/core/service/uiState.service';
import { PasswordReset } from 'app/userprofile/model/passwordreset';
import { environment } from 'environments/environment';
import { ToastrService } from 'ngx-toastr';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { ActionError } from 'app/shared/actionError';
import { HttpClient, HttpResponse, HttpHeaders } from '@angular/common/http';
import { HttpErrorResponse } from '@angular/common/http/src/response';

and after build with build optimizer:

 t.prototype.scheduleRefresh = function() {
                var t = this;
                this.tokenStream.flatMap(function(t) {
                    return o.a.timer(5e3)
                }).subscribe(function() {
                    t.getNewJwt()
                })
            }

The log given by the failure

message: "o.a.timer is not a function"
stack: "TypeError: o.a.timer is not a function"

It works when the set to --build-optimizer=false but when is turned on and after the build when the scheduleRefresh is called throws a not a function error

"dependencies": {
        "@angular/animations": "5.1.3",
        "@angular/cdk": "5.0.3",
        "@angular/common": "5.1.3",
        "@angular/compiler": "5.1.3",
        "@angular/core": "5.1.3",
        "@angular/forms": "5.1.3",
        "@angular/http": "5.1.3",
        "@angular/material": "5.0.3",
        "@angular/platform-browser": "5.1.3",
        "@angular/platform-browser-dynamic": "5.1.3",
        "@angular/router": "5.1.3",
        "@types/lodash": "4.14.91",
        "@types/moment": "2.13.0",
        "@types/jquery": "3.2.17",
        "@types/quill": "1.3.5",
        "@auth0/angular-jwt": "1.0.0-beta.9",
        "angular-cropperjs": "0.1.5",
        "angular-l10n": "4.1.3",
        "angular-tree-component": "5.2.1",
        "angular2-moment": "1.7.1",
        "angular2-recaptcha": "0.4.1",
        "bootstrap": "3.3.7",
        "core-js": "2.5.3",
        "devextreme": "17.2.4",
        "devextreme-angular": "17.2.4",
        "devextreme-intl": "17.2.4",
        "fast-json-patch": "2.0.6",
        "file-saver": "1.3.2",
        "font-awesome": "4.7.0",
        "jquery": "3.2.1",
        "js2xmlparser": "3.0.0",
        "metismenu": "2.7.2",
        "mobx-angular": "1.9.0",
        "ng-sidebar": "6.0.5",
        "ngx-quill": "2.1.1",
        "ngx-toastr": "7.0.0",
        "rxjs": "5.5.6",
        "web-animations-js": "2.3.1",
        "xlsx": "0.11.2",
        "zone.js": "0.8.19"
    },
    "devDependencies": {
        "@angular-devkit/build-optimizer": "0.3.1",
        "@angular/cli": "1.6.3",
        "@angular/compiler-cli": "5.1.3",
        "@angular/language-service": "5.1.3",
        "@types/jasmine": "2.5.54",
        "@types/metismenu": "2.7.1",
        "@types/node": "6.0.95",
        "codelyzer": "4.0.2",
        "concurrently": "3.5.1",
        "jasmine-core": "2.8.0",
        "jasmine-spec-reporter": "4.1.1",
        "karma": "1.7.1",
        "karma-chrome-launcher": "2.1.1",
        "karma-cli": "1.0.1",
        "karma-coverage-istanbul-reporter": "1.3.3",
        "karma-jasmine": "1.1.1",
        "karma-jasmine-html-reporter": "0.2.2",
        "node-sass": "4.7.2",
        "protractor": "5.1.2",
        "ts-node": "3.2.2",
        "tslint": "5.3.2",
        "typescript": "2.5.3",
        "webpack-bundle-analyzer": "2.9.1"
    }

it does not work with "@angular-devkit/build-optimizer": "0.4.0" either.
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions