From b794c25a45a0bfb5f78d51823ab1ee154b4c456d Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 22 Apr 2026 13:24:24 +0700 Subject: [PATCH] refactor(loldle): import champions.json directly, drop ESM wrapper Node 24 + wrangler 4.x both accept `import ... with { type: "json" }`, so the generated champions-data.js wrapper is no longer needed. Drop scripts/build-loldle-data.js and the build:loldle-data npm script. Scraper writes champions.json only. --- .github/workflows/scrape-loldle-data.yml | 4 +- package.json | 3 +- scripts/build-loldle-data.js | 27 - scripts/scrape-loldle-data.js | 17 +- src/modules/loldle/README.md | 13 +- src/modules/loldle/champions-data.js | 1863 ---------------------- src/modules/loldle/handlers.js | 2 +- 7 files changed, 13 insertions(+), 1916 deletions(-) delete mode 100644 scripts/build-loldle-data.js delete mode 100644 src/modules/loldle/champions-data.js diff --git a/.github/workflows/scrape-loldle-data.yml b/.github/workflows/scrape-loldle-data.yml index 5b92d33..dfc21f9 100644 --- a/.github/workflows/scrape-loldle-data.yml +++ b/.github/workflows/scrape-loldle-data.yml @@ -47,6 +47,4 @@ jobs: `attackType`, `region`, `lane`, `releaseDate`). Review the diff, merge, then run `npm run deploy` to ship. - add-paths: | - src/modules/loldle/champions.json - src/modules/loldle/champions-data.js + add-paths: src/modules/loldle/champions.json diff --git a/package.json b/package.json index dc6155f..34e163d 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ }, "scripts": { "dev": "wrangler dev", - "build": "npm run build:loldle-data && npm run build:wordle-data", - "build:loldle-data": "node scripts/build-loldle-data.js", + "build": "npm run build:wordle-data", "build:wordle-data": "node scripts/build-wordle-data.js", "scrape:loldle-data": "node scripts/scrape-loldle-data.js", "deploy": "npm run build && wrangler deploy && npm run db:migrate && npm run register", diff --git a/scripts/build-loldle-data.js b/scripts/build-loldle-data.js deleted file mode 100644 index d3ba172..0000000 --- a/scripts/build-loldle-data.js +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env node -/** - * @file build-loldle-data — wraps src/modules/loldle/champions.json - * as an ES module export to sidestep Node/esbuild disagreement on - * JSON import attributes (Node 24 requires `with { type: "json" }`, - * wrangler's bundled esbuild doesn't parse it yet). - * - * Run after any update to champions.json. - */ - -import { readFileSync, writeFileSync } from "node:fs"; -import { resolve } from "node:path"; - -const root = resolve(import.meta.dirname, ".."); -const src = resolve(root, "src/modules/loldle/champions.json"); -const dst = resolve(root, "src/modules/loldle/champions-data.js"); - -const json = readFileSync(src, "utf8").trimEnd(); -const out = [ - "// Auto-generated from champions.json — do NOT edit by hand.", - "// Regenerate with: node scripts/build-loldle-data.js", - `export default ${json};`, - "", -].join("\n"); - -writeFileSync(dst, out); -console.log(`wrote ${dst}`); diff --git a/scripts/scrape-loldle-data.js b/scripts/scrape-loldle-data.js index f295a88..8240fc1 100644 --- a/scripts/scrape-loldle-data.js +++ b/scripts/scrape-loldle-data.js @@ -8,8 +8,8 @@ * at `