Closed joshuaMarple closed 1 year ago
Was unable to recreate this in another project, closing.
I believe the step I had missed was adding the amplify npm modules with
npm install --save aws-amplify @aws-amplify/ui-angular
npm start
Reopening- this is happening after adding authentication and the database backend. I don't have these issues when just creating the default angular app.
hi @joshuaMarple I am also facing the same issue I am using angular v15 "aws-amplify": "^5.2.4", "@aws-amplify/ui-angular": "^3.2.18",
@sparteek91 and @joshuaMarple, can you both check to see if there is another dependency besides aws-amplify
that is importing the buffer
polyfill (see this comment in issue #10268).
After looking through the angular-cli repo for similar errors, there might be a couple ways we can try to resolve this. Can one of you try deleting your node_modules
folder as well as your package-lock.json
file, and then reinstalling all dependencies with the npm install
command?
@sparteek91 and @joshuaMarple, can you both check to see if there is another dependency besides
aws-amplify
that is importing thebuffer
polyfill (see this comment in issue #10268).After looking through the angular-cli repo for similar errors, there might be a couple ways we can try to resolve this. Can one of you try deleting your
node_modules
folder as well as yourpackage-lock.json
file, and then reinstalling all dependencies with thenpm install
command?
Thanks, it solved the issue
Can also confirm that deleting node_modules
and package-lock.json
and running npm install
resolves this issue. Seems like an incompatible version of buffer
is being included with Angular CLI.
I got the same Optimization Error a week ago and had spent a few days narrowing down the culprits.
It is from a change in @aws-amplify/predictions > 5.1.6 . which I don't reference in my Angular 15 code, but is part of the @aws-amplify/ui-angular
You can bypass the problem with the followin in your package.json, until the underlying problem is fixed ( see pull request https://github.com/aws-amplify/amplify-js/pull/11453 )
"overrides":{ "aws-amplify": { "@aws-amplify/predictions": "5.1.6" } },
Here's a repro repo: https://github.com/wlee221/angular-amplify-bug. npm install && npm run build
will fail.
I could confirm that rollbacking aws-amplify
to 5.2.1
(which is right before the buffer commit) fixes this error.
Yes, we also got the same issue we are using "aws-amplify": "^5.0.25"
version. We tried everything with different versions and at last keeping aws-amplify to 5.2.1 fixes this error. No need to remove the package-lock.json as we will lost the track.
Affirmative. Staying with "5.2.1" works.. but I researched further to find the underlying culprit. I am able to use aws-amplify 5.2.4 ie with "^5.x.x" in package.json , but override with "@aws-amplify/predictions": "5.1.6"
per above. by inserting the following into package.json:
...
"overrides":{
"aws-amplify": {
"@aws-amplify/predictions": "5.1.6"
}
},
...
nadetastic and wlee221 reacted with thumb
@gerrytsui thank you for sharing that. I am using aws-amplify for only authentication so, is there a way that I can only use aws-amplify/auth library rather getting all the dependencies coming with aws-amplify.
is there a way that I can only use aws-amplify/auth library...
@sandeep-bhaskar , if you need the ui components ( e.g. the Authenticator UI), the ui-angular has aws-amplify as a dependency, so answer is No. We rely on webpack treeshaking, so it is a moot point.
e.g. we don't use Predictions, but it is causing the ng build optimization error.
@gerrytsui we don't need the ui components, we are using our own custom components. But, we are using federated logins and cognito.
We tried using amazon-cognito-identity-js
but this will work only for cognito. It is not supporting federated logins.
Updating this issue to be a bug
and will provide an updates on a fix soon. Temporary workarounds are described in comments above until fix is in place.
The proposed fix has been released to npm and testing confirms that the build issue is unreproducible in the example app provided above.
Thank you all for your input on this issue.
Thanks for merging and release to npm. I, too, am confirming our (huge) production app can build without the Optimization error.
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication, GraphQL API
Amplify Categories
auth, storage, hosting
Environment information
Describe the bug
I am seeing the bug as described in https://github.com/aws-amplify/amplify-js/issues/10268.
I have double checked that all of the polyfill settings are being set as defined in https://docs.amplify.aws/start/getting-started/setup/q/integration/angular/.
I can recreate this with just running
ng build
.The error goes away if I turn off all optimizations.
The exact error is
Expected behavior
I expect the tutorial app to be published
Reproduction steps
I followed exactly the steps in the tutorial.
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response