Universal: Fix 2.1.1 _private_ import issues

Created on 24 Oct 2016  ·  27Comments  ·  Source: angular/universal

  • I'm submitting a ...
  • [X] bug report
  • What modules are related to this Issue?
  • [x] platform-node

In the latest Core/Compiler upgrades to 2.1.1, compiler-private & core-private have changed a few things Universal uses.

__compiler_private__ looks to of been removed from @angular/compiler.

SelectorMatcher & CssSelector (needed for Universal), seem to be public now.

Also _ViewUtils seems to be missing / removed from __core_private__
It looks like it was renamed to view_utils ?

Seems to fix it:

import {
  SelectorMatcher as SelectorMatcher211, 
  CssSelector as CssSelector211 } from '@angular/compiler';

let SelectorMatcher;
let CssSelector;

if (SelectorMatcher211 && CssSelector211) {
  SelectorMatcher = SelectorMatcher211;
  CssSelector = CssSelector211;
} else {
  const _compiler_private_  = require('@angular/compiler').__compiler_private__;
  SelectorMatcher = _compiler_private_.SelectorMatcher;
  CssSelector = _compiler_private_.CssSelector;
}

ViewUtils -> view_utils can be handled in a similar way.

Most helpful comment

Let me make sure the workaround still works for the latest Angular release and I'll talk to @gdi2290 about it, see if it's possible to squeeze this in there!
Apologies guys!

All 27 comments

Can we merge this? Or is there any issues with this PR?

Any news on this issue?

I'll talk to Pat about it today and let you guys know @stanbe @aiboy.
We have a nice workaround file for now you can use (and import at the top of your browser/node modules) for the time being as well. (https://github.com/angular/universal-starter/tree/master/src - you can see the workaround files in here)

Hi. Is this issue fixed? I am still getting this error, using angular2-universal version ~2.1.0-rc.1

@MarkPieszak I followed the link you posted and added those files to my project, and then imported the appropriate ones into my client.ts and server.ts

Unfortunately I'm still getting the same error. Here are my versions, if that is any help too:

    "@angular/common": "~2.1.2",
    "@angular/compiler": "~2.1.2",
    "@angular/core": "~2.1.2",
    "@angular/forms": "~2.1.2",
    "@angular/http": "~2.1.2",
    "@angular/platform-browser": "~2.1.2",
    "@angular/platform-browser-dynamic": "~2.1.2",
    "@angular/platform-server": "~2.1.2",
    "angular2-express-engine": "~2.1.0-rc.1",
    "angular2-platform-node": "~2.1.0-rc.1",
    "angular2-universal": "~2.1.0-rc.1",
    "angular2-universal-polyfills": "~2.1.0-rc.1",

You have it setup similar to how the starters have it? Included at the top of each of those files? @ScaryWolfMan

@MarkPieszak Yep! :(

It isn't working for me with 2.2.3 either. But there's a 90% chance I'm
just too tired to work on this now.

On Wed, Dec 14, 2016, 02:25 ScaryWolfMan notifications@github.com wrote:

@MarkPieszak https://github.com/MarkPieszak Yep! :(


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/universal/issues/606#issuecomment-266945951,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABeg9ClkQlbYh_vnaPykJvpBh2KV7nOcks5rH33JgaJpZM4KeRBn
.

I'm a newibe to universal but it seems like a pretty daunting task trying to manage all the various angular projects and making sure everything works. :o

This error is rather annoying and the workaround is by definition just a workaround, not really satisfying. Is there still an issue with the pull request? @MarkPieszak @aiboy

@stanbe I'm not a maintainer :/ so I can't do anything about it.

And yes, we have Angular 2.3 already, but I still can't update Angular-Universal. This is sad.

Let me make sure the workaround still works for the latest Angular release and I'll talk to @gdi2290 about it, see if it's possible to squeeze this in there!
Apologies guys!

@MarkPieszak I've reverted to 2.10 and I'm able to run my project without any issues at the moment.

how can we build with universal? We're started using angular2-webpack-starter

Check out the universal node starter to see what you need to add to the webpack-starter, check out the documentation.md file here as well that talks about the necessary files. @fdambrosio

thanks @MarkPieszak we have "Call to Node module failed with error: TypeError: Cannot read property 'SelectorMatcher' of undefined" message error

If you're using the workaround I think you can't use Angular 2.3 as some other things changed. Can you take it down to 2.2 and see if it works?
As we move some Core things from Universal into AngularCore itself, it'll help alleviate problems like this from happening!

@MarkPieszak I was having the same issue, but I'm now using angular 2.1.0 and angular-universal 2.0.11. no longer getting any issues :(

Workarounds from universal-starter repository is working well with Angular 2.4.1!

Oh that's great news 👍 haven't been able to check on holiday this week. @dimonzav

@dimonzav I just tried update to 2.4.1 version and adding files: __workaround.browser, __workaround.node.
Then adding appropriate import statements to server.ts and client.ts files and it didn't work. What did you do or what I did wrong?

I tried the workaround. But still facing the problem in [email protected]; currently using the latest 2.1.0-rc.1 version of Universal. Anything more to do?

Do you have it setup just like in the universal starter? @parkourkarthik

I'm a noob and I'm using the Asp.net Core with Angular template. I faced this when I upgraded all my packages to the latest version. But now I downgraded all packages to the same in the template (2.0.10); so working for now.
I'm scared of upgrading the packages again. It seems there are multiple dependencies of packages which raise these errors; any guidelines would be helpful.

This template here has everything a little more up to date and is .net, take a look at the dependencies. https://github.com/MarkPieszak/aspnetcore-angular2-universal

Don't worry about warnings during install for now. @ParkourKarthik

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._

Was this page helpful?
0 / 5 - 0 ratings