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

[FEATURE] Support SSR using @angular/cli and ng-packagr #35

Open
lucaswxp opened this issue Feb 18, 2019 · 6 comments
Open

[FEATURE] Support SSR using @angular/cli and ng-packagr #35

lucaswxp opened this issue Feb 18, 2019 · 6 comments

Comments

@lucaswxp
Copy link

Hey guys.
I'm trying to get ssr to work, but I'm getting the following error:

/home/lucaswxp/reduza/universal-starter/node_modules/ngx-currency/src/currency-mask.directive.js:1
(function (exports, require, module, __filename, __dirname) { import { Directive, ElementRef, forwardRef, HostListener, Inject, KeyValueDiffers, Input, Optional } from "@angular/core";
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Module._compile (internal/modules/cjs/loader.js:618:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)

I'm not sure what to do, I can make a PR if you guys point the way. It know it has something to do with commonjs.

@nbfontana
Copy link
Owner

Hello @lucaswxp,

import is part of ES6, does your project supports it?

If not, try using babel to transpile your code.

@lucaswxp
Copy link
Author

Hey @nbfontana, thanks for the reply.
If I remove ngx-currency, my project compiles, not sure what I should do?

@paullryan
Copy link

@nbfontana and @lucaswxp I also needed support for SSR and the issue is with the build system you're using (the self rolled es and umd builders with webpack. I have a have a version (not supported) using @angular/cli and ng-packagr at https://github.com/nomadreservations/ngx-currency that works with SSR. I doubt I will maintain it in the long term but you can use it to find your build issues. Let me know if you have questions.

@nbfontana
Copy link
Owner

Great @paullryan!

I'll link your code as a guide for someone that's available to change the module strategy to make use of @angular/cli and ng-packagr.

I'm totally in favor of the change, and I'll change the Issue description to be a new feature.

@nbfontana nbfontana changed the title Problems with server side rendering [FEATURE] Support SSR using @angular/cli and ng-packagr May 21, 2019
@paullryan
Copy link

@nbfontana would it be helpful for me to package my changes as a PR for you?

@tom94zoe
Copy link

tom94zoe commented Aug 8, 2019

@nbfontana would it be helpful for me to package my changes as a PR for you?

How can i use your code?
I couldn't integrate it within my project.

Thanks in advance

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

4 participants