Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

build(sdk): build only the CommonJS interop layer instead of the whole package

nirholas9c7ea387c337
diff --git a/package.json b/package.json
index b6005987c..c6507a1b2 100644
--- a/package.json
+++ b/package.json
@@ -311,6 +311,7 @@
"check:claude": "node scripts/check-claude-md.mjs",
"verify:erc8004-validation": "node scripts/erc8004/verify-validation-registry.mjs",
"check:rules": "node scripts/check-rules.mjs",
+ "check:secrets": "node scripts/check-secrets.mjs",
"check:gcloudignore": "node scripts/check-gcloudignore.mjs",
"check:evm-rpc": "node --env-file=.env scripts/probe-evm-rpc.mjs --chain 1 --ens",
"awal:pin": "node scripts/update-awal-version.mjs",
diff --git a/scripts/publish-npm-queue.mjs b/scripts/publish-npm-queue.mjs
index 24556496c..e131456d4 100644
--- a/scripts/publish-npm-queue.mjs
+++ b/scripts/publish-npm-queue.mjs
@@ -84,7 +84,7 @@ const QUEUE = [
"packages/audio-mcp", // @three-ws/audio-mcp 0.1.2 (312 dl/mo)
"packages/clash-mcp", // @three-ws/clash-mcp 0.1.2 (305 dl/mo)
"packages/provenance-mcp", // @three-ws/provenance-mcp 0.1.2 (297 dl/mo)
- "x402-modal-sdk", // @three-ws/x402-modal 0.2.2 (283 dl/mo)
+ "x402-modal-sdk", // @three-ws/x402-modal 0.3.0 (283 dl/mo)
"solana-agent-sdk", // @three-ws/solana-agent 0.2.2 (275 dl/mo)
"sdk", // @three-ws/sdk 0.2.2 (244 dl/mo)
"packages/react", // @three-ws/react 1.0.2 (228 dl/mo)
diff --git a/sdk/.npmignore b/sdk/.npmignore
deleted file mode 100644
index 00dcd9408..000000000
--- a/sdk/.npmignore
+++ /dev/null
@@ -1,5 +0,0 @@
-src/
-test/
-example/
-build.mjs
-*.test.js
diff --git a/sdk/build.mjs b/sdk/build.mjs
index be63096cc..321112bfd 100644
--- a/sdk/build.mjs
+++ b/sdk/build.mjs
@@ -1,61 +1,52 @@
/**
* Build script for @three-ws/sdk
*
- * Uses esbuild (available in the root node_modules) to produce:
- * dist/index.js — CommonJS bundle
- * dist/index.mjs — ESM bundle
+ * The package ships its ESM source as-is (package.json `exports` resolve the
+ * `import` condition straight to src/), so the only thing that has to be built
+ * is the CommonJS interop layer for consumers that `require()` the package.
*
- * Then copies type declarations into dist/.
+ * Uses esbuild (available in the root node_modules) to bundle every public
+ * entry point to a `.cjs` file under dist/. The `.cjs` extension is
+ * load-bearing: this package is `"type": "module"`, so a CJS bundle named
+ * `.js` is parsed as ESM by Node and resolves to zero exports.
*
* Run: node build.mjs (from sdk/ directory)
*/
import { build } from '../node_modules/esbuild/lib/main.js';
-import { copyFileSync, mkdirSync, readdirSync, statSync } from 'node:fs';
+import { mkdirSync, rmSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
-
-const entryPoint = join(__dirname, 'src/index.js');
const outDir = join(__dirname, 'dist');
-mkdirSync(outDir, { recursive: true });
-
-const shared = {
- entryPoints: [entryPoint],
- bundle: true,
- // Mark all peer deps and ethers as external — consumers install them.
- external: ['ethers', '@solana/web3.js'],
- sourcemap: false,
- logLevel: 'info',
-};
-
-// ESM build
-await build({
- ...shared,
- format: 'esm',
- outfile: join(outDir, 'index.mjs'),
-});
-
-// CJS build
-await build({
- ...shared,
- format: 'cjs',
- outfile: join(outDir, 'index.js'),
-});
-
-// Copy type declarations
-copyFileSync(join(__dirname, 'src/index.d.ts'), join(outDir, 'index.d.ts'));
-
-// permissions sub-entry
+// Every entry point declared in package.json `exports` that has JS behind it.
+// Keep this list in sync with the `require` conditions in package.json.
+const ENTRIES = [
+ { src: 'src/index.js', out: 'index.cjs' },
+ { src: 'src/permissions.js', out: 'permissions.cjs' },
+ { src: 'src/permissions/advanced.js', out: 'permissions/advanced.cjs' },
+ { src: 'src/solana.js', out: 'solana.cjs' },
+ { src: 'src/solana-attestations.js', out: 'solana-attestations.cjs' },
+];
+
+rmSync(outDir, { recursive: true, force: true });
mkdirSync(join(outDir, 'permissions'), { recursive: true });
-copyFileSync(join(__dirname, 'src/permissions.d.ts'), join(outDir, 'permissions.d.ts'));
-
-// permissions/advanced sub-entry
-copyFileSync(join(__dirname, 'src/permissions/advanced.d.ts'), join(outDir, 'permissions/advanced.d.ts'));
-
-// Copy styles
-copyFileSync(join(__dirname, 'src/styles.css'), join(outDir, 'styles.css'));
-console.log('Build complete — dist/');
+for (const entry of ENTRIES) {
+ await build({
+ entryPoints: [join(__dirname, entry.src)],
+ outfile: join(outDir, entry.out),
+ bundle: true,
+ format: 'cjs',
+ platform: 'node',
+ target: 'node18',
+ // Peer deps stay external: consumers install them.
+ external: ['ethers', '@solana/web3.js', 'viem'],
+ sourcemap: false,
+ logLevel: 'info',
+ });
+}
+
+console.log(`Build complete: ${ENTRIES.length} CommonJS entry points in dist/`);
diff --git a/sdk/package.json b/sdk/package.json
index 132145378..263cfe19e 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -10,33 +10,39 @@
".": {
"types": "./types/index.d.ts",
"import": "./src/index.js",
+ "require": "./dist/index.cjs",
"default": "./src/index.js"
},
"./permissions": {
"types": "./types/permissions.d.ts",
"import": "./src/permissions.js",
+ "require": "./dist/permissions.cjs",
"default": "./src/permissions.js"
},
"./permissions/advanced": {
"types": "./src/permissions/advanced.d.ts",
"import": "./src/permissions/advanced.js",
+ "require": "./dist/permissions/advanced.cjs",
"default": "./src/permissions/advanced.js"
},
"./styles": "./src/styles.css",
"./solana": {
"types": "./types/solana.d.ts",
"import": "./src/solana.js",
+ "require": "./dist/solana.cjs",
"default": "./src/solana.js"
},
"./solana-attestations": {
"types": "./types/solana-attestations.d.ts",
"import": "./src/solana-attestations.js",
+ "require": "./dist/solana-attestations.cjs",
"default": "./src/solana-attestations.js"
}
},
"files": [
"src",
"types",
+ "dist",
"README.md",
"LICENSE",
"CHANGELOG.md"
@@ -67,7 +73,8 @@
"license": "SEE LICENSE IN LICENSE",
"peerDependencies": {
"ethers": "^6.0.0",
- "@solana/web3.js": "^1.0.0"
+ "@solana/web3.js": "^1.0.0",
+ "viem": "^2.0.0"
},
"peerDependenciesMeta": {
"ethers": {
@@ -75,8 +82,14 @@
},
"@solana/web3.js": {
"optional": true
+ },
+ "viem": {
+ "optional": true
}
},
+ "devDependencies": {
+ "jsdom": "^27.3.0"
+ },
"author": "three.ws <[email protected]> (https://three.ws)",
"homepage": "https://three.ws/",
"repository": {