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

Start LiveSync watcher earlier during run #3404

Closed
Mitko-Kerezov opened this issue Feb 28, 2018 · 0 comments
Closed

Start LiveSync watcher earlier during run #3404

Mitko-Kerezov opened this issue Feb 28, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@Mitko-Kerezov
Copy link
Contributor

Currently whenever tns run <platform> is executed the logic in CLI is as follows:

  1. Prepare the project if needed (this process includes moving files around in platforms, LiveSyncing files if needed, building and installing if required)
  2. Start watching the project files for changes. Whenever changes occur CLI triggers the whole logic in 1.

This logic leads to some issues:

  • Some plugins have before-prepare hooks which trigger some compilation for example and before-watch hook, which starts some other watch process and the project files end up undergoing the same process twice

The proposed solution to this is to invert the logic and start the watcher initially and then force the first preparation. This will eliminate the aforementioned issues in all plugins (nativescript-dev-typescript, nativescript-dev-sass, nativescript-dev-webpack, etc.). There is also an additional benefit to be gained with this approach - during the very first build of the project the user may make changes to the project files, which will be taken into account and LiveSynced - this functionality is currently missing.

sis0k0 added a commit to NativeScript/nativescript-dev-webpack that referenced this issue Mar 17, 2018
Every time we are running a new build with webpack the platforms/.../app/ dir should be deleted as there may be old assets
left.

Ex.
When the app bundled with snapshot enabled:
```
tns build android --bundle --env.snapshot
```
this produces some assets:
```
platforms/android/.../app/vendor.js
platforms/android/.../app/_embedded_script.js
// ...
```

Then, if the project is bundled without snapshot:
```
tns build android --bundle
```
the produced assets will override the ones that are already in
`platforms/android/.../app`. However, since the build is without
snapshot, an `_embedded_script.js` won't be generated to override the one
that's left in `platforms/android/.../app` from the previous build.

We'll be using `CleanWebpackPlugin` to clean the dist folder.
** Important **: Currently we're running two webpack builds when doing
`tns run android|ios` - one on prepare and one when the watcher starts.
This means that the dist folder will be cleaned two times. This will be
resolved when
NativeScript/nativescript-cli#3404 is
implemented.

fixes #463
sis0k0 added a commit to NativeScript/nativescript-dev-webpack that referenced this issue Mar 21, 2018
Every time we are running a new build with webpack the platforms/.../app/ dir should be deleted as there may be old assets
left.

Ex.
When the app bundled with snapshot enabled:
```
tns build android --bundle --env.snapshot
```
this produces some assets:
```
platforms/android/.../app/vendor.js
platforms/android/.../app/_embedded_script.js
// ...
```

Then, if the project is bundled without snapshot:
```
tns build android --bundle
```
the produced assets will override the ones that are already in
`platforms/android/.../app`. However, since the build is without
snapshot, an `_embedded_script.js` won't be generated to override the one
that's left in `platforms/android/.../app` from the previous build.

We'll be using `CleanWebpackPlugin` to clean the dist folder.
** Important **: Currently we're running two webpack builds when doing
`tns run android|ios` - one on prepare and one when the watcher starts.
This means that the dist folder will be cleaned two times. This will be
resolved when
NativeScript/nativescript-cli#3404 is
implemented.

fixes #463
sis0k0 added a commit to NativeScript/nativescript-dev-webpack that referenced this issue Mar 21, 2018
Every time we are running a new build with webpack the platforms/.../app/ dir should be deleted as there may be old assets
left.

Ex.
When the app bundled with snapshot enabled:
```
tns build android --bundle --env.snapshot
```
this produces some assets:
```
platforms/android/.../app/vendor.js
platforms/android/.../app/_embedded_script.js
// ...
```

Then, if the project is bundled without snapshot:
```
tns build android --bundle
```
the produced assets will override the ones that are already in
`platforms/android/.../app`. However, since the build is without
snapshot, an `_embedded_script.js` won't be generated to override the one
that's left in `platforms/android/.../app` from the previous build.

We'll be using `CleanWebpackPlugin` to clean the dist folder.
** Important **: Currently we're running two webpack builds when doing
`tns run android|ios` - one on prepare and one when the watcher starts.
This means that the dist folder will be cleaned two times. This will be
resolved when
NativeScript/nativescript-cli#3404 is
implemented.

fixes #463
sis0k0 added a commit to NativeScript/nativescript-dev-webpack that referenced this issue Mar 22, 2018
Every time we are running a new build with webpack the platforms/.../app/ dir should be deleted as there may be old assets
left.

Ex.
When the app bundled with snapshot enabled:
```
tns build android --bundle --env.snapshot
```
this produces some assets:
```
platforms/android/.../app/vendor.js
platforms/android/.../app/_embedded_script.js
// ...
```

Then, if the project is bundled without snapshot:
```
tns build android --bundle
```
the produced assets will override the ones that are already in
`platforms/android/.../app`. However, since the build is without
snapshot, an `_embedded_script.js` won't be generated to override the one
that's left in `platforms/android/.../app` from the previous build.

We'll be using `CleanWebpackPlugin` to clean the dist folder.
** Important **: Currently we're running two webpack builds when doing
`tns run android|ios` - one on prepare and one when the watcher starts.
This means that the dist folder will be cleaned two times. This will be
resolved when
NativeScript/nativescript-cli#3404 is
implemented.

fixes #463
sis0k0 added a commit to NativeScript/nativescript-dev-webpack that referenced this issue Mar 22, 2018
Every time we are running a new build with webpack the platforms/.../app/ dir should be deleted as there may be old assets
left.

Ex.
When the app bundled with snapshot enabled:
```
tns build android --bundle --env.snapshot
```
this produces some assets:
```
platforms/android/.../app/vendor.js
platforms/android/.../app/_embedded_script.js
// ...
```

Then, if the project is bundled without snapshot:
```
tns build android --bundle
```
the produced assets will override the ones that are already in
`platforms/android/.../app`. However, since the build is without
snapshot, an `_embedded_script.js` won't be generated to override the one
that's left in `platforms/android/.../app` from the previous build.

We'll be using `CleanWebpackPlugin` to clean the dist folder.
** Important **: Currently we're running two webpack builds when doing
`tns run android|ios` - one on prepare and one when the watcher starts.
This means that the dist folder will be cleaned two times. This will be
resolved when
NativeScript/nativescript-cli#3404 is
implemented.

fixes #463
@Fatme Fatme self-assigned this Apr 12, 2018
Fatme added a commit that referenced this issue May 11, 2018
Fatme added a commit that referenced this issue May 11, 2018
Fatme added a commit that referenced this issue May 11, 2018
Fatme added a commit that referenced this issue May 11, 2018
Fatme added a commit that referenced this issue May 14, 2018
Fatme added a commit that referenced this issue May 14, 2018
Fatme added a commit that referenced this issue May 15, 2018
Fatme added a commit that referenced this issue May 15, 2018
@Fatme Fatme added this to the 4.1.0 milestone May 16, 2018
@miroslavaivanova miroslavaivanova self-assigned this May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants