Managing bower dependencies with ionic
Asked Answered
A

2

8

After starting with a new ionic app, I can see at bower.json that comes with ionic is in devdependencies. Why is it a devdependency and not a normal dependency?

"devDependencies": {
    "ionic": "driftyco/ionic-bower#1.0.0-rc.0"
},

Thanks, I feel confused right now

Autoicous answered 11/3, 2015 at 8:40 Comment(1)
Wondering exactly the same thing myselfYardstick
D
2

having devDependencies gives you the opportunity to simplify the steps that drive you from the source files (a git clone of the project) to the production ready app

when you don't need to make changes and (develop) the application, you could just run

bower install --production

or

npm install --production

they work the same

bower install options

-F, --force-latest: Force latest version on conflict

-p, --production: Do not install project devDependencies

-S, --save: Save installed packages into the project’s bower.json dependencies

-D, --save-dev: Save installed packages into the project’s bower.json devDependencies

-E, --save-exact: Configure installed packages with an exact version rather than semver

bower documentation

npm install options

By default, npm install will install all modules listed as dependencies. With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies. npm documentation

This way you take less time to ship the app and don't waste bandwidth downloading stuff you won't need.

Given that, to me, the choice of listing ionic as devDependecy is a poor one: it implies that I could take advantage of this choice to get ready the app for execution this way:

git clone my-project
git cd my-project
npm install --production # ionic not installed here
ionic state restore
ionic build ios

Now, if you ignore the content of /lib folder in your sources, this should not work, and if it works because the ionic-cli does some more checks to save your ass, I think this is unclear.

Droplet answered 1/8, 2015 at 9:44 Comment(1)
Isn't ionic required for production, since index.html references files in lib/ionic?Freeness
D
1

From what I understand, dependencies are required to run, and devDependencies are only for development, like minification, unit tests, etc.

Both will install when you do npm install but only dependencies will install when you do npm install $package, unless you add the --dev option

Dematerialize answered 2/4, 2015 at 1:9 Comment(2)
Thanks for the answer. Ok, thats the difference between a dependency and a devdependency. But my question is why ionic is a devdependency.Autoicous
@Autoicous I think they consider ionic and all bower packages as devdependency, because the final production for ionic is the IOS appGilead

© 2022 - 2024 — McMap. All rights reserved.