thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

Can I remove shimmed dependencies from the global scope? #194

Closed arcticShadow closed 8 years ago

arcticShadow commented 8 years ago

I have the following config in my package.json:

"browser": {
    "uikit": "./node_modules/uikit/dist/js/uikit.js",
    "uikit.css": "./node_modules/uikit/dist/css/uikit.css",
    "uikit/autocomplete": "./node_modules/uikit/dist/js/components/autocomplete.js",
    "uikit/autocomplete.css": "./node_modules/uikit/dist/css/components/autocomplete.css",
    "uikit/pagination": "./node_modules/uikit/dist/js/components/pagination.js"
  },
  "browserify": {
    "transform": [
      "browserify-shim",
      "browserify-css"
    ]
  },
  "browserify-shim": {
    "uikit": {
      "exports": "UIkit",
      "depends": [
        "jquery:window.jQuery",
        "uikit.css"
      ]
    },
    "uikit/autocomplete": {
      "depends": [
        "uikit:window.UIkit"
      ]
    }

As you may be able to tell, I am trying to get uikit to play nicely with CommonJS style loading.

The above works. in my Javascript files, i can

import uikit from 'uikit';
import uikitautocomplete from 'uikitautocomplete'

And both uikit and uikitautocomplete are available on the uikit object. (This is the way uikit works)

However, I have noticed that UIkit and jQuery objects are available globally whenever I import uikit. Can i stop this from happenning?

bendrucker commented 8 years ago

Short answer is no, verdict is here: https://github.com/thlorenz/browserify-shim/issues/137#issuecomment-84628544

arcticShadow commented 8 years ago

Ahh bother. Thanks for that link - missed it when i looked earlier.