-
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
1.2.3+ versions are breaking plain javascript/html imports #4666
Comments
@ajhool, we updated our webpack config to mark aws-amplify packages as external in amplify in hope to reduce the webpack bundle size but it seems we missed the predictions package. The idea was for clients to include the corresponding bundles (Such as only api + it's dependencies such as core and cache) rather than one giant bundle that includes everything. Looking at the aws-amplify package, that may not be possible since all of the dependent packages are referenced and so clients would have to include everything. I'm looking to make changes in aws-amplify to package everything in the bundle for now so that it's self sufficient. |
@Amplifiyer thanks, there also might have been a minor discussion at some point about hosting amplify on a cdn. That would also be a nice feature. My clients usually have the aws sdk imported via cdn in html/javascript and do not know how to do something similar with Amplify because it is more involved. |
@Amplifiyer additionally, I would like to leverage the modularized import functionality to reduce bundle sizes on plain javascript/html sites, but I am hesitant to do so because the behavior is not well-documented and I'm only confident in importing the whole aws-amplify package. I'm confident from experience, but not documentation, that importing the aws-amplify package will create a |
@ajhool as mentioned in the #4471 we have discussed it internally but haven't reached a consensus whether we will be able to do it or not. Also as you mentioned, we don't have official documentation or support for plain javascript apps as of right now. I'll be fixing the regression so that the full bundle from "aws-amplify" package is usable again. But to make it modularized is something we need to work as a feature request. |
@Amplifiyer @ajhool I am also hoping for a Vanilla JS method and example whith minimal required file sizes. I am trying to keep my websites as small as possible (<14kb gzipped). Adding Amplify or SDK increases the size significantly, while I guess I only want to use the Auth method. At the moment, to keep file size as small as possible, and to keep Vanilla JS without any frameworks or bundlers, I am following the instructions here: By including the following files:
To reduce the size of the aws-sdk-*.min.js file I build a custom SDK which only includes the AWS.CognitoIdentity part, using https://sdk.amazonaws.com/builder/js/. @Amplifiyer Is this approach using the amazon-cognito-identity.min.js and SDK still maintained? Or is only Amplify maintained? |
@MartijnHarmenzon , what you are doing is still valid, in our next major version release (along with aws-sdk) our focus is to provide modularized imports and reduced bundle sizes with Amplify using webpack's tree shaking. However, I'm not sure how that can be beneficial in vanilla JS apps. |
…build (aws-amplify#4745) Co-authored-by: Sam Martinez <sammartinez19@gmail.com> Co-authored-by: Eric Clemmons <eric@smarterspam.com>
I was able to do it in this way. It works perfectly <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./node_modules/aws-amplify/dist/aws-amplify.min.js"></script>
<script>
aws_amplify.Amplify.configure({
// content of aws-exports.js
});
try {
const user = aws_amplify.Amplify.Auth.signIn("<username>", "<pass>");
console.log(user);
} catch (error) {
console.log('error signing in', error);
}
try {
const { user } = aws_amplify.Amplify.Auth.signUp({
username: "<username>",
password: "<pass>",
attributes: {
email: "<email>" // optional
}
});
console.log(user);
} catch (error) {
console.log('error signing up:', error);
}
</script>
</head>
<body>
</body>
</html>` |
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 |
Describe the bug
Up to version 1.2.2, it was possible to import Amplify as a script in an html page by retrieving the built file from /node_modules/aws-amplify/dist/amplify.js . After version 1.2.2, the script fails to load Tested in 1.2.3, 1.2.4, 2.2.1 and all fail with same error.
Error:
To Reproduce
Steps to reproduce the behavior (Linux):
Expected behavior
Amplify is the recommended javascript aws sdk and it must be able to load in plain html / javascript.
N/A
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Sample code
Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)
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: