Skip to content

Commit

Permalink
cli: hash indexers to allow special characters in name
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek committed Nov 27, 2024
1 parent 5169411 commit 413fd1e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"hookable": "^5.5.3",
"klona": "^2.0.6",
"magic-string": "^0.30.12",
"ohash": "^1.1.4",
"pathe": "^1.1.2",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.1.3",
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/rollup/plugins/indexers.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import virtual from "@rollup/plugin-virtual";
import type { Apibara } from "apibara/types";
import { hash } from "ohash";

export function indexers(apibara: Apibara) {
const indexers = [...new Set(apibara.indexers)];

return virtual({
"#apibara-internal-virtual/indexers": `
${indexers.map((i) => `import ${i.name} from '${i.indexer}';`).join("\n")}
${indexers.map((i) => `import _${hash(i)} from '${i.indexer}';`).join("\n")}
export const indexers = [
${indexers.map((i) => `{ name: "${i.name}", indexer: ${i.name} }`).join(",\n")}
${indexers.map((i) => `{ name: "${i.name}", indexer: _${hash(i)} }`).join(",\n")}
];
`,
});
Expand Down
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 413fd1e

Please sign in to comment.