-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ionic 3 production builds not working after installing amplify #1003
Comments
Hi @johneast , We recently addressed some issues related to Angular's AOT compilation, which could be part of the issue here. I was just able to successfully do a prod build in an ionic app using AOT Amplify patch. I'm closing this issue for now, but if you find that the latest Amplify deployment doesn't fix your problem please speak up. Thanks! |
Reopened issue - investigating whether this is truly related to AOT. |
I've rebuilt and redeployed with the latest version and can confirm it works now. |
After production builds working for a little while, this issue has come back and I'm getting the same error again. My package.json looks like
I've completely removed my It's weird that the problem went away and then came back again. I can't figure out what has changed. Other environment settings |
Looking into this a bit more. Amplify works with production builds with Ionic 4, but not with Ionic 3. I think when I reported it was working, that was with my Ionic 4 project, and not my Ionic 3 project. Apologies for the confusion. |
I'm stuck with the same error message. I can't run my Ionic 3 production build anymore. :-( Error message:
I'm using this libs:
Any help would be really much appreciated! |
Out of interest @svzi have you tried it with the latest 1.0.4-unstable.* of Also, I note, there is a new version of |
I've also just noticed that Amplify now supports modular imports. I don't know about your use case, but I'm not using the graphql part of amplify so I'm going to see if only importing what I need fixes the issue. |
Putting this here in case anyone else has a similar issue and they want to know how to get around it. In my use case, I'm not using AppSync so have no need for graphql, this meant I was able to get around the problem by using the modular imports of amplify and only import what I needed, rather than importing the entire amplify library. See https://github.com/aws-amplify/amplify-js/wiki/Amplify-modularization So instead of import Amplify from 'aws-amplify'; I have import Amplify from '@aws-amplify/core' Currently, the AmplifyService in the aws-amplify-angular module doesn't support modular imports, so I made my own until the official one does. It looks a little like this: import { Injectable } from '@angular/core';
import Amplify from '@aws-amplify/core';
import Auth, { AuthClass } from '@aws-amplify/auth';
import PubSub from '@aws-amplify/pubsub';
@Injectable()
export class AmplifyService {
private _auth: AuthClass;
private _pubsub: any;
constructor() {
// According to the docs, this shouldn't be necessary, but without it I couldn't get it to work
Amplify.Auth = Auth;
Amplify.PubSub = PubSub;
this._auth = Amplify.Auth;
this._pubsub = Amplify.PubSub;
}
auth(): AuthClass {
return this._auth;
}
pubsub(): any {
return this._pubsub;
}
} For my application, I only need auth and pubsub, so that's all I'm importing. |
I'm also facing this issue. I tried aws-amplify 1.0.8 and aws-amplify-angular 2.0.0 and it still doesn't work. I did some digging in my node_modules folder and I found that AWS Amplify defines graphql version 0.11.7 in its package-lock.json file (node_modules/aws-amplify/package-lock.json) but the API module uses 0.13.0 in its package.json file (node_modules/@aws-amplify/api/package.json). That might be the problem. Still haven't found a solution... Thanks for the workaround @johneast. It' a great approach but I need to use the API module and that one has graphql dependency. Any other information/suggestion is appreciated :) |
@johneast Thank you very much for your feedback and suggestion. I've updated aws-amplify to 1.0.8 and aws-amplify-angular to 1.0.5, but neither does solve my issue. I've also tried your solution by implementing my own
I didn't find the source code of aws-amplify-angular, so I couldn't have a look at how to implement because I'm not familar with the aws-amplify library itself. For that reason I'm waiting for an out-of-the-box solution that simply works. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
After building the app with the
ionic build --prod
command and deploying to S3 for hosting, the following error is found in the browser consoleIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.
Install the ionic framework and create a new app, install amplify
import
AmplifyAngularModule
andAmplifyService
in app.module.ts, for instance:Run a production build:
Deploy the built app to S3 bucket and try to load it in a browser. App fails to load.
What is the expected behavior?
Browser should load the app when navigating to the correct URL
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
aws-amplify v0.4.4
aws-amplify-angular v0.1.4
Seen bug in Safari and Chrome on Mac and iOS
Prior to installing amplify building and deploying ionic apps worked.
You can turn on the debug mode to provide more info for us by setting
window.LOG_LEVEL = 'DEBUG';
in your app.The text was updated successfully, but these errors were encountered: