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

Using module with SSR from angular cli gives import error #31

Closed
jimmy-tfp opened this issue Sep 9, 2017 · 10 comments
Closed

Using module with SSR from angular cli gives import error #31

jimmy-tfp opened this issue Sep 9, 2017 · 10 comments

Comments

@jimmy-tfp
Copy link

jimmy-tfp commented Sep 9, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Our SSR app is built using this guide: https://github.com/angular/angular-cli/wiki/stories-universal-rendering and works well. However if you npm install --save this module you get:

import xyz
^^^^^^
SyntaxError: Unexpected token import

when you run in on the server with "node server.js"

It works very well if we just build it in our app, Thanks!

Expected behavior

It runs on the server.

Minimal reproduction of the problem with instructions

Build a SSR app using the above guide. I could start over an make one if you want?

What is the motivation / use case for changing the behavior?

Works on the server.

Environment


Angular version: 4.2.4

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  v6.11.2 
- Platform:  Mac

Others:
@jimmy-tfp jimmy-tfp changed the title Using module with SSR give import error Using module with SSR from angular cli gives import error Sep 9, 2017
@nicky-lenaers
Copy link
Owner

Hi @jimmy-tfp, thank you for submitting your issue. I will be investigating this soon!

@jacobedawson
Copy link

@nicky-lenaers I just ran into this issue as well - the error only came up while building for SSR, same error as what @jimmy-tfp reported.

Thanks for your work on the module but I would say until this issue is resolved you might want to remove the mention on the repo homepage that this module works with SSR.

@nicky-lenaers
Copy link
Owner

@jacobedawson @jimmy-tfp I'm working on this issue. Will be resolved soon!

@jacobedawson
Copy link

@nicky-lenaers thanks for your effort dude, in all other aspects it's a great module :)

@nicky-lenaers
Copy link
Owner

@jacobedawson @jimmy-tfp I did a full repo overhaul to enforce a package called ng-packagr. This module should package everything up properly. I just release 0.4.0-alpha.3, which includes support for SSR builds. I tested it on my own repo and it works.

I'd like to get your feedback on whether it works or not.

Thanks, your feedback is much appreciated!

@jacobedawson
Copy link

jacobedawson commented Oct 5, 2017

Hi @nicky-lenaers - I just installed 0.4.0-alpha.3 and I got this error during compilation (no other changes made - just installed ngx-scroll-to, added imports in module.ts, set up the service from this repo):

 ERROR in Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in ... etc

@nicky-lenaers
Copy link
Owner

@jacobedawson Thank you for reporting this. I came across quiet a hot issue topic that references this issue. It seems there could be multiple factors that cause this error. Even outside of the scope of this module. The fact that I have a working example in a repo confirms that.

I'd really like to help you with this. Do you mind setting up a small example repo or plunkr with your setup (or share the repo you already have if possible), so I'm able to properly figure out what causes this error?

Thanks in advance.

@nicky-lenaers nicky-lenaers reopened this Oct 5, 2017
@nicky-lenaers nicky-lenaers self-assigned this Oct 5, 2017
@jacobedawson
Copy link

@nicky-lenaers yo dude - sure thing, will have a look tomo morning (bedtime in berlin...zzz) and get back to you, cheers!

@nicky-lenaers
Copy link
Owner

Sure man, same thing in your neighbor Netherlands :-) let me know when you got something!

@nicky-lenaers
Copy link
Owner

@jacobedawson I've been doing research into this issue. It seems to not be related to this module specifically. My suggestion is to check your installed versions of Angular itself and go through topics that address your issue.

Thanks again for your feedback, this is much appreciated!

Closing this issue due to irrelevance to the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants