-
Notifications
You must be signed in to change notification settings - Fork 59
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
Added Bundle Node Module Support #54
Conversation
I would personally favor an approach that works the same way across all platforms. For example, we could use a tool such as Babel, Webpack, or Typescript to transform the sources and combine them into a bundle for each platform. P.S. Thanks to @erisu for your efforts on this one. |
@brodybits we are talking about bundling all node modules that can also include executable binaries. |
@erisu I think you meant @brodybits 🙈 |
Sorry @brody, you are correct. I was typing this on my phone 🙈 Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good to me. However, I was wondering, maybe the DOCUMENTATION.md
file should be submitted as a separate PR.
c30e68d
to
b71857a
Compare
As soon as this is merged I am volunteering to see if it works :) -> but that's a big improvment! |
Codecov Report
@@ Coverage Diff @@
## master #54 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 14 14
Lines 605 612 +7
=====================================
+ Hits 605 612 +7
Continue to review full report at Codecov.
|
PR sounds awesome.
Should this be changed in Cordova CLI?
Where did the documentation for this feature end up? |
Yes, the long-term solution on how Cordova install platforms and plugins though CLI will need changing within CLI/fetch. I recall from a conversation with others that this type of change would be considered major but also desirable. This is why I mention the manual process for an immediate solution while we work on the long-term.
The documentation he was referring to that was in this PR was not exactly only for this feature. There was an example that explains how to enable As an end note on documentation, maybe I can add within this PR a doc update specifically talking about the feature strictly. |
abb8aa5
to
32ffd73
Compare
Co-Authored-By: Jan Piotrowski <piotrowski+github@gmail.com>
60f2690
to
1c43617
Compare
Platforms affected
electron
Motivation and Context
Support Bundling Node Modules
fixes: #52
Description
This PR is a possible solution to support the bundling of node_modules inside the Electron built package.
The concept is that when working on an app, we add specific npm packages (
npm i -S <package>
) to the root directory of the Cordova project as adependencies
, notdevDependencies
.For example, if we wanted to use
lodash
:nodeIntegration
.Follow these guides:
lodash
npm node modules.Now what happens?:
During testing with the
cordova run electron --nobuild
command, it will spawn an Electron process and use thelodash
modules from<project_root>/node_modules/lodash
.This is how it operated before this PR.
When building, the Cordova build process will copy the Cordova's project
dependencies
frompackage.json
to the built application'spackage.json
. During the build process, it willnpm install
all the modules within the app directory that is packaged.This was added from this PR.
Note: With the current Cordova CLI, all platforms are added as
dependencies
. IT SHOULD BE ok to manually move these dependencies todevDependencies
. These dependencies contain only the build tools and templates and are not needed in your bundled app. All it will do is increase the application's size.Testing
npm t
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)