Skip to content
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

feat: Speed up adding native platform #3735

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

rosen-vladimirov
Copy link
Contributor

The current logic for adding native platform is:

  1. Install the runtime package (tns-ios or tns-android) as a dependency of the project
  2. Copy all files from the <project dir>/node_modules/<runtime package>/framework to <project dir>/plaforms/<platform>/... (specific places there).
  3. Uninstall the runtime package, so it is no longer dependency of the project.

This solution becomes really slow when the project has a lot of dependencies. For example, for tns-template-master-detail-ng, all these steps take around 2 mins and 5 seconds on Windows (without SSD) and around 40 seconds on macOS (with SSD).

In order to speed up this process, remove the installing and uninstalling of the runtime package. Instead of this, use the pacote package to extract the runtime to a directory in the temp and copy
files from there to platforms directory. As we do not execute npm install and npm uninstall with this solution, the operation is not dependent on the number of dependencies used in the project. It takes
around 5-9 second on both Windows and macOS.

Also remove the usage of $options from npmInstallationManager - its purpose was to work with --frameworkPath on tns platform add <platform> command, but we no longer call npmInstallationManager for this case.

Fix the tests for platorm-service's addPlatform method as they were incorrectly passing.

PR Checklist

What is the current behavior?

tns platform add <platform> takes around 40 seconds

What is the new behavior?

tns platform add <platform> takes around 6 seconds.

Fixes/Implements/Closes #[Issue Number].

The current logic for adding native platform is:
1. Install the runtime package (tns-ios or tns-android) as a dependency
of the project
2. Copy all files from the `<project dir>/node_modules/<runtime
package>/framework` to `<project dir>/plaforms/<platform>/...` (specific
places there).
3. Uninstall the runtime package, so it is no longer dependency of the
project.

This solution becomes really slow when the project has a lot of
dependencies. For example, for `tns-template-master-detail-ng`, all
these steps take around 2 mins and 5 seconds on Windows (without SSD)
and around 40 seconds on macOS (with SSD).

In order to speed up this process, remove the installing and
uninstalling of the runtime package. Instead of this, use the `pacote`
package to extract the runtime to a directory in the `temp` and copy
files from there to `platforms` directory. As we do not execute `npm
install` and `npm uninstall` with this solution, the operation is not
dependant on the number of dependencies used in the project. It takes
around 5-9 second on both Windows and macOS.

Also remove the usage of `$options` from `npmInstallationManager` - its
purpose was to work with `--frameworkPath` on `tns platform add
<platform>` command, but we no longer call `npmInstallationManager` for
this case.

Fix the tests for `platorm-service`'s addPlatform method as they were
incorrectly passing.
Copy link
Contributor

@Fatme Fatme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@Natalia-Hristova
Copy link

run ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants