-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroadroller-plugin.js
More file actions
35 lines (30 loc) · 857 Bytes
/
roadroller-plugin.js
File metadata and controls
35 lines (30 loc) · 857 Bytes
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
import { Packer } from 'roadroller';
export default function roadroller() {
return {
name: 'compress-with-roadroller',
async generateBundle(_, bundle) {
for (const chunk in bundle) {
if (bundle[chunk].name === "index") {
const inputs = [
{
data: bundle[chunk].code,
type: 'js',
action: 'eval',
},
];
const packer = new Packer(inputs, {
maxMemoryMB: 1024,
precision: 16,
modelMaxCount: 5,
modelRecipBaseCount: 20,
recipLearningRate: 1000,
numAbbreviations: 32,
});
await packer.optimize();
const { firstLine, secondLine } = packer.makeDecoder();
bundle[chunk].code = firstLine + secondLine;
}
}
}
}
}