Ionic-app-scripts: RC4 build for device fails with modified main.ts

Created on 21 Dec 2016  路  7Comments  路  Source: ionic-team/ionic-app-scripts

_From @themastersoda on December 16, 2016 8:30_

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

_Copied from original issue: driftyco/ionic#9664_

Most helpful comment

Same thing happens with ionic RC5 and ionic-app-scripts 1.0.0. Building application with --prod and --release flags results in this error.

All 7 comments

_From @jayeshanandani on December 20, 2016 18:19_

Please try updating to ionic-app-scripts to 0.0.48

Same thing happens with ionic RC5 and ionic-app-scripts 1.0.0. Building application with --prod and --release flags results in this error.

Having the same issue with RC5 and app scripts v.1.0.0

This issue can be fixed by changing the last argument (BOOLEAN) of typescript_utils_1.findNodes() call to TRUE in node_modules/@ionic/app-scripts/dist/aot/app-module-resolver.js . Apparently it defines whether to look for bootstrap in nested blocks.

This should be fixed in the next release of app-scripts. This change is in master already. We are no longer getting so fancy in how we resolve the app module.

Thanks,
Dan

@danbucholtz Is there a ETA on which the next release of app-scripts should be out? Doesn't have to be specific by any means. Maybe like sometime early February?

Not sure. Hopefully soonish. I have a bunch of big changes that we need to make so I will likely release something before we dive in too far.

Thanks,
Dan

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jgw96 picture jgw96  路  52Comments

DhruvGupta5 picture DhruvGupta5  路  49Comments

kleeb picture kleeb  路  48Comments

biesbjerg picture biesbjerg  路  78Comments

shlomiassaf picture shlomiassaf  路  83Comments