-
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
Import only parts of amplify? #488
Comments
@jliebrand we are working towards migrating to rollup in order to provide separate bundles so you can do something like this. It's currently in our backlog i don't have a specific date right now. |
@mlabieniec Wouldn't it be possible to get rid of the default class that namespaces all part apis as statics without switching amplifies build system? Because this is what breaks userland tree shaking I suspect... Edit: Sorry just now really read OPs feature request. What I proposed would only solve #701. |
This needs to be prioritized! I'm trying to use auth APIs but I'm also getting Chatbots and stuff - which is extra bad because Chatbot requires me to add babel-polyfill to my site - which is another bloat. Tree shaking can be supported without moving to rollup. I hope this can be done soon. |
Hey guys we are working on to make the whole library modularized which means you can import only certain module as you want. For now it's in the branch |
@powerful23 That's great news. Is it published on npm under some tag? I cannot use github branches as package sources due to corporate policy. |
@mrchief Not yet but we will publish a beta version ASAP |
Will you publish the modularized library as ES modules (which all modern browsers support)? That would save a lot of time during development by not having to rely on bundlers handling non-standard module formats. |
@hotgazpacho thanks for the feedback. Yes we are aware of this one and are working on this. |
is |
@stevemao yes. In that way you won't import other categories like |
Thanks @powerful23 , I was hoping that |
It's not that |
I'm probably missing something here, but if I do:
Things work, but if I do
It fails with TypeError: Amplify.configure is not a function ? |
@jliebrand can you try |
@powerful23 sorry for the delay, been a bit snowed under. Yes that does work, although there are some more gotchas. 1- the configure doesn't do anything, unless you had also loaded the modules that you are trying to configure. This threw me, as I'm using those modules elsewhere and the configure didn't complain. So to get it working properly, you have to do something like this:
Trying to configure modules that are not loaded should probably throw an exception, or at least log a warning to the console? 2- this actually ends up producing bigger chunks for the end user to download. Just pulling in the massive aws-amplify resulted in a chunk with the size 861k. Now that I've split it out in core, auth and api, I end up with three separate modules: 380k, 465k and 242k, totalling 1087k. Are the individual modules expected to get slimmed down so that this is the correct approach? |
@jliebrand thanks for your advice. Did you check the final bundle size of your app? Those separate modules have some common modules like |
Ok, I've combined the modules I need (core, auth and api) in to my own bundle and dynamically load that now. That's brought it down to 600k... still too big for my liking, but better than aws-amplify |
@jliebrand what tool are you using to generate the javascript breakdown image? |
@cliffordh source-map-explorer (https://www.npmjs.com/package/source-map-explorer) |
Are there any plans to create targeted bundles? eg. web / node / isomorphic? That might help to reduce bundle sizes too but I know that's a huge undertaking. |
I just noticed the huge graphql bundle as well. This should really be fixed. Amazon has the coin to do it :) |
Hi, any updates on this? I'm already stripping |
Currently, aws-amplify is a whopping 2/3rds of my web app bundle size. I'd love to see graphql out of my bundle, and clear documentation for importing modules a la carte like @jliebrand is attempting above |
So i spent some time today trying to remove graphql since I dont use it. A workaround that is working for me is I used craco to modify the webpack config without ejecting create react app to ignore graphql, and my build doesnt include the dependency anymore. here is my craco.config.js |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still a valid issue. @manueliglesias how is this progressing?? |
friendly ping... |
@antonsamper @jliebrand about the library bundle size please check the RFC: #3365 |
@powerful23 thanks, will keep a close eye on it |
@jliebrand I have referenced this issue to the overall RFC that we are currently working on. |
@sammartinez thanks! Any guestimate when the preview work will be rolled up into the master release? |
Any updates? |
@luchoman08 Here's mine
|
maybe should be import Auth from '@aws-amplify/auth'
import API from '@aws-amplify/api'
import { AmplifyPlugin } from 'aws-amplify-vue'
Auth.configure({...})
Vue.use(AmplifyPlugin, { Auth, API }) |
This has been closed with #5243 that implemented tree shaking and modular imports. |
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 |
Hi there, I am using amplify inside a react app, where i have code split amplify out in to a chunk like this (pseudo code):
I only want to use Auth and API but pulling aws-amplify in like this also gives me all the code for storage etc... Is there a way to selectively pull in the various parts? I tried
But that didn't seem to work?
The text was updated successfully, but these errors were encountered: