feat: Speed up adding native platform #3735
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current logic for adding native platform is:
<project dir>/node_modules/<runtime package>/framework
to<project dir>/plaforms/<platform>/...
(specific places there).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 thetemp
and copyfiles from there to
platforms
directory. As we do not executenpm install
andnpm uninstall
with this solution, the operation is not dependent on the number of dependencies used in the project. It takesaround 5-9 second on both Windows and macOS.
Also remove the usage of
$options
fromnpmInstallationManager
- its purpose was to work with--frameworkPath
ontns platform add <platform>
command, but we no longer callnpmInstallationManager
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 secondsWhat is the new behavior?
tns platform add <platform>
takes around 6 seconds.Fixes/Implements/Closes #[Issue Number].