Open squallliu opened 7 years ago
@squallliu,
Can you upload a sample repo that I can work off of?
Thanks, Dan
@danbucholtz
@danbucholtz I can confirm that issue as well - my app has a dependency to a library with custom ionic components. Those components extends ionic basic components. When ionic_manual_treeshaking is true, classes of ionic components that are not used directly within the app, are not accessible for components from the library... When ionic_manual_treeshaking is set to false it works, but css files is not generated properly (reported in another issue).
Similar situation, but in my case ModalController and ToastController are undefined in my UIService provider with a --prod build but they exist without the prod flag (AlertController exists in both cases). If I attempt a build with --manualTreeshaking false then the app errors entirely with Uncaught SyntaxError: Unexpected token var from main.js .
"ionic-angular": "3.6.1",
"@ionic/app-scripts": "2.1.4",
@squallliu @mmlleevvyy @danbucholtz AlertController and LoadingController were working in my app because they were imported and injected into at least one "page" component in the app. My workaround was to import & inject the following in app.component.ts and now they are no longer undefined in my UIService provider with --prod builds where --manualTreeshaking false is not specified (default true).
import { Platform, AlertController, LoadingController, ModalController, ToastController } from 'ionic-angular'; //import & inject these to prevent manualTreeshaking removal in --prod builds
constructor(
private platform: Platform,
private alert: AlertController,
private loading: LoadingController,
private modal: ModalController,
private toast: ToastController,
public translate: TranslateService,
public ui: UIService,
private splashscreen: SplashScreen,
private statusbar: StatusBar
) { ... }
;
Steps to reproduce:
set "ionic_manual_treeshaking" to false it work.