UNPKG

1.35 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/utils/test-require-error.js"],"names":["moduleName","err","code","pnpCode","regex","RegExp","replace","firstLine","toString","split","test"],"mappings":";;;;;AAAA;AACA;eACe,CAACA,UAAD,EAAaC,GAAb,KAAqB;AAClC;AACA;AACA,MACEA,GAAG,CAACC,IAAJ,KAAc,kCAAd,IACAD,GAAG,CAACE,OAAJ,KAAiB,kCAFnB,EAGE;AACA,WAAO,IAAP;AACD;;AAED,QAAMC,KAAK,GAAG,IAAIC,MAAJ,CACX,+CAA8CL,UAAU,CAACM,OAAX,CAC7C,uBAD6C,EAE5C,MAF4C,CAG7C,EAJU,CAAd;AAMA,QAAMC,SAAS,GAAGN,GAAG,CAACO,QAAJ,GAAeC,KAAf,CAAsB,IAAtB,EAA2B,CAA3B,CAAlB;AACA,SAAOL,KAAK,CAACM,IAAN,CAAWH,SAAX,CAAP;AACD,C","sourcesContent":["// This module is also copied into the .cache directory some modules copied there\n// from cache-dir can also use this module.\nexport default (moduleName, err) => {\n // PnP will return the following code when a require is allowed per the\n // dependency tree rules but the requested file doesn't exist\n if (\n err.code === `QUALIFIED_PATH_RESOLUTION_FAILED` ||\n err.pnpCode === `QUALIFIED_PATH_RESOLUTION_FAILED`\n ) {\n return true\n }\n\n const regex = new RegExp(\n `Error:\\\\s(\\\\S+\\\\s)?[Cc]annot find module\\\\s.${moduleName.replace(\n /[-/\\\\^$*+?.()|[\\]{}]/g,\n `\\\\$&`\n )}`\n )\n const firstLine = err.toString().split(`\\n`)[0]\n return regex.test(firstLine)\n}\n"],"file":"test-require-error.js"}
\No newline at end of file