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

convert global objects falsely if they are exported #84

Closed
xiechao06 opened this issue Jul 28, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@xiechao06
Copy link

commented Jul 28, 2016

take package gloabl for example:

// file: document.js
var topLevel = typeof global !== 'undefined' ? global :
    typeof window !== 'undefined' ? window : {}
var minDoc = require('min-document');

if (typeof document !== 'undefined') {
    module.exports = document;
} else {
    var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];

    if (!doccy) {
        doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
    }

    module.exports = doccy;
}

when using in browser, the object document actually is window.document, but since it is exported, the last snippet is converted to (notice document is changed to document$1):

var document$1 = createCommonjsModule(function (module) {
    var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
        typeof window !== 'undefined' ? window : {}
    var minDoc = interopDefault(require$$0$18);

    if (typeof document$1 !== 'undefined') {
        module.exports = document$1;
    } else {
        var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];

        if (!doccy) {
            doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
        }

        module.exports = doccy;
    }
});

Rich-Harris added a commit that referenced this issue Sep 17, 2016

Rich-Harris added a commit that referenced this issue Sep 17, 2016

Merge pull request #107 from rollup/gh-84
deconflict against globals
@Rich-Harris

This comment has been minimized.

Copy link
Contributor

commented Sep 17, 2016

Sorry for the long wait, this is finally fixed in 5.0.1. Side-note: that package is hilarious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.