static-module
Advanced tools
Comparing version 2.2.2 to 2.2.3
20
index.js
@@ -36,2 +36,16 @@ var fs = require('fs'); | ||
body = buf.toString('utf8').replace(/^#!/, '//#!'); | ||
var matches = false; | ||
for (var key in modules) { | ||
if (body.indexOf(key) !== -1) { | ||
matches = true; | ||
break; | ||
} | ||
} | ||
if (!matches) { | ||
// just pass it through | ||
output.end(buf); | ||
return; | ||
} | ||
if (opts.sourceMap) { | ||
@@ -44,7 +58,3 @@ inputMap = convertSourceMap.fromSource(body); | ||
for (var key in modules) { | ||
if (body.indexOf(key) === -1) continue; | ||
falafel(body, parserOpts, walk); | ||
break; | ||
} | ||
falafel(body, parserOpts, walk); | ||
} | ||
@@ -51,0 +61,0 @@ catch (err) { return error(err) } |
{ | ||
"name": "static-module", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "convert module usage to inline expressions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -89,1 +89,39 @@ var test = require('tape'); | ||
}); | ||
test('retain input source map when file has no static-module use', function (t) { | ||
t.plan(4); | ||
var content = fs.readFileSync(__dirname + '/sourcemap/main.js', 'utf8'); | ||
var minified = uglify.minify({ 'main.js': content }, { | ||
output: { beautify: true }, | ||
sourceMap: { | ||
url: 'inline', | ||
includeSources: true | ||
} | ||
}); | ||
var transform = staticModule({ | ||
not_sheetify: function () { return 'whatever'; } | ||
}, { sourceMap: true, inputFilename: 'main.js' }); | ||
transform.pipe(concat({ encoding: 'string' }, function (res) { | ||
var consumer = new SourceMapConsumer(convertSourceMap.fromSource(res).toObject()); | ||
var mapped = consumer.originalPositionFor({ | ||
line: 7, | ||
column: 0 | ||
}); | ||
t.equal(mapped.line, 8); | ||
t.equal(mapped.column, 0); | ||
mapped = consumer.originalPositionFor({ | ||
line: 7, | ||
column: 21 | ||
}); | ||
t.equal(mapped.line, 10); | ||
t.equal(mapped.column, 0); | ||
})); | ||
transform.end(minified.code); | ||
}); |
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
60615
1560