forked from browserify/module-deps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtr_no_entry.js
31 lines (29 loc) · 945 Bytes
/
tr_no_entry.js
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
var mdeps = require('../');
var test = require('tap').test;
var JSONStream = require('JSONStream');
var packer = require('browser-pack');
var through = require('through2');
var concat = require('concat-stream');
var path = require('path');
test('transform no entry', function (t) {
t.plan(1);
var p = mdeps({
transform: [ function (file) {
return through(function (buf, enc, next) {
this.push(String(buf).replace(/AAA/g, '"WOW"'));
next();
});
} ]
});
p.end({
file: path.join(__dirname, '/files/tr_no_entry/main.js'),
id: 'xxx'
});
p.pipe(JSONStream.stringify()).pipe(packer())
.pipe(concat(function (body) {
var con = { log: function (x) { t.equal(x, 'WOW') } };
var src = 'require=' + body.toString('utf8') + ';require("xxx")';
Function('console', src)(con);
}))
;
});