简体   繁体   中英

How to develop NPM module for Ionic

I am developing library for Ionic 2, that should be installed via NPM, but i can't do this in classic way. If you want to develop module you can use npm link command to link module to your project where you want test and develop it, but in Ionic it everytime fall on compilation error, when is module linked using npm link .

This is error that i get evertime:

[10:14:15]  Error: Could not resolve entry (./.tmp/app/main.dev.js)
at /Users/daniel/ionic/cache-test/node_modules/rollup/dist/rollup.js:8602:28
at process._tickCallback (internal/process/next_tick.js:103:7)

So, is there any trick how to develop and test NPM module in Ionic 2?

Thanks.

We did experiment with this, to share ngrx-based core module in between a web Angular2 app and an Ionic2 mobile app: https://github.com/benorama/ngrx-demo-apps

However, we did not manage to make it work through npm link , only with npm pack/install .

The trick is to define your external lib in a custom rollup.config.js . You can find more info here: http://ionicframework.com/docs/v2/resources/third-party-libs/ http://ionicframework.com/docs/v2/resources/app-scripts/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM