Skip to content

Failure when _removeDecorators is called #5416

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

Closed
1 task
rightisleft opened this issue Mar 14, 2017 · 7 comments
Closed
1 task

Failure when _removeDecorators is called #5416

rightisleft opened this issue Mar 14, 2017 · 7 comments

Comments

@rightisleft
Copy link

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.0.0-rc.1
node: 6.9.1
os: darwin x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.0
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

Repro steps.

ng build --prod

The log given by the failure.

I just updated to angular-cli 1.0.0-rc1 after following the upgrade instructions on the wiki.

When i run ng serve - the app behaves correctly.

When i run ng build - the app behaves correctly.

When I run ng build --target=production --environment=prod
I get the following:

➜  web git:(master) ✗ ng build --target=production --environment=prod
Hash: 1e69750dbc9679bddab0
Time: 69052ms
chunk    {0} main.8839163bd6c77300ac2a.bundle.js (main) 1.11 MB {3} [initial] [rendered]
chunk    {1} styles.014a26b5c21b6bdedf9e.bundle.css (styles) 440 bytes {4} [initial] [rendered]
chunk    {2} scripts.73c5e350c283a9340ddc.bundle.js (scripts) 146 kB {4} [initial] [rendered]
chunk    {3} vendor.f208e8b0304d6a96ac3d.bundle.js (vendor) 2.54 MB [initial] [rendered]
chunk    {4} inline.1eab99acff53ba884df2.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ../api/src/business/dtos/modifier.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
    at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:129:10)
    at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:292:33)
 @ ./src/app/model-labels/model-label.component.ts 3:0-51
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

ERROR in ../api/src/business/dtos/document.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
    at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:129:10)
    at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:292:33)
 @ ./src/app/document-viewer/document-viewer.component.ts 2:0-51
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

ERROR in ../api/src/business/dtos/models.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
    at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:129:10)
    at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:292:33)
 @ ./src/app/model-sublabel/model-sublabel.component.ts 1:0-46
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

ERROR in ../api/src/business/dtos/lens.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
    at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:129:10)
    at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/@ngtools/webpack/src/loader.js:292:33)
 @ ./src/app/create-lens/create-lens.component.ts 2:0-43
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

ERROR in main.8839163bd6c77300ac2a.bundle.js from UglifyJs
Unexpected token: name (FooterComponent) [main.8839163bd6c77300ac2a.bundle.js:7,6]

How do i get my app to compile correctly for production?

UPDATE 1:
Here's an example of one of the offending files. ColumnTypes.TEXT is a public value. As these are just decorators, they have no external dependencies. Again, this works fine for non production builds.

import {autoserialize} from "cerialize";
import {ManyToOne, PrimaryGeneratedColumn, Column, JoinColumn, OneToOne, OneToMany, Table, ColumnTypes, CreateDateColumn} from "./export.dtos";

@Table()
export class DTOModifier {
  
  @PrimaryGeneratedColumn()
  @autoserialize id: number;
    
  @Column(ColumnTypes.TEXT, {nullable: true})
  @autoserialize label: string;
}

Where:

static TEXT: ColumnType;
@clydin
Copy link
Member

clydin commented Mar 14, 2017

Can you run 'npm ls @ngtools/webpack' and post the output here?

@rightisleft
Copy link
Author

➜  web git:(master) npm ls @ngtools/webpack
web@0.0.0 /Users/jmurphy/projects/ubq/web
├─┬ @angular/cli@1.0.0-rc.1
│ └── @ngtools/webpack@1.2.12
├── UNMET PEER DEPENDENCY @angular/common@2.4.9
├── UNMET PEER DEPENDENCY @angular/core@2.4.9
└── UNMET PEER DEPENDENCY @angular/platform-browser@2.4.9

npm ERR! peer dep missing: @angular/common@2.4.0, required by @angular/router@3.4.0
npm ERR! peer dep missing: @angular/core@2.4.0, required by @angular/router@3.4.0
npm ERR! peer dep missing: @angular/platform-browser@2.4.0, required by @angular/router@3.4.0

@rightisleft
Copy link
Author

package.json

{
  "name": "web",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "killAll": "pkill -f angular-cli",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.9",
    "@angular/compiler": "^2.4.9",
    "@angular/core": "^2.4.9",
    "@angular/forms": "^2.4.9",
    "@angular/http": "^2.4.9",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "3.4.0",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.19",
    "angular2-loaders-css": "1.0.5",
    "cerialize": "0.1.13",
    "core-js": "2.4.1",
    "ng2-charts": "1.4.4",
    "ng2-page-scroll": "^4.0.0-beta.3",
    "ng2-select": "^1.2.0",
    "ng2-toasty": "2.2.2",
    "puse-icons-feather": "^1.1.0",
    "reflect-metadata": "0.1.9",
    "rxjs": "^5.0.1",
    "ts-helpers": "1.1.1",
    "typeorm": "https://github.com/typeorm/typeorm.git",
    "typescript": "^2.2.0",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.1",
    "@angular/compiler-cli": "^2.4.9",
    "@types/jasmine": "2.5.38",
    "@types/node": "6.0.42",
    "bootstrap": "4.0.0-alpha.6",
    "codelyzer": "~2.0.0-beta.1",
    "font-awesome": "4.7.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.0.2",
    "karma-remap-istanbul": "0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "2.1.0",
    "tslint": "4.3.0"
  }
}

@rightisleft
Copy link
Author

FYI - just updated to rc2 - same result.

@rightisleft
Copy link
Author

rightisleft commented Mar 14, 2017

Looks like this is an issue with using symlinks.

Context: DTO's are used to establish a common interface between a typescript front-end and backend. In order to ensure sync - they live in their own repository and are symlink'd into place.

I deleted the symlink and just cp'd them into the web project -> executed ng build --prod and the errors dropped away.

This is a diagnosis, not a fix.

Note: ERROR in ../api/src/business/dtos/models.dto.ts

@filipesilva
Copy link
Contributor

Dupe of #5098

@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants