ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.09k stars 13.51k forks source link

RC4 build for device fails with modified main.ts #9664

Closed themastersoda closed 7 years ago

themastersoda commented 7 years ago

Ionic version: (check one with "x") [ ] 1.x [ x] 2.x

I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior: Building for device with modified main.ts fails. If platformBrowserDynamic().bootstrapModule(AppModule); is not in the top level, of the file, build gives an error.

Expected behavior: Correctly check for bootstrapping code in main.ts, even if it is not in the top-level

Steps to reproduce: I am building an application based on https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp I have successfully modified custom webpack.config according to the one provided in latest app-scripts version (0.0.47).

Related code:

My main.ts looks like this:

import 'meteor-client-side';
import 'accounts-base-client-side';
import 'accounts-password-client-side';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

Meteor.startup(() => {
  platformBrowserDynamic().bootstrapModule(AppModule);
  Tracker.autorun(() => {
    if (Meteor.loggingIn()) return;
  });
});

Running ionic serve with this works, however, ionic build gives an error during ngc phase:

            update C:/xampp/htdocs/PROJECT/src/app/main.ts to match the following:
            https://github.com/driftyco/ionic2-app-base/blob/master/src/app/main.ts
[10:15:02]  ionic-app-script task: "build"
[10:15:02]  Error: Failed to find Angular bootstrapping code in C:/xampp/htdocs/PROJECT/src/app/main.ts. Please update
            C:/xampp/htdocs/PROJECT/src/app/main.ts to match the following:
            https://github.com/driftyco/ionic2-app-base/blob/master/src/app/main.ts

After extracting the code from Meteor.startup to the top level, build finishes without any problems.

Other information: none

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):


Your system information:

**C**ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.3.0
Xcode version: Not installed
jayeshanandani commented 7 years ago

Please try updating to ionic-app-scripts to 0.0.48

jgw96 commented 7 years ago

This issue was moved to driftyco/ionic-app-scripts#594

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.