Amplify-js: Amplify global

Created on 11 Apr 2018  路  6Comments  路  Source: aws-amplify/amplify-js

Do you want to request a feature or report a bug?

Have an Amplify global namespace, (or maybe AWS.Amplify), to use Amplify outside of npm/webpack tooling.

What is the current behavior?

Not sure if there's a way to use aws-amplify without npm/webpack.

What is the expected behavior?

It'll be great to easily use this without npm/webpack, maybe have it be on a CDN.

feature-request question

All 6 comments

@quangv you can use Amplify without webpack, it's a little different setup but even if you include the amplify.min.js dist in your head tag you can still access and configure it, this can give you a bit of an idea on that with for example ember.js: https://itnext.io/adding-aws-amplify-to-an-ember-js-application-72683167c476

Also, we have a request on cdnjs that is prioritized: https://github.com/cdnjs/cdnjs/issues/12677

But for now you can include the packages/aws-amplify/dist/ file/s in your page and access via the window object, see fiddle here: https://jsfiddle.net/0gmqtq7g/226/

@mlabieniec Thanks, that helped. I guess you can access it via window["aws-amplify"]

This solved the problem for me, I'll close the ticket. If anyone feels the need, feel free to re-open. :)

Your JS fiddle seems to throw an error:

Error: Cannot use e "__Schema" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

related: https://github.com/thheller/shadow-cljs/issues/248

Error: Cannot use e "__Schema" from another module or realm.

Seems like related to something with graphql

@mlabieniec Thanks, that helped. I guess you can access it via window["aws-amplify"]

This solved the problem for me, I'll close the ticket. If anyone feels the need, feel free to re-open. :)

Hi I have the same issue, can you give me complete details how you have solved this. I am a beginner in aws.

@jayalog what issue are you having?

I think my original question was just about using aws-amplify without webpack/Babel build step.

Much like how other libs like jQuery, moment, lodash you can use directly after including the script tag via their global/window variable name.

Was this page helpful?
0 / 5 - 0 ratings