shared: route ref-script server helpers via tx/server (keep buyer bundle clean)

Static re-exports from tx/index.ts caused vite to trace
loadEscrowScript/loadAdvertScript/buildLiveTxForPublishReferenceScripts
into the buyer UI bundle, hitting the CML WASM "ESM integration proposal"
limitation. Sibling builders avoid this with /* @vite-ignore */ dynamic
imports; we keep symmetry by parking the helpers on a separate
@marketplace/shared/tx/server entry that the buyer never imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
david
2026-05-14 15:41:29 +02:00
parent 5cae0c4f6c
commit 57e77e0e25
4 changed files with 27 additions and 11 deletions

View File

@@ -10,7 +10,8 @@
"./chain": "./src/chain/index.ts",
"./cbor": "./src/cbor/index.ts",
"./receipt": "./src/receipt/index.ts",
"./tx": "./src/tx/index.ts"
"./tx": "./src/tx/index.ts",
"./tx/server": "./src/tx/server.ts"
},
"scripts": {
"typecheck": "tsc --noEmit"

View File

@@ -10,14 +10,11 @@ export type { Signer } from "./signer.js";
export { MockSigner } from "./signer.js";
export type { Blueprint } from "./blueprint.js";
export { loadBlueprint } from "./blueprint.js";
// Script-bytes loaders (used by the publish-reference-scripts CLI).
export { loadEscrowScript, loadAdvertScript } from "./internal/liveCbor.js";
export { pkhToEnterpriseAddress } from "./internal/pkhAddress.js";
export type {
LivePublishRefScriptsParams,
PublishRefScriptsBuildResult,
} from "./internal/publishReferenceScripts.js";
export { buildLiveTxForPublishReferenceScripts } from "./internal/publishReferenceScripts.js";
// Note: live-CBOR helpers (loadEscrowScript, loadAdvertScript,
// buildLiveTxForPublishReferenceScripts, pkhToEnterpriseAddress) live in
// "./server.js" — kept OUT of this index so the buyer's vite bundle
// doesn't trace into lucid-evolution / CML WASM (sibling builders use
// /* @vite-ignore */ dynamic imports for the same reason).
// Advert builders
export type { PostAdvertParams } from "./advert/postAdvert.js";

View File

@@ -0,0 +1,18 @@
/**
* tx/server.ts — server-only re-exports.
*
* These bind the lucid-evolution + CML WASM dep graph at import time, so
* they MUST NOT be imported from anything that gets bundled by Vite (i.e.
* the buyer UI). The buyer SDK uses /* @vite-ignore *\/ dynamic imports
* to reach the live-CBOR builders for the same reason.
*
* Consumers: supplier CLIs and Node-only tx tooling.
*/
export { loadEscrowScript, loadAdvertScript } from "./internal/liveCbor.js";
export { pkhToEnterpriseAddress } from "./internal/pkhAddress.js";
export type {
LivePublishRefScriptsParams,
PublishRefScriptsBuildResult,
} from "./internal/publishReferenceScripts.js";
export { buildLiveTxForPublishReferenceScripts } from "./internal/publishReferenceScripts.js";