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

Fix for 2 years old issue StaticInjectorError error when --bundle-dependencies=all #15498

Closed
naveedahmed1 opened this issue Aug 31, 2019 · 4 comments · Fixed by #15502
Closed

Comments

@naveedahmed1
Copy link

🐞 Bug report

This is about the issue reported at #8616 .

Its a 2 years old issue with still no fix from Angular team. Since that issue has been closed, I am creating a new issue.

When we set "bundleDependencies": "all", in angular.json file, which we normally do for SSR/Universal apps (specifically for .net/.net core applications its required), and also have "optimization": true,. The generated bundle throws below error:

NodeInvocationException: StaticInjectorError(AppServerModule)[InjectionToken Application Initializer -> InjectionToken DocumentToken]: 
StaticInjectorError(Platform: core)[InjectionToken Application Initializer -> InjectionToken DocumentToken]: 
Right-hand side of 'instanceof' is not an object
TypeError: StaticInjectorError(AppServerModule)[InjectionToken Application Initializer -> InjectionToken DocumentToken]: 
StaticInjectorError(Platform: core)[InjectionToken Application Initializer -> InjectionToken DocumentToken]: 
Right-hand side of 'instanceof' is not an object

I believe the reason of this is the compress and mangle option of terser plugin.

If we set --keep-fnames for terser plugin for server bundles or when using "bundleDependencies": "all", this issue can be resolved.

--keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name.

I have verified this and it works as mentioned here #8616 (comment)

@alan-agius4
Copy link
Collaborator

Thanks @naveedahmed1, I'll be looking at this today or tomorrow!

@naveedahmed1
Copy link
Author

@alan-agius4 a fix for this issue should also close these issues:

#12273
#8616
#7200

@alan-agius4
Copy link
Collaborator

Hi @naveedahmed1, the linked issues don’t seem related to
optimization.

vikerman pushed a commit that referenced this issue Sep 3, 2019
vikerman pushed a commit that referenced this issue Sep 3, 2019
@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 Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants