|
| 1 | +async function main() { |
| 2 | + let proc = Bun.spawn([ |
| 3 | + "bunx", |
| 4 | + "attw", |
| 5 | + "-f", |
| 6 | + "table-flipped", |
| 7 | + "--no-emoji", |
| 8 | + "--no-color", |
| 9 | + "--pack", |
| 10 | + ]); |
| 11 | + |
| 12 | + let text = await new Response(proc.stdout).text(); |
| 13 | + |
| 14 | + let entrypointLines = text |
| 15 | + .slice(text.indexOf('"remix-i18next/')) |
| 16 | + .split("\n") |
| 17 | + .filter(Boolean) |
| 18 | + .filter((line) => !line.includes("─")) |
| 19 | + .map((line) => |
| 20 | + line |
| 21 | + .replaceAll(/[^\d "()/A-Za-z│-]/g, "") |
| 22 | + .replaceAll("90m│39m", "│") |
| 23 | + .replaceAll(/^│/g, "") |
| 24 | + .replaceAll(/│$/g, ""), |
| 25 | + ); |
| 26 | + |
| 27 | + let pkg = await Bun.file("package.json").json(); |
| 28 | + let entrypoints = entrypointLines.map((entrypointLine) => { |
| 29 | + let [entrypoint, ...resolutionColumns] = entrypointLine.split("│"); |
| 30 | + if (!entrypoint) throw new Error("Entrypoint not found"); |
| 31 | + if (!resolutionColumns[2]) throw new Error("ESM resolution not found"); |
| 32 | + if (!resolutionColumns[3]) throw new Error("Bundler resolution not found"); |
| 33 | + return { |
| 34 | + entrypoint: entrypoint.replace(pkg.name, ".").trim(), |
| 35 | + esm: resolutionColumns[2].trim(), |
| 36 | + bundler: resolutionColumns[3].trim(), |
| 37 | + }; |
| 38 | + }); |
| 39 | + |
| 40 | + let entrypointsWithProblems = entrypoints.filter( |
| 41 | + (item) => item.esm.includes("fail") || item.bundler.includes("fail"), |
| 42 | + ); |
| 43 | + |
| 44 | + if (entrypointsWithProblems.length > 0) { |
| 45 | + console.error("Entrypoints with problems:"); |
| 46 | + process.exit(1); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +await main().catch((error) => { |
| 51 | + console.error(error); |
| 52 | + process.exit(1); |
| 53 | +}); |
| 54 | + |
| 55 | +export {}; |
0 commit comments