forked from rollup/rollup
/
_config.js
51 lines (49 loc) · 1.44 KB
/
_config.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module.exports = {
description: 'deduplicates asset that have the same source',
options: {
input: ['main.js'],
plugins: {
buildStart() {
this.emitFile({ type: 'asset', name: 'string.txt', source: 'string' });
this.emitFile({ type: 'asset', name: 'stringSameSource.txt', source: 'string' });
this.emitFile({
type: 'asset',
name: 'sameStringAsBuffer.txt',
source: Buffer.from('string') // Test cross Buffer/string deduplication
});
// Different string source
this.emitFile({ type: 'asset', name: 'otherString.txt', source: 'otherString' });
const bufferSource = () => Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
this.emitFile({
type: 'asset',
name: 'buffer.txt',
source: bufferSource()
});
this.emitFile({
type: 'asset',
name: 'bufferSameSource.txt',
source: bufferSource()
});
this.emitFile({
type: 'asset',
name: 'sameBufferAsString.txt',
source: bufferSource().toString() // Test cross Buffer/string deduplication
});
// Different buffer source
this.emitFile({
type: 'asset',
name: 'otherBuffer.txt',
source: Buffer.from('otherBuffer')
});
// specific file names will not be deduplicated
this.emitFile({ type: 'asset', fileName: 'named/string.txt', source: 'named' });
this.emitFile({
type: 'asset',
fileName: 'named/buffer.txt',
source: bufferSource()
});
return null;
}
}
}
};