Skip to content

punycode exports nothing if global AMD define is present #7224

Closed
@andyearnshaw

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)

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