Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80698 views
1
var browserify = require('../');
2
var test = require('tap').test;
3
4
test('identical content gets deduped and the row gets a "nomap" flag set when sourcemaps are turned on', function (t) {
5
t.plan(4)
6
7
var rows = [];
8
browserify({ debug: true })
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 nomappeds = rows.filter(function (x) { return x.nomap });
16
var nm = nomappeds[0];
17
18
t.equal(rows.length, 3, 'packs 3 rows');
19
t.equal(nomappeds.length, 1, 'one of has nomapped flag set');
20
t.equal(
21
rows.filter(function (x) {
22
return x.id == nm.dedupeIndex
23
}).length,
24
1,
25
'2 rows with the same hash as the duplicate exist'
26
);
27
t.similar(nm.source, /module\.exports.*=.*require\(.+\)$/, 'redirects duplicate to original via require call');
28
}
29
})
30
31
test('identical content gets deduped and the row gets a "nomap" flag set when sourcemaps are turned off', function (t) {
32
t.plan(4)
33
34
var rows = [];
35
browserify({ debug: false })
36
.on('dep', [].push.bind(rows))
37
.require(require.resolve('./dup'), { entry: true })
38
.bundle(check);
39
40
function check(err, src) {
41
if (err) return t.fail(err);
42
var nomappeds = rows.filter(function (x) { return x.nomap });
43
var nm = nomappeds[0];
44
45
t.equal(rows.length, 3, 'packs 3 rows');
46
t.equal(nomappeds.length, 1, 'one of has nomapped flag set');
47
t.equal(
48
rows.filter(function (x) {
49
return x.id == nm.dedupeIndex
50
}).length,
51
1,
52
'2 rows with the same hash as the duplicate exist'
53
);
54
t.similar(nm.source, /module\.exports.*=.*require\(.+\)$/, 'redirects duplicate to original via require call');
55
}
56
})
57
58