-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save platforms and plugins to devDependencies #64
Comments
👍 I'd say this change requires a major release of |
And I think a PR would be very welcome. |
Yes, I also think that's for the next major release of |
Yes, I did the changes that I have described. I believe that's all we need for saving platforms and plugins to the devDependencies. However, I didn't remove the user-provided options as @raphinesse suggested, but I thought maybe that needs a further discussion and could be a separate PR. |
Feature Request
Motivation Behind Feature
Currently, Cordova platforms and plugins are saved as
dependencies
in thepackage.json
file. Hence, during the Cordova prepare step, necessary files for plugins are moved for bundling with the app. Thesedependencies
are not used directly with the app, so I believe, they should be treated asdevDependencies
.I want to clear out Cordova platforms and plugins from
dependencies
because it could affect platforms that leverage thenpm
modules. This issues can be seen with the newest platform - Electron. With Electron it is expected that you usenpm
packages within the application and should be installed asdependencies
.For instance, if we want to use
lodash
with Electron app, we wouldnpm install lodash
and then import it usingrequire
. When werun
the application everything works as expected because it uses the module from{project}/node_modules
. But withbuild
we need to take all thedependencies
from the project and install them within the app.As a result:
With Cordova platforms and plugins defined in the
dependencies
, for example,cordova-electron
the packaged app size will increase greatly.With Cordova platforms and plugins defined in the
devDependencies
, they would not be installed with the app and reduce the package size.Again, Cordova platforms and plugins should be treated as development building blocks and shouldn't be in the app
Feature Description
The current implementation of the npm arguments handling is the following:
My suggestion would be instead of using
--save
flag, change it to--save-dev
. While the--save
option still appears to work, it is no longer required. Thenpm install
saves any specified packages intodependencies
by default.Besides that, we also append
--production
flag. With the--production
flag npm will not install modules listed indevDependencies
. However, the--production
flag has no particular meaning when we are adding a dependency to a project. I think that should be removed. Plus, if you use--production
and--save-dev
flags together, it causesnpm install
to break.Later we could also remove options, like production, that get passed from
cordova-lib
to thecordova-fetch
and do a general clean up.Alternatives or Workarounds
Manually move Cordova platforms and plugins, that don't need to be bundled with an app, from
dependencies
to thedevDependecies
.The text was updated successfully, but these errors were encountered: