insert-module-globals
Advanced tools
Comparing version 6.1.0 to 6.2.0
44
index.js
@@ -8,2 +8,3 @@ var parseScope = require('lexical-scope'); | ||
var processPath = require.resolve('process/browser.js'); | ||
var combineSourceMap = require('combine-source-map'); | ||
@@ -93,3 +94,3 @@ var defaultVars = { | ||
this.queue(closeOver(globals, source)); | ||
this.queue(closeOver(globals, source, file, opts)); | ||
this.queue(null); | ||
@@ -101,3 +102,3 @@ } | ||
function closeOver (globals, src) { | ||
function closeOver (globals, src, file, opts) { | ||
var keys = Object.keys(globals); | ||
@@ -107,19 +108,32 @@ if (keys.length === 0) return src; | ||
var wrappedSource; | ||
if (keys.length <= 3) { | ||
return '(function (' + keys.join(',') + '){\n' | ||
wrappedSource = '(function (' + keys.join(',') + '){\n' | ||
+ src + '\n}).call(this,' + values.join(',') + ')' | ||
; | ||
} | ||
// necessary to make arguments[3..6] still work for workerify etc | ||
// a,b,c,arguments[3..6],d,e,f... | ||
var extra = [ '__argument0', '__argument1', '__argument2', '__argument3' ]; | ||
var names = keys.slice(0,3).concat(extra).concat(keys.slice(3)); | ||
values.splice(3, 0, | ||
'arguments[3]','arguments[4]', | ||
'arguments[5]','arguments[6]' | ||
); | ||
return '(function (' + names.join(',') + '){\n' | ||
+ src + '\n}).call(this,' + values.join(',') + ')' | ||
; | ||
else { | ||
// necessary to make arguments[3..6] still work for workerify etc | ||
// a,b,c,arguments[3..6],d,e,f... | ||
var extra = [ '__argument0', '__argument1', '__argument2', '__argument3' ]; | ||
var names = keys.slice(0,3).concat(extra).concat(keys.slice(3)); | ||
values.splice(3, 0, | ||
'arguments[3]','arguments[4]', | ||
'arguments[5]','arguments[6]' | ||
); | ||
wrappedSource = '(function (' + names.join(',') + '){\n' | ||
+ src + '\n}).call(this,' + values.join(',') + ')'; | ||
} | ||
// Generate source maps if wanted. Including the right offset for | ||
// the wrapped source. | ||
if (!opts.debug) { | ||
return wrappedSource; | ||
} | ||
var sourceFile = path.relative(opts.basedir, file); | ||
var sourceMap = combineSourceMap.create().addFile( | ||
{ sourceFile: sourceFile, source: src}, | ||
{ line: 1 }); | ||
return combineSourceMap.removeComments(wrappedSource) + "\n" | ||
+ sourceMap.comment(); | ||
} |
{ | ||
"name": "insert-module-globals", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "insert implicit module globals into a module-deps stream", | ||
@@ -11,2 +11,3 @@ "main": "index.js", | ||
"JSONStream": "~0.7.1", | ||
"combine-source-map": "~0.3.0", | ||
"concat-stream": "~1.4.1", | ||
@@ -13,0 +14,0 @@ "lexical-scope": "~1.1.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16428
322
140
7
24
+ Addedcombine-source-map@~0.3.0
+ Addedamdefine@1.0.1(transitive)
+ Addedcombine-source-map@0.3.0(transitive)
+ Addedconvert-source-map@0.3.5(transitive)
+ Addedinline-source-map@0.3.1(transitive)
+ Addedsource-map@0.1.430.3.0(transitive)