Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Webpack both Android and iOS simutaneously #457

Open
Mitko-Kerezov opened this issue Mar 6, 2018 · 0 comments
Open

Webpack both Android and iOS simutaneously #457

Mitko-Kerezov opened this issue Mar 6, 2018 · 0 comments

Comments

@Mitko-Kerezov
Copy link
Contributor

CLI is able to execute tns run without a platform which will build and deploy to both platforms and execute LiveSync for each of them.

This is currently not possible with --bundle. There are multiple ideas about how to go about this.

  1. Launch two separate webpack processes one for each platform. The issue with this approach would be that each webpack process would watch the same files - this could lead to potential problems.
  2. Launch one webpack process that handles both platforms.

Both approaches have the issue of when to stop the webpack process for a particular platform. For example the user has one android and one iOS device, launches tns run --bundle and later on disconnects the iOS device - webpack would need to know and stop bundling for the iOS platform.

This could be done by adding an event handler for livesyncStopped or by some other approach.

@sis0k0 sis0k0 added the feature label Mar 6, 2018
@sis0k0 sis0k0 added backlog and removed backlog labels Aug 21, 2018
Fatme added a commit that referenced this issue Sep 10, 2018
* Add event handler for "liveSyncStopped" event
* Persist webpack process per platform

Implements: #457
Fatme added a commit that referenced this issue Sep 10, 2018
* Add event handler for "liveSyncStopped" event
* Persist webpack process per platform

Implements: #457
Fatme added a commit that referenced this issue Sep 10, 2018
* Add event handler for "liveSyncStopped" event
* Persist webpack process per platform

Implements: #457
Fatme added a commit that referenced this issue Sep 12, 2018
* Add event handler for "liveSyncStopped" event
* Persist webpack process per platform

Implements: #457
sis0k0 pushed a commit that referenced this issue Sep 13, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
sis0k0 pushed a commit that referenced this issue Sep 27, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
sis0k0 pushed a commit that referenced this issue Sep 28, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants