Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80522 views
1
var browserify = require('../');
2
var test = require('tap').test;
3
4
test('identical content gets deduped and the row gets an implicit dep on the original source', function (t) {
5
t.plan(1)
6
7
var rows = [];
8
browserify()
9
.on('dep', [].push.bind(rows))
10
.require(require.resolve('./dup'), { entry: true })
11
.bundle(check);
12
13
function check(err, src) {
14
if (err) return t.fail(err);
15
var deduped = rows.filter(function (x) { return x.dedupeIndex });
16
var d = deduped[0];
17
18
t.deepEqual(d.deps, { 'dup': d.dedupeIndex }, "adds implicit dep");
19
}
20
})
21
22
test('identical content gets deduped with fullPaths', function (t) {
23
t.plan(1)
24
25
var rows = [];
26
browserify({fullPaths: true})
27
.on('dep', [].push.bind(rows))
28
.require(require.resolve('./dup'), { entry: true })
29
.bundle(check);
30
31
function check(err, src) {
32
if (err) return t.fail(err);
33
var deduped = rows.filter(function (x) { return x.dedupe });
34
var d = deduped[0];
35
36
t.deepEqual(
37
d.source,
38
'arguments[4]['+ JSON.stringify(d.dedupe) + '][0]'
39
+ '.apply(exports,arguments)',
40
"dedupes content"
41
);
42
}
43
})
44
45