Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Using --prod causes error in app #780

Closed
bilalsoomro opened this issue Feb 24, 2017 · 3 comments
Closed

Using --prod causes error in app #780

bilalsoomro opened this issue Feb 24, 2017 · 3 comments

Comments

@bilalsoomro
Copy link

Short description of the problem:

My build created using --prod and --release flags gets stuck at startup due to the following error which I captured in logcat.

file:///android_asset/www/build/main.js: Line 29 : Uncaught Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/***/ionic2app/src/pages/react-page/react-page.js' at Error (native)

What behavior are you expecting?

The build to work like a normal --release build with the --prod optimizations

Steps to reproduce:

  1. Created a custom webpack config and added it to my package.json like this...
"config": {
   "ionic_webpack": "./webpack.config.js"
 }
  1. Inside my custom config, I added support for tsx by changing one of the module loader for ts
{
  test: /\.(ts|tsx)$/,
  loader: process.env.IONIC_WEBPACK_LOADER
}
  1. Created a page, imported react and changed the file extension to tsx to I can use react's render functionality. When I run "ionic run android", it is able to build a debug version of the app and run on my device. I can also run "ionic build android --release" to build an unsigned apk. But when I run "ionic build android --release --prod" to optimize my ionic2 app, the app has an error inside the assets/www/build/main.js file saying that my page.js is missing. It seems like it didnt get added to my bundled main.js properly.

Which @ionic/app-scripts version are you using?
1.1.4

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
My ionic version is....
"ionic-angular": "2.1.0"

@bilalsoomro
Copy link
Author

Here's a repo that can reproduce my error. You may try and run "ionic run android --prod" and see the error in the console once the app is launched. Am I importing React correctly?

https://github.com/sunny061/ionic2-react-app

@bilalsoomro
Copy link
Author

Update: I've managed to solve my issue by ditching my tsx file and importing react in a different way. I've updated my repo with the fix in case anyone else is interested in how I solved it.

@andrewvmail
Copy link

@bilalsoomro i got it to work on a vanilla install using this patch

https://gist.github.com/majo44/4862b8e7db6254975669e0a3f9d67a2a#file-angular-cli-1-5-0-tsx-loading-ugly-fix

more on the issue here
angular/angular-cli#8046

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants