Skip to content

Commit

Permalink
Create exports.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa-silverback committed Sep 20, 2024
1 parent e8d6a41 commit 85cea13
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions scripts/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
async function main() {
let proc = Bun.spawn([
"bunx",
"attw",
"-f",
"table-flipped",
"--no-emoji",
"--no-color",
"--pack",
]);

let text = await new Response(proc.stdout).text();

let entrypointLines = text
.slice(text.indexOf('"remix-auth/'))
.split("\n")
.filter(Boolean)
.filter((line) => !line.includes("─"))
.map((line) =>
line
.replaceAll(/[^\d "()/A-Za-z│-]/g, "")
.replaceAll("90m│39m", "│")
.replaceAll(/^│/g, "")
.replaceAll(/│$/g, ""),
);

let pkg = await Bun.file("package.json").json();
let entrypoints = entrypointLines.map((entrypointLine) => {
let [entrypoint, ...resolutionColumns] = entrypointLine.split("│");
if (!entrypoint) throw new Error("Entrypoint not found");
if (!resolutionColumns[2]) throw new Error("ESM resolution not found");
if (!resolutionColumns[3]) throw new Error("Bundler resolution not found");
return {
entrypoint: entrypoint.replace(pkg.name, ".").trim(),
esm: resolutionColumns[2].trim(),
bundler: resolutionColumns[3].trim(),
};
});

let entrypointsWithProblems = entrypoints.filter(
(item) => item.esm.includes("fail") || item.bundler.includes("fail"),
);

if (entrypointsWithProblems.length > 0) {
console.error("Entrypoints with problems:");
process.exit(1);
}
}

await main().catch((error) => {
console.error(error);
process.exit(1);
});

export {};

0 comments on commit 85cea13

Please sign in to comment.