Skip to content
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

RequireJS issue #999

Closed
serkejal opened this issue May 23, 2016 · 8 comments
Closed

RequireJS issue #999

serkejal opened this issue May 23, 2016 · 8 comments
Labels
guidance Question that needs advice or information.

Comments

@serkejal
Copy link

Starting from version 2.3.11 i have an issue with aws sdk for javascript using requirejs.
Unitl 2.3.10 i simply include the path of the library installed via bower and then load it when needed

require.config({
    paths: {
        'app':               './app',
        ....
        aws:                'assets/lib/aws-sdk/dist/aws-sdk',
       ....
     },
     shim: { ... }
);

require([
    'angular',
    'app',
    'aws'], function (angular, app) {
    var $html = angular.element(document.getElementsByTagName('html')[0]);
    angular.element().ready(function () {
        // bootstrap the app manually
        angular.bootstrap(document, ['app']);
    });

starting from 2.3.11 i'm stucked in this error

angular.js:13550 TypeError: punycode.toASCII is not a function
    at Url.parse (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:10762:32)
    at Object.urlParse [as parse] (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:10621:5)
    at Object.urlParse (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:6464:27)
    at new Endpoint (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:1765:36)
    at setEndpoint (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:4907:21)
    at initialize (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:4652:10)
    at Service [as constructor] (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:4637:10)
    at features.constructor (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:6955:24)
    at new features.constructor (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:6955:24)
    at Service [as constructor] (http://localhost:3000/assets/lib/aws-sdk/dist/aws-sdk.js:4636:30) <div class="content-wrapper ng-scope" ui-view="content">

I see that problem is relative to punycode library that was included inside aws sdk and is not correctly inject at this line:

line 10554: var punycode = require('punycode');

but the module appears correctly declared also for AMD

    punycode = {
        'version': '1.4.1',
        'ucs2': {
            'decode': ucs2decode,
            'encode': ucs2encode
        },
        'decode': decode,
        'encode': encode,
        'toASCII': toASCII,
        'toUnicode': toUnicode
    };
    if (
        typeof define == 'function' &&
        typeof define.amd == 'object' &&
        define.amd
    ) {
        define('punycode', function() {
            return punycode;
        });
    } else if (freeExports && freeModule) {
        if (module.exports == freeExports) {
            freeModule.exports = punycode;
        } else {
            for (key in punycode) {
                punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
            }
        }
    } else {
        root.punycode = punycode;
    }

Can anyone help me with this?

@chrisradek
Copy link
Contributor

@serkejal
Can you include a minimal gist that shows how you're pulling in the SDK and the error that you're seeing? The version of browserify that the SDK uses in 2.3.11 was updated, and it's possible this error is a result of that. If you can give me a minimal example I can see if that's the case and if we can shrinkwrap some of the dependencies.

@serkejal
Copy link
Author

For now you can check this jsfiddle example

i'm loading aws sdk form cdn and trying to get dynamodb instance. (of course the credential are missing)

if you try to run and check the console log you can find the error above.
Moreover you can switch the version of the sdk to 2.3.10 and re run, no error are shown in this case.

@MaxVita
Copy link

MaxVita commented May 24, 2016

We also running into the same issue while loading aws-sdk-js with requirejs.

Release 2.3.10 works
Release 2.3.11 and above fails

Easy to reproduce:

image

image

@chrisradek
Copy link
Contributor

@serkejal and @MaxVita
Can you try the latest version of the SDK? Last week I updated our npm-shrinkwrap file that is used for the browser version of the SDK to hopefully solve this issue.

@MaxVita
Copy link

MaxVita commented Jun 1, 2016

I have tested the 2.3.16 Version. It works! Thank you for the fix.

@chrisradek
Copy link
Contributor

Glad to hear it, thanks for reporting this issue!

@MaxVita
Copy link

MaxVita commented Sep 19, 2016

hi @chrisradek

i got this old error in the new sdk version 2.6.3

2.5.6 works well and all versions >2.5.6 will fail with "TypeError: punycode.toASCII is not a function"

@srchase srchase added guidance Question that needs advice or information. and removed Question labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

4 participants