Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

'exports.clearTimeout' shadows global/window 'clearTimeout' #127

@ntilwalli

Description

@ntilwalli

Minimal reproduction repo: https://github.com/ntilwalli/rollupSuperagentIssue

I'm trying to bundle Superagent using rollup and it is not working. I had originally thought the issue had to do with this being overwritten to undefined but in actuality, the cause of the failure is the naming of one of the exports on the request-base.js module. That module exports a bunch of functions using exports.[name-of-function] syntax. One of the functions exported is exports.clearTimeout. That function itself calls the global clearTimeout, but this call to the global method gets shadowed upon transformation and during run-time the local clearTimeout function which tries to call the global clearTimeout ends up calling itself instead causing an error.

The offending function is here: https://github.com/visionmedia/superagent/blob/master/lib/request-base.js#L15

A non-ideal workaround does exist and has been posted (but this is arguably more of rollup-plugin-commonjs issue): forwardemail/superagent#1076

I'm looking to start a discussion on how to handle this. I'd be willing to submit a PR if given guidance.

cc: @pornel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions