angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

Ivy and reflect-metadata causes TypeError #16870

Closed noxi515 closed 4 years ago

noxi515 commented 4 years ago

🐞 bug report

Affected Package

not sure.

Is this a regression?

Yes. Angular8 and Angular9 (ivy disabled) works well.

Description

Using both @grapecity/wijmo.angular2.all library and import-metadata causes TypeError on bootstrap.

🔬 Minimal Reproduction

  1. ng new to generate new project.
  2. npm i -P @grapecity/wijmo.angular2.all to install library.
  3. Add WjGridModule to AppModule, and edit app.component.html.
  4. Add import 'reflect-metadata' in main.ts

https://github.com/noxi515/angular-wijmo-reflect-issue

🔥 Exception or Error


Reflect.js:541 Uncaught TypeError: decorator is not a function
    at DecorateConstructor (Reflect.js:541)
    at Object.decorate (Reflect.js:130)
    at push../node_modules/@grapecity/wijmo.angular2.grid/__ivy_ngcc__/index.js.__decorate (index.js:18)
    at index.js:45
    at Object../node_modules/@grapecity/wijmo.angular2.grid/__ivy_ngcc__/index.js (index.js:45)
    at __webpack_require__ (bootstrap:79)
    at Module../src/app/app.module.ts (app.module.ts:1)
    at __webpack_require__ (bootstrap:79)
    at Module../src/main.ts (main.ts:1)
    at __webpack_require__ (bootstrap:79)

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.1
Node: 12.14.1
OS: win32 x64

Angular: 9.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2
filipesilva commented 4 years ago

I think this happens because of processing done in Angular CLI, so I am transferring it there.

petebacondarwin commented 4 years ago

So the error is thrown because the decorators array is 1-based rather than 0-based. And we are iterating down to the zeroth term in the array.

See this screenshot...

Screenshot 2020-02-07 at 19 16 05

clydin commented 4 years ago

This looks like it may be an issue with the reflect-metadata package. By including the package, the behavior of the TypeScript helper __decorate changes to use the Reflect.decorate function provided by reflect-metadata. As shown above, the Reflect.decorate function does not guard against undefined decorators. The __decorate helper, however, does provide a guard for such an occurrence when Reflect.decorate is not present (code).

Does the application or any of its dependencies directly use the reflect metadata functionality? Angular applications built with the CLI have not required a reflect metadata polyfill (core-js was used) since version 8.0.4. Before that version it was only required for JIT builds.

dgp1130 commented 4 years ago

Also reflect-metadata is listed as deprecated: https://angular.io/guide/deprecations#reflect-metadata.

angular-automatic-lock-bot[bot] commented 4 years ago

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.