Ngx-bootstrap: Problem with update

Created on 24 Jan 2017  路  11Comments  路  Source: valor-software/ngx-bootstrap

I am updating library with 1.1.16-9 to 1.3.0 and I am getting
index.js:1Uncaught SyntaxError: Unexpected token export
image

Can you help me?

question

Most helpful comment

Fixed by replacing ng2-bootstrap/ng2-bootstrap to ng2-bootstrap as it says in the warnings..

console.warn('DEPRECATED: please replace import of `ng2-bootstrap/ng2-bootstrap` with `ng2-bootstrap`');
export * from './index';

All 11 comments

webpack or system.js?
if system.js you should use bundled version of ng2-bootstrap
if webpack it should consume it without issues

http://valor-software.com/ng2-bootstrap/#/
how to use with section covers typical configurations with instructions

I got the same error once 1.3.0 was released. When I revert to 1.2.6 the problem goes away without changing anything else. I am using WebPack 1.14. When I don't uglify I get this run-time error:

image

When I uglify, I get this compile-time error:

image

Oh, thing is, I have to keep my package in sync with @angular, they switched to es6 modules, so do I. Webpack 2 natively supports es6 module format.

@valorkin thank you for the quick response. I will work on getting my webpack 1 to support es6 modules.

@valorkin I use 1.14.0 webpack but 1.1.16-9 version ng2-bootstrap work very nice.
what could be the reason else?

I wrote reason above, all other changes described in change log

Fixed by replacing ng2-bootstrap/ng2-bootstrap to ng2-bootstrap as it says in the warnings..

console.warn('DEPRECATED: please replace import of `ng2-bootstrap/ng2-bootstrap` with `ng2-bootstrap`');
export * from './index';

As @matejkramny mentioned, you need to update your Ng2BootstrapModule import to fromng2-bootstrapget rid of the/ng2-bootstrap` at the end.

Also don't forget to add: Ng2BootstrapModule .forRoot() <-- the forRoot() when importing the module to your own NgModule.

Still loving the library @valorkin great work as always :100:

Have you featured in my aspnet & angular universal repo here finally was able to upgrade to the 1.3.x version after fixing the workarounds needed to get Universal to play well with NG 2.4.5.

Works like a charm though, your components are still coming in great server-rendered! :+1: Keep up the great work!

I decided to upgrade webpack from 1.4 to 2.2 and the new exports work now. It was time to upgrade to webpack 2 anyway...

@MarkPieszak can you explain why .forRoot() is needed?

I import it in the root app module, and also in other "sub" modules (hope that makes sense!). Do the sub modules also require .forRoot() import?

sorry if it doesn't make sense, haven't slept for ~36 hours.

seems to be fixed in 1.3.3

@matejkramny .forRoot() needed to not duplicate providers declarations in lazy loaded modules

Was this page helpful?
0 / 5 - 0 ratings