App_Resources directory exists in <project dir>/platforms/<platform>.../app/
#4377
Labels
<project dir>/platforms/<platform>.../app/
#4377
Environment
Provide version numbers for the following components (information can be retrieved by running
tns info
in your project folder or by inspecting thepackage.json
of the project):Describe the bug
Every run after the first
tns run <platform> --bundle
produces App_Resources directory inside<project dir>/platforms/<platform>/.../app/
directory.App_Resources
directory must not exist in platforms dir - content of the App_Resources should be placed on specific locations in the platforms dir, but the directory itself should not be copied anywhere. In fact the resources are prepared on the correct place and duplicated in<project dir>/platforms/<platform>/.../app/
.To Reproduce
tns create myApp --js
cd myApp
tns run android --bundle --justlaunch
ls -l platforms/android/app/src/main/assets/app
- App_Resources will not be in the listed files/dirs.tns run android --bundle --justlaunch
again.ls -l platforms/android/app/src/main/assets/app
- App_Resources will be in the listed files/dirs.NOTE: Same is valid for iOS.
Expected behavior
App_Resources must not be in the platforms dir.
Additional context
The issue is caused by the way CLI prepares App_Resources and the way nativescript-dev-webpack plugs in CLI's lifecycle.
Currently, during project preparation CLI copies the project's app directory to platforms dir. By default, the App_Resources are inside project's app directory, so CLI actually copies them as well. After that CLI executes some actions over the files in
platforms/<platform>.../app/App_Resources
(i.e. deletes some of them) and moves them to correct places in platforms dir. At the end of these operations, CLI deletes theplatforms/<platform>.../app/App_Resources
dir, as it has already prepared the files.What happens when
--bundle
is used -nativescript-dev-webpack
replaces the method in which CLI copies project's app directory toplatforms
dir. However, other methods after the replaced one (particularly the prepareAppResources method), expect to find App_Resources inplatforms/.../app/App_Resources
. Sonativescript-dev-webpack
has a logic to copy project's App_Resources dir to the location where prepareAppResources method will expect. This whole thing works correctly when building application. However, whentns run <platform> --bundle
is executed, there's additional magic. First operation that is run in such case is starting the webpack process with watcher enabled. Webpack produces files and reports them to CLI to be LiveSynced. Whenever webpack compiler is started, our logic in nativescript-dev-webpack copies App_Resources toplatforms/.../app/App_Resources
. NOTE: The start of webpack process and producing the App_Resources comes from the before-watch hook, not from the replacement of the method where CLI copies app dir to platforms. After watcher is started CLI checks the application state and decides that it should skip the project preparation as nothing has changed since last time. However, it uploads the files reported by webpack to device (i.e. the new bundle.js, vendor,js, etc.). The App_Resources remain inplatforms/.../app/App_Resources
as CLI skips its preparation phase. However, these files will never be uploaded on device. In case some change in the app requires build, CLI will reprepare the native files, including App_Resources and they will not be included in the build .apk/.ipa file.Related to: #4239
The text was updated successfully, but these errors were encountered: