-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestDeadCodeElimination.js
123 lines (116 loc) · 2.94 KB
/
testDeadCodeElimination.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var Terser = require('terser');
const code = `
(this['webpackJsonppoc-separate-env-injection'] =
this['webpackJsonppoc-separate-env-injection'] || []).push([
[0],
[
,
,
,
function(e, n, o) {
e.exports = o.p + 'static/media/logo.5d5d9eef.svg';
},
function(e, n, o) {
e.exports = o(11);
},
,
,
,
,
function(e, n, o) {},
function(e, n, o) {},
function(e, n, o) {
'use strict';
o.r(n);
var t = o(0),
a = o.n(t),
r = o(2),
c = o.n(r),
s = (o(9), o(3)),
l = o.n(s),
A = (o(10), 'I am param two');
console.log('SOMEPARAM outside', A);
var i = function() {
return (
console.log('production'),
console.log('SOMEPARAM inside', A),
console.log('I am param three'),
t.createElement(
'div',
{ className: 'App' },
t.createElement(
'header',
{ className: 'App-header' },
t.createElement('img', {
src: l.a,
className: 'App-logo',
alt: 'logo',
}),
t.createElement(
'p',
null,
'Edit ',
t.createElement('code', null, 'src/App.js'),
' and save to reload.'
),
t.createElement(
'a',
{
className: 'App-link',
href: 'https://reactjs.org',
target: '_blank',
rel: 'noopener noreferrer',
},
'Learn React'
)
),
'I AM PARAM THREE' === 'I am param three' &&
t.createElement('p', null, 'COnditional got rendered')
)
);
};
'localhost' !== window.location.hostname &&
'[::1]' !== window.location.hostname &&
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
);
c.a.render(
a.a.createElement(a.a.StrictMode, null, a.a.createElement(i, null)),
document.getElementById('root')
),
'serviceWorker' in navigator &&
navigator.serviceWorker.ready
.then(function(e) {
e.unregister();
})
.catch(function(e) {
console.error(e.message);
});
},
],
[[4, 1, 2]],
]);
//# sourceMappingURL=main.46f0c750.chunk.js.map
`;
// console.log(
// babel.transformSync(
// code,
// {
// plugins: [['minify-dead-code-elimination', {}]],
// },
// {
// filename: 'test.js',
// }
// )
// );
// const code2 = `
// export const SOMEPARAM = process.env.REACT_APP_PARAM_TWO;
// // "I AM PARAM TWO",
// `;
var result = Terser.minify(code, {
output: {
ast: false,
code: true, // optional - faster if false
},
});
console.log('result', result);