* Check if the dist files contain browser-incompatible imports
(packageDir)
| 57 | * Check if the dist files contain browser-incompatible imports |
| 58 | */ |
| 59 | function checkDistForNodeProtocol(packageDir) { |
| 60 | const distDir = join(packageDir, 'dist'); |
| 61 | if (!existsSync(distDir)) { |
| 62 | return { ok: true, issues: [] }; |
| 63 | } |
| 64 | |
| 65 | const issues = []; |
| 66 | const jsFiles = findJsFiles(distDir); |
| 67 | |
| 68 | for (const filePath of jsFiles) { |
| 69 | const content = readFileSync(filePath, 'utf8'); |
| 70 | for (const pattern of BROWSER_INCOMPATIBLE_PATTERNS) { |
| 71 | if (pattern.test(content)) { |
| 72 | issues.push({ |
| 73 | file: filePath.replace(ROOT_DIR, ''), |
| 74 | pattern: pattern.toString(), |
| 75 | }); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return { ok: issues.length === 0, issues }; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Test that a package can be packed without errors |
no test coverage detected