You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/16 02:07:00 UTC

[jira] [Commented] (CB-14133) Avoid reinstalling already installed plugins in cordova-fetch

    [ https://issues.apache.org/jira/browse/CB-14133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16514623#comment-16514623 ] 

ASF GitHub Bot commented on CB-14133:
-------------------------------------

raphinesse opened a new pull request #24: CB-14133 Avoid reinstalling already installed plugins in cordova-fetch (WIP)
URL: https://github.com/apache/cordova-fetch/pull/24
 
 
   This is to alleviate the performance penalty incurred by fetching-by-default.
   
   This speeds up `cordova prepare` in below setup by about 200% (i.e. it takes half the time)
   ```
   git clone https://github.com/dpogue/cb-13797
   npm i
   cordova prepare
   ```
   
   - This only reuses packages if their version matches the requirements
   - This still transparently supports all spec formats that `npm install` supports
   - This obviously only works for specs that we can infer the package name and version from. So git dependencies will still be fetched every time
   
   I'm sure there are other issues related to this, but I linked to the one that made me think of a robust and easy way to increase performance.
   
   In the long run, we should try to reduce all fetching to a minimum, but that has to tackled in cordova-lib.
   
   ### TODO
   - Add test for reusing installed package
   - Rebase onto master after #23 lands
   - Add some way to prevent reusing installed packages?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Avoid reinstalling already installed plugins in cordova-fetch
> -------------------------------------------------------------
>
>                 Key: CB-14133
>                 URL: https://issues.apache.org/jira/browse/CB-14133
>             Project: Apache Cordova
>          Issue Type: Wish
>          Components: cordova-cli, cordova-fetch
>    Affects Versions: 8.0.0
>            Reporter: Zak
>            Assignee: Raphael
>            Priority: Minor
>
> Relates to CB-13992
> The pull request for CB-13992 removed the {{dependency-ls}} package which helped to speed up the platform add step. However, each plugin still gets {{npm install}} ed seemingly just to determine the package name. 
> Typical workflow is to run {{npm install}} as the first task after cloning a node repository. The current practice for cordova is to save plugins to the package.json meaning that plugins are already installed to the node_modules directory, so running {{npm install}} for each of them individually is redundant.
> If the main function in {{cordova-fetch}} is simplified to just return the path to the given module (albeit this isn't the most elegant implementation):
> {code:javascript}
> module.exports = function (target, dest, opts = {}) {
>     var fetchArgs = opts.link ? ['link'] : ['list'];
>     var nodeModulesDir = dest + '/node_modules/';
>     // check if npm is installed
>     return module.exports.isNpmInstalled()
>         .then(function () {
>             const mod = target.slice(0, target.lastIndexOf('@'));
>             return path.resolve(nodeModulesDir, mod)
>         })
>         .catch(function (err) {
>             throw new CordovaError(err);
>         });
> };
> {code}
> the platform add process runs almost instantly rather than taking a few minutes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org