From 7e8f23a9bbfe67a874f3e72fce738ce6afda4c9b Mon Sep 17 00:00:00 2001 From: nhenin Date: Wed, 16 Aug 2023 13:26:37 +0200 Subject: [PATCH] replaced @emurgo/cardano-serialization-lib asmjs version with the browser one --- .gitignore | 3 ++- package.json | 6 +++-- packages/legacy-runtime/package.json | 2 +- packages/legacy-runtime/src/common/address.ts | 2 +- .../src/common/tx/collateral.ts | 2 +- .../legacy-runtime/src/wallet/cip30/index.ts | 2 +- rollup/legacy-runtime-esm.config.mjs | 26 ++++++++++++------- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 28648fac..27477514 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,8 @@ tsconfig.tsbuildinfo !.yarn/releases !.yarn/sdks !.yarn/versions - +# created by the rollup +stats.html # created by nix result source diff --git a/package.json b/package.json index 83c70aa3..10be3192 100644 --- a/package.json +++ b/package.json @@ -29,25 +29,27 @@ "devDependencies": { "@blockfrost/blockfrost-js": "5.2.0", "@blockfrost/openapi": "0.1.54", - "lucid-cardano": "0.9.4", - "dotenv": "^16.0.3", "@relmify/jest-fp-ts": "^2.0.2", "@rollup/plugin-commonjs": "^25.0.3", "@rollup/plugin-node-resolve": "^15.1.0", + "@rollup/plugin-wasm": "^6.1.3", "@types/axios-curlirize": "^1.3.2", "@types/deep-equal": "1.0.1", "@types/jest": "^26.0.24", "@types/json-bigint": "^1.0.1", "@types/node": "^18.14.2", + "dotenv": "^16.0.3", "eslint": "^7.32.0", "http-server": "^14.1.1", "jest": "^29.4", "jest-serial-runner": "^1.2.1", + "lucid-cardano": "0.9.4", "npm-run-all": "^4.1.5", "prettier": "^2.3.2", "rollup": "^3.27.2", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-output-size": "^1.2.2", + "rollup-plugin-visualizer": "^5.9.2", "shx": "^0.3.3", "ts-jest": "^29.0.5", "ts-node": "^10.9.1", diff --git a/packages/legacy-runtime/package.json b/packages/legacy-runtime/package.json index 18508af9..3f2930ec 100644 --- a/packages/legacy-runtime/package.json +++ b/packages/legacy-runtime/package.json @@ -39,6 +39,6 @@ "@47ng/codec":"1.1.0", "json-bigint": "^1.0.0", "jsonbigint-io-ts-reporters":"2.0.1", - "@emurgo/cardano-serialization-lib-asmjs":"11.4.0" + "@emurgo/cardano-serialization-lib-browser":"11.4.0" } } diff --git a/packages/legacy-runtime/src/common/address.ts b/packages/legacy-runtime/src/common/address.ts index 041a68de..60a8ebf7 100644 --- a/packages/legacy-runtime/src/common/address.ts +++ b/packages/legacy-runtime/src/common/address.ts @@ -3,7 +3,7 @@ import { iso, Newtype } from "newtype-ts"; import { fromNewtype } from "io-ts-types"; import { pipe } from "fp-ts/lib/function.js"; -import * as CSL from '@emurgo/cardano-serialization-lib-asmjs' +import * as CSL from '@emurgo/cardano-serialization-lib-browser' import { hex } from '@47ng/codec' export type AddressBech32 = Newtype<{ readonly AddressBech32: unique symbol }, string> diff --git a/packages/legacy-runtime/src/common/tx/collateral.ts b/packages/legacy-runtime/src/common/tx/collateral.ts index b8839619..0a839519 100644 --- a/packages/legacy-runtime/src/common/tx/collateral.ts +++ b/packages/legacy-runtime/src/common/tx/collateral.ts @@ -1,5 +1,5 @@ import { pipe } from "fp-ts/lib/function.js"; -import * as CSL from '@emurgo/cardano-serialization-lib-asmjs' +import * as CSL from '@emurgo/cardano-serialization-lib-browser' import { TxOutRef, txOutRef } from "./outRef.js"; import { hex } from '@47ng/codec' diff --git a/packages/legacy-runtime/src/wallet/cip30/index.ts b/packages/legacy-runtime/src/wallet/cip30/index.ts index 7714a958..b0cc1efa 100644 --- a/packages/legacy-runtime/src/wallet/cip30/index.ts +++ b/packages/legacy-runtime/src/wallet/cip30/index.ts @@ -11,7 +11,7 @@ import { deserializeCollateral } from '../../common/tx/collateral.js'; import { token } from '@marlowe/language-core-v1/token'; -import * as CSL from '@emurgo/cardano-serialization-lib-asmjs' +import * as CSL from '@emurgo/cardano-serialization-lib-browser' import { TokenValue, lovelaceValue, tokenValue } from '@marlowe/language-core-v1/tokenValue'; import { hex, utf8 } from '@47ng/codec' diff --git a/rollup/legacy-runtime-esm.config.mjs b/rollup/legacy-runtime-esm.config.mjs index 4ebf46b1..a8f77b81 100644 --- a/rollup/legacy-runtime-esm.config.mjs +++ b/rollup/legacy-runtime-esm.config.mjs @@ -2,27 +2,33 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import copy from 'rollup-plugin-copy' import commonjs from '@rollup/plugin-commonjs'; import outputSize from 'rollup-plugin-output-size'; +import { visualizer } from "rollup-plugin-visualizer"; const outputDir = 'dist/legacy-runtime/esm'; -const nodePlugin = nodeResolve({browser: true}); +const nodePlugin = nodeResolve( + { browser: true + , resolveOnly: module => !module.includes('@emurgo/cardano-serialization-lib-browser') + }); // const wasmPlugin = wasm({targetEnv: 'browser', sync: ['**/*.wasm']}); -// const copyWasm = copy({ -// targets: [ -// { src: 'node_modules/lucid-cardano/esm/src/core/wasm_modules/cardano_multiplatform_lib_web/*.wasm', dest: `${outputDir}/wasm_modules/cardano_multiplatform_lib_web/` }, -// { src: 'node_modules/lucid-cardano/esm/src/core/wasm_modules/cardano_message_signing_web/*.wasm', dest: `${outputDir}/wasm_modules/cardano_message_signing_web/` }, -// ] -// }); +const copyWasm = copy({ + targets: [ + { src: 'node_modules/@emurgo/cardano-serialization-lib-browser/*.wasm', dest: `${outputDir}/` } + ] +}); export default { + // input: 'packages/language/core/v1/dist/semantics/contract/index.js', + // input: 'packages/legacy-adapter/dist/index.js', input: 'packages/legacy-runtime/dist/index.js', output: { dir: outputDir, format: 'esm', }, plugins: - [ nodePlugin + [ copyWasm + , nodePlugin , commonjs() - // , copyWasm - , outputSize()], + , outputSize() + , visualizer()], } \ No newline at end of file