Skip to content

Commit 8459324

Browse files
committed
Add export verification script and update CI workflow
1 parent dc10f21 commit 8459324

File tree

3 files changed

+65
-9
lines changed

3 files changed

+65
-9
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
- run: bun install --frozen-lockfile
4040
- run: bun test
4141

42-
# exports:
43-
# name: Verify Exports
44-
# runs-on: ubuntu-latest
45-
# steps:
46-
# - uses: actions/checkout@v4
47-
# - uses: oven-sh/setup-bun@v2
48-
# - run: bun install --frozen-lockfile
49-
# - run: bun run exports
42+
exports:
43+
name: Verify Exports
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: oven-sh/setup-bun@v2
48+
- run: bun install --frozen-lockfile
49+
- run: bun run exports

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"build": "tsc --project tsconfig.json --outDir ./build",
6666
"typecheck": "tsc --project tsconfig.json --noEmit",
6767
"lint": "eslint --ext .ts,.tsx src/ test/",
68-
"test": "vitest"
68+
"test": "vitest",
69+
"exports": "bun run ./scripts/exports.ts"
6970
},
7071
"dependencies": {
7172
"react-router": "^7.0.1",

scripts/exports.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)