-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
54 lines (54 loc) · 4.94 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
"name": "insert-module-globals",
"version": "6.2.1",
"description": "insert implicit module globals into a module-deps stream",
"main": "index.js",
"bin": {
"insert-module-globals": "bin/cmd.js"
},
"dependencies": {
"JSONStream": "~0.7.1",
"combine-source-map": "~0.3.0",
"concat-stream": "~1.4.1",
"lexical-scope": "~1.1.0",
"process": "~0.6.0",
"through": "~2.3.4",
"xtend": "^3.0.0"
},
"devDependencies": {
"tap": "~0.4.0",
"browser-pack": "~0.10.2",
"module-deps": "~1.4.0",
"native-buffer-browserify": "~2.0.16"
},
"scripts": {
"test": "tap test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/substack/insert-module-globals.git"
},
"homepage": "https://github.com/substack/insert-module-globals",
"keywords": [
"__filename",
"__dirname",
"global",
"process",
"module-deps",
"browser-pack",
"browserify"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT",
"readme": "# insert-module-globals\n\ninsert implicit module globals\n(`__filename`, `__dirname`, `process`, `global`, and `Buffer`)\nas a browserify-style transform\n\n[![build status](https://secure.travis-ci.org/substack/insert-module-globals.png)](http://travis-ci.org/substack/insert-module-globals)\n\n# example\n\n``` js\nvar mdeps = require('module-deps');\nvar bpack = require('browser-pack');\nvar insert = require('insert-module-globals');\nfunction inserter (file) {\n return insert(file, { basedir: __dirname + '/files' });\n}\n\nvar files = [ __dirname + '/files/main.js' ];\nmdeps(files, { transform: inserter })\n .pipe(bpack({ raw: true }))\n .pipe(process.stdout)\n;\n```\n\n```\n$ node example/insert.js | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\nor use the command-line scripts:\n\n```\n$ module-deps main.js | insert-module-globals | browser-pack | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\nor use insert-module-globals as a transform:\n\n```\n$ module-deps main.js --transform insert-module-globals | browser-pack | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\n# methods\n\n``` js\nvar insertGlobals = require('insert-module-globals')\n```\n\n## var inserter = insertGlobals(file, opts)\n\nReturn a transform stream `inserter` for the filename `file` that will accept a\njavascript file as input and will output the file with a closure around the\ncontents as necessary to define extra builtins.\n\nWhen `opts.always` is truthy, wrap every file with all the global variables\nwithout parsing. This is handy because parsing the scope can take a long time,\nso you can prioritize fast builds over saving bytes in the final output.\n\nUse `opts.vars` to override the default inserted variables, or set\n`opts.vars[name]` to `undefined` to override an undefined variable that has\nalready been set by default.\n\nIf `opts.debug` is true, an inline source map will be generated to compensate\nfor the extra lines.\n\n# events\n\n## inserter.on('global', function (name) {})\n\nWhen a global is detected, the inserter stream emits a `'global'` event.\n\n# usage\n\n```\nusage: insert-module-globals {basedir}\n```\n\n# install\n\nWith [npm](https://npmjs.org), to get the library do:\n\n```\nnpm install insert-module-globals\n```\n\nand to get the bin script do:\n\n```\nnpm install -g insert-module-globals\n```\n\n# insert custom globals.\n\n`insert-module-globals` can also insert arbitary globals into files.\nPass in an object of functions as the `vars` option.\n\n``` js\nvar vars = {\n process: function (row, basedir) {\n return {\n id: \"path/to/custom_process.js\",\n source: customProcessContent\n }\n },\n Buffer: function (row, basedir) {\n return {\n id: 'path/to/custom_buffer.js',\n source: customProcessContent,\n //suffix is optional\n //it's used to extract the value from the module.\n //it becomes: require(...).Buffer in this case.\n suffix: '.Buffer'\n }\n },\n Math: function () {\n //if you return a string,\n //it's simply set as the value.\n return '{}'\n //^ any attempt to use Math[x] will throw!\n }\n}\n\nfunction inserter (file) {\n return insert(file, { vars: vars });\n}\nmdeps(files, { transform: inserter })\n .pipe(bpack({ raw: true }))\n .pipe(process.stdout)\n```\n\n\n# license\n\nMIT\n",
"readmeFilename": "readme.markdown",
"bugs": {
"url": "https://github.com/substack/insert-module-globals/issues"
},
"_id": "insert-module-globals@6.2.1",
"_from": "insert-module-globals@^6.1.0"
}