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

Carousel Unexpected Import with Angular Universal #3073

Closed
jezguitarist30 opened this issue Nov 19, 2017 · 11 comments
Closed

Carousel Unexpected Import with Angular Universal #3073

jezguitarist30 opened this issue Nov 19, 2017 · 11 comments

Comments

@jezguitarist30
Copy link

Below is the error I get when I run my server.js, everything works well when I removed my component that uses Carousel.

D:\Development\DemoProjects\angularph-universal-app\node_modules\ngx-bootstrap\carousel\slide.component.js:1
(function (exports, require, module, __filename, __dirname) { import { Component, HostBinding, Input } from '@angular/core';
^^^^^^

SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.mK+S (D:\Development\DemoProjects\angularph-universal-app\dist\server\main.ac013103ccc455daa776.bundle.js:1:132178)
PS D:\Development\DemoProjects\angularph-universal-app>

@IlyaSurmay
Copy link
Contributor

Could you create a minimal reproduction of this? Sample repo would be enough.
Also want to ask, which version of ngx-bootstrap are you using? universal support was added in 2.0.0-beta.7

@jezguitarist30
Copy link
Author

Hi, I have a repo that you can check
https://github.com/jezguitarist30/AngularPH-Universal-Application.git

the Dev Branch is the updated one.

@IlyaSurmay
Copy link
Contributor

Have you added all necessary files like server.ts? because your repo only has a command to build browser and server versions of app (btw they're both build fine)

@jezguitarist30
Copy link
Author

I made a separate repo for the build one
https://github.com/jezguitarist30/AngularPH-Universal-Application-Build

@jezguitarist30
Copy link
Author

you can see there the server.js and package.json, it is currently working because I temporarily removed the Banner carousel.

@jezguitarist30
Copy link
Author

Hi @IlyaSurmay hope you can help me make it work.. I added a new branch "build" where the dist folder with the bundle files, server.js and package.json is available

https://github.com/jezguitarist30/AngularPH-Universal-Application/tree/build

@valorkin
Copy link
Member

valorkin commented Nov 23, 2017

@jezguitarist30 issue is kinda simple, node.js doesn't support es6 import syntax
so your code (and code imported from ngx-bs) should be compiled with ts before running on node
working sample here: https://github.com/valor-software/ngx-bootstrap/tree/development/scripts/universal

@jezguitarist30
Copy link
Author

OH! I see, thanks for the explanation I wouldn't be able to figure this out myself.

@denizcoskun
Copy link

@valorkin hi, Thanks for the info. Could you explain a bit more how to compile node_modules in es5? I couldn't find a way to do that?

@jezguitarist30
Copy link
Author

@denizcoskun you can check https://github.com/angular/angular-cli/wiki/stories-universal-rendering for a complete guide on how to do that, I just followed all the steps here and mine is now working.

@denizcoskun
Copy link

@jezguitarist30 thanks!

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