jscrambler-metro-plugin 6.0.1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +8 -0
- package/lib/utils.js +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
@@ -256,6 +256,8 @@ module.exports = function (_config = {}, projectRoot = process.cwd()) {
|
|
256
256
|
}
|
257
257
|
|
258
258
|
const bundlePath = getBundlePath();
|
259
|
+
// make sure jscrambler-metro-plugin is properly configure on metro bundler
|
260
|
+
let calledByMetro = false;
|
259
261
|
const fileNames = new Set();
|
260
262
|
const sourceMapFiles = [];
|
261
263
|
const config = Object.assign({}, jscrambler.config, _config);
|
@@ -272,6 +274,10 @@ module.exports = function (_config = {}, projectRoot = process.cwd()) {
|
|
272
274
|
|
273
275
|
process.on('beforeExit', async function (exitCode) {
|
274
276
|
try{
|
277
|
+
if (!calledByMetro) {
|
278
|
+
throw new Error('*jscrambler-metro-plugin* was not properly configured on metro.config.js file. Please verify our documentation in https://docs.jscrambler.com/code-integrity/frameworks-and-libraries/react-native/integration.');
|
279
|
+
}
|
280
|
+
|
275
281
|
console.log(
|
276
282
|
instrument
|
277
283
|
? 'info Jscrambler Instrumenting Code'
|
@@ -297,6 +303,8 @@ module.exports = function (_config = {}, projectRoot = process.cwd()) {
|
|
297
303
|
* @returns {boolean}
|
298
304
|
*/
|
299
305
|
processModuleFilter(_module) {
|
306
|
+
calledByMetro = true;
|
307
|
+
|
300
308
|
const modulePath = _module.path;
|
301
309
|
const shouldSkipModule = !validateModule(modulePath, config, projectRoot);
|
302
310
|
|
package/lib/utils.js
CHANGED
@@ -225,10 +225,10 @@ const isFileReadable = (path) => new Promise((resolve) => {
|
|
225
225
|
})
|
226
226
|
|
227
227
|
const addBundleArgsToExcludeList = (chunk, excludeList) => {
|
228
|
-
const regex = /\(([0-9a-zA-Z_
|
228
|
+
const regex = /\(([0-9a-zA-Z_,$ ]+)\)[ ]?{$/gm;
|
229
229
|
const m = regex.exec(chunk);
|
230
230
|
if (Array.isArray(m) && m.length > 1) {
|
231
|
-
for (const arg of m[1].split(",")) {
|
231
|
+
for (const arg of m[m.length - 1].split(",")) {
|
232
232
|
if (!excludeList.includes(arg)) {
|
233
233
|
excludeList.push(arg);
|
234
234
|
}
|