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

convert global objects falsely if they are exported #84

Closed
xiechao06 opened this issue Jul 28, 2016 · 1 comment · Fixed by #107
Closed

convert global objects falsely if they are exported #84

xiechao06 opened this issue Jul 28, 2016 · 1 comment · Fixed by #107

Comments

@xiechao06
Copy link

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
deconflict against globals
@Rich-Harris
Copy link
Contributor

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

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants