You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Don't mangle in no-external builds
* Don't mangle at all for no-external
* Fix tests
* Add some extra caution to rollup
* Maybe we can do non-property mangling for noexternal builds
? true// Don't mangle properties in the es5 build, as it relies on helpers which don't work well with mangling.
83
-
: {
84
-
// Note:
85
-
// PROPERTY MANGLING CAN BREAK YOUR CODE
86
-
// But we use it anyway because it's incredible for bundle size, you just need to develop with it in mind.
87
-
// Any properties that start with _ will be mangled, which can be a problem if anything with that pattern is
88
-
// part of the public interface, or if any API responses we use matches that regex.
89
-
// Fix specific instances of this by adding the property to the reserved list.
90
-
properties: {
91
-
regex: /^_(?!_)/,// only mangle properties that start with a single _
92
-
reserved: [
93
-
// list any exceptions that shouldn't be mangled, and please add an explanation:
81
+
mangle:
82
+
// Don't mangle properties in no-external builds, as it is used in Browser extensions which have to go through a review process with e.g. Google, and they can be weird about obfuscated code.
83
+
// Don't mangle properties in the es5 build, as it relies on helpers which don't work well with mangling.
84
+
noExternal||es5
85
+
? true
86
+
: {
87
+
// Note:
88
+
// PROPERTY MANGLING CAN BREAK YOUR CODE
89
+
// But we use it anyway because it's incredible for bundle size, you just need to develop with it in mind.
90
+
// Any properties that start with _ will be mangled, which can be a problem if anything with that pattern is
91
+
// part of the public interface, or if any API responses we use matches that regex.
92
+
// Fix specific instances of this by adding the property to the reserved list.
93
+
properties: {
94
+
regex: /^_(?!_)/,// only mangle properties that start with a single _
95
+
reserved: [
96
+
// list any exceptions that shouldn't be mangled, and please add an explanation:
94
97
95
-
// referenced in snippet, MUST be preserved
96
-
'_i',
97
-
'__SV',
98
+
// referenced in snippet, MUST be preserved
99
+
'_i',
100
+
'__SV',
98
101
99
-
// used in decide request, MUST be preserved
100
-
'_',
102
+
// used in decide request, MUST be preserved
103
+
'_',
101
104
102
-
// used in config
103
-
'_url',
104
-
'_batchKey',
105
-
'_noTruncate',
106
-
'_onCapture',
105
+
// used in config
106
+
'_url',
107
+
'_batchKey',
108
+
'_noTruncate',
109
+
'_onCapture',
107
110
108
-
// used in surveys, however, this shouldn't be needed
109
-
// TODO: figure out how to remove them
110
-
'_posthog',
111
-
'_instance',
112
-
'_surveyEventReceiver',
111
+
// used in surveys, however, this shouldn't be needed
112
+
// TODO: figure out how to remove them
113
+
'_posthog',
114
+
'_instance',
115
+
'_surveyEventReceiver',
113
116
114
-
// part of setup/teardown code, preserve these out of caution
115
-
'_init',
116
-
'_dom_loaded',
117
-
'_execute_array',
118
-
'_handle_unload',
117
+
// part of setup/teardown code, preserve these out of caution
118
+
'_init',
119
+
'_dom_loaded',
120
+
'_execute_array',
121
+
'_handle_unload',
119
122
120
-
// playwright uses these
121
-
'_forceAllowLocalhostNetworkCapture',
122
-
'_is_bot',
123
-
'__ph_loaded',
124
-
'_sessionActivityTimestamp',
125
-
'_sessionStartTimestamp',
126
-
'_sessionTimeoutMs',
123
+
// playwright uses these
124
+
'_forceAllowLocalhostNetworkCapture',
125
+
'_is_bot',
126
+
'__ph_loaded',
127
+
'_sessionActivityTimestamp',
128
+
'_sessionStartTimestamp',
129
+
'_sessionTimeoutMs',
127
130
128
-
// set on global window object (the ones using __ are not mangled anyway BUT be abundantly cautious)
129
-
'_POSTHOG_REMOTE_CONFIG',
130
-
'__POSTHOG_INSTRUMENTED__',
131
-
'__PosthogExtensions__',
132
-
'__posthog_wrapped__',
133
-
'__Posthog__',
134
-
'_patchFetch',
135
-
'_patchXHR',
131
+
// set on global window object (the ones using __ are not mangled anyway BUT be abundantly cautious)
132
+
'_POSTHOG_REMOTE_CONFIG',
133
+
'__POSTHOG_INSTRUMENTED__',
134
+
'__PosthogExtensions__',
135
+
'__posthog_wrapped__',
136
+
'__Posthog__',
137
+
'_patchFetch',
138
+
'_patchXHR',
136
139
137
-
// part of the public API (none start with _ so are not mangled anyway BUT be abundantly cautious)
138
-
'capture',
139
-
'identify',
140
-
'alias',
141
-
'set',
142
-
'set_once',
143
-
'set_config',
144
-
'register',
145
-
'register_once',
146
-
'unregister',
147
-
'opt_out_capturing',
148
-
'has_opted_out_capturing',
149
-
'opt_in_capturing',
150
-
'reset',
151
-
'isFeatureEnabled',
152
-
'onFeatureFlags',
153
-
'getSurveys',
154
-
'getActiveMatchingSurveys',
155
-
'captureException',
156
-
'posthog',
157
-
'version',
158
-
'surveys',
159
-
'calculateEventProperties',
140
+
// set as part of lazy-loading (doesn't start with _ BUT be abundantly cautious)
141
+
'loadExternalDependency',
160
142
161
-
// possibly used by naughty users - we should decide if we want make these part of the public API, but be cautious for now
162
-
'_isIdentified',
163
-
'_is_bot',
164
-
'_calculate_event_properties',// deprecated in favour of calculateEventProperties
143
+
// part of the public API (none start with _ so are not mangled anyway BUT be abundantly cautious)
144
+
'capture',
145
+
'identify',
146
+
'alias',
147
+
'set',
148
+
'set_once',
149
+
'set_config',
150
+
'register',
151
+
'register_once',
152
+
'unregister',
153
+
'opt_out_capturing',
154
+
'has_opted_out_capturing',
155
+
'opt_in_capturing',
156
+
'reset',
157
+
'isFeatureEnabled',
158
+
'onFeatureFlags',
159
+
'getSurveys',
160
+
'getActiveMatchingSurveys',
161
+
'captureException',
162
+
'posthog',
163
+
'version',
164
+
'surveys',
165
+
'calculateEventProperties',
165
166
166
-
// URL parameters
167
-
'__posthog_debug',
167
+
// possibly used by naughty users - we should decide if we want make these part of the public API, but be cautious for now
168
+
'_isIdentified',
169
+
'_is_bot',
170
+
'_calculate_event_properties',// deprecated in favour of calculateEventProperties
168
171
169
-
// attribution params, not used in a way that would be mangled but be cautious
170
-
'_kx',
172
+
// URL parameters
173
+
'__posthog_debug',
171
174
172
-
// used in rrweb source
173
-
'_rrweb',
174
-
'_root',
175
-
'_css',
176
-
'_opts',
177
-
'_cssText',
178
-
'__context',
179
-
'_mappings',
180
-
'_processor',
181
-
'_args',
182
-
'__ln',
183
-
'_unchangedStyles',
184
-
'__rrweb_original__',
185
-
'_Departed',
186
-
'_onload',
187
-
'_onclick',
188
-
'_oncontextmenu',
189
-
'_ondblclick',
190
-
'_onmousedown',
191
-
'_onmouseenter',
192
-
'_onmouseleave',
193
-
'_onmousemove',
194
-
'_onmouseout',
195
-
'_onmouseover',
175
+
// attribution params, not used in a way that would be mangled but be cautious
176
+
'_kx',
196
177
197
-
// Helpers added by the e.g. es5 build. We don't use this, but they can be a starting point if we try to get the es5 build mangled in the future
198
-
'_invoke',
199
-
'__proto__',
200
-
'__await',
201
-
'_createClass',
202
-
'_classCallCheck',
203
-
'__esModule',
204
-
'__publicField2',
205
-
'__symbol__',
178
+
// used in rrweb source
179
+
'_rrweb',
180
+
'_root',
181
+
'_css',
182
+
'_opts',
183
+
'_cssText',
184
+
'__context',
185
+
'_mappings',
186
+
'_processor',
187
+
'_args',
188
+
'__ln',
189
+
'_unchangedStyles',
190
+
'__rrweb_original__',
191
+
'_Departed',
192
+
'_onload',
193
+
'_onclick',
194
+
'_oncontextmenu',
195
+
'_ondblclick',
196
+
'_onmousedown',
197
+
'_onmouseenter',
198
+
'_onmouseleave',
199
+
'_onmousemove',
200
+
'_onmouseout',
201
+
'_onmouseover',
206
202
207
-
// found in terser-mangled-names.json and couldn't attribute source, so preserve out of caution,
208
-
'_sb',
209
-
'_mirror',
210
-
'_map',
211
-
],
203
+
// Helpers added by the e.g. es5 build. We don't use this, but they can be a starting point if we try to get the es5 build mangled in the future
204
+
'_invoke',
205
+
'__proto__',
206
+
'__await',
207
+
'_createClass',
208
+
'_classCallCheck',
209
+
'__esModule',
210
+
'__publicField2',
211
+
'__symbol__',
212
+
213
+
// found in terser-mangled-names.json and couldn't attribute source, so preserve out of caution,
0 commit comments