So Ionic rc0 is here. Wooop! RIP Webpack. Wait no Webpack? Nope, we’re using rollupjs now.
This comes with a few problems, also known as changes. Let’s go over how we can get some third party libraries loaded up
into our shiny new Ionic project.
Let’s make sure we’re up to date npm install -g ionic cordova typescript
Requirements aka worked for me: node -v = v6.4.0 npm -v = 3.10.7
TLDR: Here is a blank tabs starter project with everything discussed below: Ionic rc0 & Firebase git clone git@github.com:alexmgrant/ionic_rc0_firebase.git cd ionic_rc0_firebase npm i ionic serve
Installation (from scratch)
mkdir your_project_name cd your_project_name ionic start blank --v2
For this project we’re going to install lodash as well as Firebase npm i lodash firebase --save
Typescript will want the static types for our newly added libraries npm install @types/lodash --save
We’re going to use a rollup plugin called replace later npm install --save-dev rollup-plugin-replace
Install your packages npm i
Apparently @types ecosystem should come through for us “most of the time”, however in the case of Firebase they have not updated their static types to their latest api 3.0. No sweat.
Add Firebase types to /tsconfig.json
Next we need to tell rollupjs to use our commonjs modules ie. Firebase & Lodash. So we don’t have to dig into ionic’s implementation we can use package.json to build our own custom rollupjs script.
Inside of our new /config ceate a file named rollup.config.js and place the following setup into that file.
Now let’s include Firebase into our project within /src/app/app.component.ts
Start it up ionic serve
So it works, but until Firebase updates this setup is not ideal. You’ll get a couple errors in the console. I’m currently working on a solution to these. They’re from Firebase’s use of eval which is only parsing json.
$ rollup: Use of 'eval' (in /your_path/your_project_name/node_modules/firebase/auth.js) is strongly discouraged, as it poses security risks and may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details
Fortunately you can ignore this. When the Firebase team updates I’m sure they will update their use of eval.
There you go, you now have Ionic rc0, Firebase & Lodash in your project. Any questions?