jscrambler-metro-plugin 6.0.1 → 6.0.3

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 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_,]+)\){$/gm;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jscrambler-metro-plugin",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "A plugin to use metro with Jscrambler",
5
5
  "main": "lib/index.js",
6
6
  "peerDependencies": {