@contrast/rewriter 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +0 -20
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -18,14 +18,6 @@
|
|
|
18
18
|
const { transform, transformSync } = require('@swc/core');
|
|
19
19
|
const Module = require('node:module');
|
|
20
20
|
const { Cache } = require('./cache');
|
|
21
|
-
const INJECTION_FIXES = [
|
|
22
|
-
// assigning to global breaks things like `"string".constructor === global.String`
|
|
23
|
-
{ search: 'global.Function = global.ContrastMethods.Function', replace: 'var Function = global.ContrastMethods?.Function' },
|
|
24
|
-
{ search: 'global.Number = global.ContrastMethods.Number', replace: 'var Number = global.ContrastMethods?.Number' },
|
|
25
|
-
{ search: 'global.Object = global.ContrastMethods.Object', replace: 'var Object = global.ContrastMethods?.Object' },
|
|
26
|
-
{ search: 'global.String = global.ContrastMethods.String', replace: 'var String = global.ContrastMethods?.String' },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
21
|
|
|
30
22
|
/**
|
|
31
23
|
* @typedef {Object} Core
|
|
@@ -173,12 +165,6 @@ class Rewriter {
|
|
|
173
165
|
result = trim(content, result);
|
|
174
166
|
}
|
|
175
167
|
|
|
176
|
-
for (const { search, replace } of INJECTION_FIXES) {
|
|
177
|
-
if (result.code.indexOf(search) >= 0) {
|
|
178
|
-
result.code = result.code.replace(search, replace);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
168
|
return result;
|
|
183
169
|
}
|
|
184
170
|
|
|
@@ -202,12 +188,6 @@ class Rewriter {
|
|
|
202
188
|
result = trim(content, result);
|
|
203
189
|
}
|
|
204
190
|
|
|
205
|
-
for (const { search, replace } of INJECTION_FIXES) {
|
|
206
|
-
if (result.code.indexOf(search) >= 0) {
|
|
207
|
-
result.code = result.code.replace(search, replace);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
191
|
return result;
|
|
212
192
|
}
|
|
213
193
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/rewriter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "A transpilation tool mainly used for instrumentation",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"test": "../scripts/test.sh"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@contrast/agent-swc-plugin": "1.
|
|
18
|
-
"@contrast/agent-swc-plugin-unwrite": "1.
|
|
19
|
-
"@contrast/common": "1.
|
|
17
|
+
"@contrast/agent-swc-plugin": "1.5.0",
|
|
18
|
+
"@contrast/agent-swc-plugin-unwrite": "1.5.0",
|
|
19
|
+
"@contrast/common": "1.21.0",
|
|
20
20
|
"@contrast/synchronous-source-maps": "^1.1.3",
|
|
21
21
|
"@swc/core": "1.3.39",
|
|
22
22
|
"multi-stage-sourcemap": "^0.3.1"
|