1

I'm looking at code which is generated with the AWS-SDK Javascript builder

I've generated a minimal set, which only includes AWS.Kinesis and AWS.KinesisAnalytics

I'm trying to make some sense of the code it generates, see snippet below:

_xamzrequire = function e(t, n, r) {
    function s(o, u) {
        if (!n[o]) {
            if (!t[o]) {
                var a = typeof _xamzrequire == "function" && _xamzrequire;
                if (!u && a) return a(o, !0);
                if (i) return i(o, !0);
                var f = new Error("Cannot find module '" + o + "'");
                throw f.code = "MODULE_NOT_FOUND", f;
            }
            var l = n[o] = {
                exports: {}
            };
            t[o][0].call(l.exports, function(e) {
                var n = t[o][1][e];
                return s(n ? n : e);
            }, l, l.exports, e, t, n, r);
        }
        return n[o].exports;
    }
    var i = typeof _xamzrequire == "function" && _xamzrequire;
    for (var o = 0; o < r.length; o++) s(r[o]);
    return s;
}({
    98: [ function(require, module, exports) {
        var AWS = {
            util: require("./util")
        };
        var _hidden = {};
        _hidden.toString();
        module.exports = AWS;
        AWS.util.update(AWS, {
            VERSION: "2.6.3",
            Signers: {},
            Protocol: {
                Json: require("./protocol/json"),
                Query: require("./protocol/query"),
                Rest: require("./protocol/rest"),
                RestJson: require("./protocol/rest_json"),
                RestXml: require("./protocol/rest_xml")
            },
            XML: {
                Builder: require("./xml/builder"),
                Parser: null
            },

What I don't understand, where does this code find it's includeds, e.g:

Json: require("./protocol/json"),

The AWS-SDK Javascript builder generates just one file, so how can it include for example ./protocol/json, where / how can it find this file??

Gio
  • 3,242
  • 1
  • 25
  • 53
  • @ceejaoz, I think this is not a duplicate. I believe I know what the require keyword means in Javascript, it resolves libraries and modules in the Node search path and now part of standard Javascript. However in this case the code is generated by AWS-SDK Javascript generator (for browser), it doens't generate these files. – Gio Sep 20 '16 at 15:59
  • 1
    If you open the minified sdk https://sdk.amazonaws.com/js/aws-sdk-2.6.3.min.js and convert it to json/pretty format, you will find that it contains RestXml:e("./protocol/rest_xml")} inside it. And that's how it loads them – Cyclotron3x3 Sep 20 '16 at 16:06

0 Answers0