Skip to content

fix(@ngtools/webpack): fix error #4078

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

Merged
merged 1 commit into from
Jan 18, 2017
Merged

fix(@ngtools/webpack): fix error #4078

merged 1 commit into from
Jan 18, 2017

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Jan 17, 2017

When calling getText() it's important to use the SourceFile, otherwise in some cases the node doesn't have an internal SourceFile property and TypeScript throws an error.

Also moved the acceptance test to be a Jasmine spec in @ngtools/webpack. This is faster and I made it more accurate (rather than mocking everything).

Fix #4072

@hansl hansl merged commit e91552f into angular:master Jan 18, 2017
@Splaktar
Copy link
Contributor

Thank you for the quick response @hansl! I'd love to be able to run master with this fix, but it doesn't appear to be functional atm.

@jschwarty
Copy link
Contributor

Yes, thank you @hansl for the quick fix! This error drove me insane today. Looking forward to this being available on npm.

@diegovilar
Copy link

@hansl, I've just installed version 1.0.0-rc.1 and created a test project wtih ng new trese-sitemobile. Didn't change anything in the project.

ng build works fine.
ng serve works fine.
ng build --prod fails.
ng serve --prod fails.

Here's the output for ng version in the project folder:

@angular/cli: 1.0.0-rc.1
node: 6.10.0
os: win32 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.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

And here's the output for ng build --prod:

D:\dev\SiteMobile\trese-sitemobile>ng build --prod
Hash: 2bbdb9e96c288ee40e43
Time: 9287ms
chunk    {0} polyfills.28a09e20f5736e6a970b.bundle.js (polyfills) 153 kB {3} [initial] [rendered]
chunk    {1}  (styles) 1.72 kB {3} [initial] [rendered]
chunk    {2} main.69441850b2d22bca2f39.bundle.js (main) 1.18 MB [initial] [rendered]
chunk    {3} inline.dcc04371985807de2ad8.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in D:/dev/Projects/SiteMobile/trese-sitemobile/src/app/app.module.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53644:77)
    at refactor.findAstNodes.filter (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:129:10)
    at Promise.resolve.then (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:292:33)
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 13:0-48
 @ D:/dev/Projects/SiteMobile/trese-sitemobile/src/main.ts
 @ multi ./src/main.ts

ERROR in D:/dev/Projects/SiteMobile/trese-sitemobile/src/app/app.component.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53644:77)
    at refactor.findAstNodes.filter (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:129:10)
    at Promise.resolve.then (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:292:33)
 @ ./src/$$_gendir/app/app.component.ngfactory.ts 12:0-51
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ D:/dev/Projects/SiteMobile/trese-sitemobile/src/main.ts
 @ multi ./src/main.ts

@hansl hansl deleted the module-id-fix branch August 2, 2018 19:59
@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 12, 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

Successfully merging this pull request may close these issues.

ng serve: Cannot read property 'text' of undefined
5 participants