A major focus at Ionic right now is reducing the final bundle size of an Ionic app. One of the major file size offenders has been Ionic Native, which bundles a decent amount of plugin code into your app regardless of whether or not you’re using those plugins.

Ionic Native 3.x fixes this by moving each plugin into its own npm module. Just need the Camera plugin? Install the @ionic-native/camera package and then import { Camera } from '@ionic-native/camera' instead of from the legacy ionic-native package.

In our tests, this helped shave 15% of the final bundle size, which will help apps load more quickly.

Test it

To try out this new alpha version, remove ionic-native from your package.json dependencies, and instead add the plugins you need:

"dependencies": { "@angular/common": "2.2.1", ... "@ionic-native/camera": "3.0.0-alpha.1", "@ionic-native/statusbar": "3.0.0-alpha.1", "@ionic-native/splashscreen": "3.0.0-alpha.1", ... },

Change your imports from ionic-native to match the new package format:

import { StatusBar } from '@ionic-native/statusbar'; import { Splashscreen } from '@ionic-native/splashscreen';

Thoughts?

Please let us know how this works for you in the comments below or by filing an issue on the repo.

This is one of many filesize and boot time optimizations in the pipeline for Ionic, so stay tuned!