Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build optimizer after optimize not a function error #12146

Closed
alexeagle opened this issue Sep 4, 2018 · 5 comments
Closed

build optimizer after optimize not a function error #12146

alexeagle opened this issue Sep 4, 2018 · 5 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given
Milestone

Comments

@alexeagle
Copy link
Contributor

From @Mightforanis1938 on February 16, 2018 14:20

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

Copied from original issue: angular/devkit#443

@alexeagle alexeagle added comp: angular-devkit/build-optimizer needs: repro steps We cannot reproduce the issue with the information given labels Sep 4, 2018
@alexeagle
Copy link
Contributor Author

From @filipesilva on February 22, 2018 21:20

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@alexeagle
Copy link
Contributor Author

From @vincentjames501 on April 27, 2018 20:5

Try importing from here instead ('rxjs/observable/timer'). This got me too.

@Ristaaf
Copy link

Ristaaf commented Oct 24, 2018

Might be this issue ReactiveX/rxjs#4070
Since Angular 7 is using rxjs 6.3 instead of 6.2

@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.

If the problem persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants