Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Oct 19, 2023
1 parent f812c23 commit 6869c76
Show file tree
Hide file tree
Showing 11 changed files with 2,304 additions and 225 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -174,3 +174,6 @@ dist
# Finder (MacOS) folder config
.DS_Store

/dist

.wrangler
Binary file modified bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
@@ -1,16 +1,18 @@
{
"name": "ens-og-image",
"module": "index.ts",
"module": "src/index.tsx",
"type": "module",
"scripts": {
"clean": "rm -rf ./dist && mkdir dist",
"build": "bun ./scripts/build.ts",
"dev": "wrangler dev",
"publish": "wrangler publish",
"postinstall": "bunx patch-package"
},
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.3.0",
"@types/react": "^18.2.28",
"bun-types": "latest",
"esbuild": "^0.19.5",
"patch-package": "^8.0.0",
"wrangler": "^3.13.2"
},
Expand Down
28 changes: 28 additions & 0 deletions scripts/build.ts
@@ -0,0 +1,28 @@
import esbuild from "esbuild";
import { wasmPlugin } from "./wasm";

const built = await esbuild.build({
treeShaking: true,
bundle: true,
splitting: false,
minify: true,
entryPoints: ["./src/index.tsx"],
outdir: "dist",
target: "es2022",
format: "esm",
platform: "browser",
conditions: ["workerd", "worker", "browser"],
loader: {
".bin": "copy",
".wasm": "copy",
},
plugins: [wasmPlugin],
alias: {
"viem/*": "./node_modules/viem/_esm/*",
},
metafile: true,
});

Bun.write("./dist/meta.json", JSON.stringify(built.metafile, null, 2));

console.log("Build complete!");
20 changes: 20 additions & 0 deletions scripts/tsconfig.json
@@ -0,0 +1,20 @@
{
"include": ["./**/*"],
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": false,
"types": ["bun-types"]
}
}
13 changes: 13 additions & 0 deletions scripts/wasm.ts
@@ -0,0 +1,13 @@
import * as esbuild from "esbuild";
import path from "path";

export const wasmPlugin: esbuild.Plugin = {
name: "wasm",
setup(build) {
build.onResolve({ filter: /\.wasm\?module$/ }, async (args) => {
return {
path: path.join(args.resolveDir, args.path.split("?")[0]),
};
});
},
};
9 changes: 7 additions & 2 deletions src/gradient.ts
@@ -1,5 +1,10 @@
import { Hex, hexToBytes } from "viem";
import { namehash } from "viem/ens";
import type { Hex, hexToBytes as hexToBytesT } from "viem";
import type { namehash as namehashT } from "viem/ens";

const { hexToBytes } = require("viem/_esm/utils/encoding/toBytes") as {
hexToBytes: typeof hexToBytesT;
};
const { namehash } = require("viem/_esm/ens") as { namehash: typeof namehashT };

const emptyAddress = "0x0000000000000000000000000000000000000000";

Expand Down

0 comments on commit 6869c76

Please sign in to comment.