Skip to content

jeroenpelgrims/browserify-window-context

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#browserify-window-context

NPM

Adds Window context to shimed module

By default in a shimed module this points to empty Object that makes a lot of non-CommonJS modules fail. This browserify transformation replaces this with Window and script runs as expected.

package.json

{
  "main": "./js/entry.js",
  "browser": {
    "old_good_script": "./js/vendor/old_good_script.js"
  },
  "browserify-shim": {
  },
  "browserify-window-context": [
    "old_good_script"
  ],
  "browserify": {
    "transform": [ "browserify-window-context", "browserify-shim" ]
  },
  "dependencies": {
    "browserify-shim": "~3.2.0",
    "browserify-window-context": "~0.1.1"
  }
}

Installation

npm install browserify-window-context

How it works

It simply wraps your script with another function and applies new window context like so:

(function () {' + data + '}).apply(window);

Setup

Add alias of your script to browser:

  "browser": {
    "old_good_script": "./js/vendor/old_good_script.js"
  },

Then add alias of your script to browserify-window-context:

  "browserify-window-context": [
    "old_good_script"
  ],

About

Replaces default module context with Window

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 100.0%