Skip to content

punycode exports nothing if global AMD define is present #7224

Description

@andyearnshaw

If an AMD loader is defined on global, the punycode module no longer exports something if required with Node's require():

> global.define = function () {}
[Function]
> global.define.amd = {}
{}
> require('punycode')
{}

In particular, this affects Url.prototype.parse() method, which has a dependency on punycode.toASCIII().

> require('url').parse('http://foo.bar/baz')
TypeError: punycode.toASCII is not a function
    at Url.parse (url.js:312:32)
    at Object.urlParse [as parse] (url.js:73:5)
    at repl:1:16
    at REPLServer.defaultEval (repl.js:272:27)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:441:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)
    at REPLServer.Interface._onLine (readline.js:224:10)

Activity

  1. cjihrig commented on Jun 8, 2016

    @cjihrig
    Contributor

    Node core grabs punycode as is from https://github.com/bestiejs/punycode.js/. You might want to consider opening an issue there.

  2. andyearnshaw commented on Jun 8, 2016

    @andyearnshaw
    Author

    I figured as much but thought it might be a good idea to track the problem on both projects.

  3. mathiasbynens commented on Jun 10, 2016

    @mathiasbynens
    Contributor

    Patch that updates to Punycode.js v2.0.0, which only exports to module.exports: #7267

  4. added a commit that references this issue on Jun 27, 2016
  5. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions