Running app with --path
and --env.snapshot
fails #584
Description
Issue Checklist
- You are submitting: bug
Tell us about the problem
The following command fails:
tns run android --bundle --env.snapshot --path testapp
with:
ENOENT: no such file or directory, open 'platforms/android/app/snapshot-entry.js'
Reasons for failure
The nativescript-dev-webpack
has a before-watchPatterns
hook. Its job is to tell the {N} CLI what files are watched by the webpack watcher and should be ignored by the CLI watcher. The hook does the following:
- Calls the project data service from {N} CLI to determine what are the source dir and app resources dir.
- Requires the webpack config file and passes the above as arguments.
- Gets the compilation context from the returned webpack config object and tells the {N} CLI that it shouldn't bother with watching anything in that compilation context. The default compilation context is the source directory.
The problem arises when the webpack config file is required. When the --env.snapshot
flag is passed, the NativeScriptSnapshotPlugin
is instantiated. That has a side effect - a file, named snapshot-entry.js
is created inside the native Android project. This fails when we invoke the tns run
command outside of the project, because the specified path for the created file is relative.
Proposed solution
Stop requiring the webpack config file in the hook, because that may have side effects. Instead tell the {N} CLI watcher to ignore the whole source dir.