ionic-team / ionic-cli

The Ionic command-line interface
MIT License
1.99k stars 640 forks source link

bug: App no longer transferred to device with "ionic cap run android -l --external" when using angular 17 and esbuild. #5061

Closed WillooWisp closed 4 months ago

WillooWisp commented 6 months ago

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

App is not transferred to device for live-reload after upgrading to angular 17 and esbuild.

Expected Behavior

I expect to see "capacitor.cmd run android --no-sync --target " in console, but it is never executed.

Steps to Reproduce

  1. Upgrade a sample app to angular 17+.
  2. Change to utilize esbuild through @angular-devkit/build-angular:application in angular.json.
  3. Run "ionic cap run android -l --external", which just starts the dev server, but never deploys the apk.

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 7.1.5 (C:\Users\joel\AppData\Roaming\npm\node_modules\@ionic\cli) Ionic Framework : @ionic/angular 7.5.4 @angular-devkit/build-angular : 16.2.10 @angular-devkit/schematics : 16.2.10 @angular/cli : 16.2.10 @ionic/angular-toolkit : 10.0.0

Capacitor:

Capacitor CLI : 5.5.1 @capacitor/android : 5.5.1 @capacitor/core : 5.5.1 @capacitor/ios : 5.5.1

Utility:

cordova-res : not installed globally native-run : 1.7.4

System:

NodeJS : v20.9.0 (C:\Program Files\nodejs\node.exe) npm : 10.1.0 OS : Windows 10

Additional Information

Before angular 17 and esbuild...

[ng] √ Compiled successfully.

[INFO] Development server running!

       Local: http://localhost:8100
       External: http://172.24.64.1:8100, http://192.168.1.36:8100, http://192.168.32.66:8100, http://172.18.224.1:8100

       Use Ctrl+C to quit this process

> capacitor.cmd run android --no-sync --target R5CW143GQFX
[capacitor] √ Running Gradle build in 97.27s
[capacitor] √ Deploying app-debug.apk to R5CW143GQFX in 18.53s

[INFO] App deployed to device!

       Development server will continue running until manually stopped.

       Use Ctrl+C to quit this process

After angular 17 and esbuild...

[ng] Application bundle generation complete. [12.499 seconds]
[ng] Watch mode enabled. Watching for file changes...
[ng]   ➜  Local:   http://localhost:8100/
[ng]   ➜  Network: http://172.24.64.1:8100/
[ng]   ➜  Network: http://169.254.8.211:8100/
[ng]   ➜  Network: http://192.168.1.36:8100/
[ng]   ➜  Network: http://192.168.32.66:8100/
[ng]   ➜  Network: http://172.18.224.1:8100/

Call to "capacitor.cmd run android --no-sync --target R5CW143GQFX" is missing here!
liamdebeasi commented 6 months ago

Hey there,

The ionic cap command is managed by the Ionic CLI, so I am going to move this to the CLI repo.

WillooWisp commented 6 months ago

Okay, let's hope someone looks at this here then,

liamdebeasi commented 6 months ago

Do you have a sample app I can reproduce the issue in?

jcesarmobile commented 6 months ago

Looks like a bug in @angular-devkit/build-angular, when using the esbuild configuration it seems to hang the execution, so it "blocks" the execution of the following capacitor commands, while the old configuration doesn't hang and the capacitor commands can run. Since the esbuild configuration is still in preview, you should probably report this behavior change to angular team.

WillooWisp commented 6 months ago

Okay? So where is the proper place to report this issue then, do you know?

jcesarmobile commented 6 months ago

Probably https://github.com/angular/angular-cli, it's the repository linked from npm for @angular-devkit/build-angular package.

jcesarmobile commented 6 months ago

I've been doing more digging and looks like I was wrong and the problem is in Ionic CLI.

Since @angular-devkit/build-angular:browser-esbuild uses vite, the Ionic CLI is not able to handle it correctly. We will need to create a new runner for Angular similar to the vue-vite and react-vite runners that were added recently.

I've just done a quick test and copied the vue-vite runner code into a new "angular-vite" type of app and it worked as expected.

WillooWisp commented 6 months ago

Okay, yes, so it seems after the angular cli team investigated this.

https://github.com/angular/angular-cli/issues/26396

greg-md commented 4 months ago

still not fixed?

robsonos commented 4 months ago

Same error here with Ionic 7.6.2 and Angular 17.0.8