Ver Fonte

fix(pyth-fuel-js): fixed build and typings

benduran há 3 semanas atrás
pai
commit
b693600a6d

+ 3 - 0
pnpm-lock.yaml

@@ -2855,6 +2855,9 @@ importers:
       eslint:
         specifier: ^8.14.0
         version: 8.56.0
+      fast-glob:
+        specifier: ^3.3.3
+        version: 3.3.3
       prettier:
         specifier: 'catalog:'
         version: 3.5.3

+ 58 - 3
target_chains/fuel/sdk/js/package.json

@@ -6,8 +6,8 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "main": "./dist/cjs/index.js",
+  "types": "./dist/cjs/index.d.ts",
   "files": [
     "dist/**/*"
   ],
@@ -44,6 +44,7 @@
     "@typescript-eslint/parser": "^7.7.0",
     "copyfiles": "^2.4.1",
     "eslint": "^8.14.0",
+    "fast-glob": "^3.3.3",
     "prettier": "catalog:",
     "ts-node": "catalog:"
   },
@@ -55,5 +56,59 @@
     "pnpm": ">=10.19.0"
   },
   "packageManager": "pnpm@10.19.0",
-  "type": "module"
+  "type": "module",
+  "exports": {
+    ".": {
+      "require": {
+        "default": "./dist/cjs/index.js",
+        "types": "./dist/cjs/index.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/index.js",
+        "types": "./dist/esm/index.d.ts"
+      }
+    },
+    "./types/PythContract": {
+      "require": {
+        "default": "./dist/cjs/types/PythContract.js",
+        "types": "./dist/cjs/types/PythContract.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/types/PythContract.js",
+        "types": "./dist/esm/types/PythContract.d.ts"
+      }
+    },
+    "./types/PythContractFactory": {
+      "require": {
+        "default": "./dist/cjs/types/PythContractFactory.js",
+        "types": "./dist/cjs/types/PythContractFactory.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/types/PythContractFactory.js",
+        "types": "./dist/esm/types/PythContractFactory.d.ts"
+      }
+    },
+    "./types/common": {
+      "require": {
+        "default": "./dist/cjs/types/common.js",
+        "types": "./dist/cjs/types/common.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/types/common.js",
+        "types": "./dist/esm/types/common.d.ts"
+      }
+    },
+    "./types": {
+      "require": {
+        "default": "./dist/cjs/types/index.js",
+        "types": "./dist/cjs/types/index.d.ts"
+      },
+      "import": {
+        "default": "./dist/esm/types/index.js",
+        "types": "./dist/esm/types/index.d.ts"
+      }
+    },
+    "./package.json": "./package.json"
+  },
+  "module": "./dist/esm/index.js"
 }

+ 3 - 3
target_chains/fuel/sdk/js/src/index.ts

@@ -1,4 +1,4 @@
-import PYTH_CONTRACT_ABI from "./abi/pyth-contract-abi.json";
+import PYTH_CONTRACT_ABI from "./abi/pyth-contract-abi.json" with { type: "json" };
 
 /** Address of the Pyth contract on Fuel Sepolia (testnet). */
 export const PYTH_CONTRACT_ADDRESS_SEPOLIA =
@@ -13,5 +13,5 @@ export const FUEL_ETH_ASSET_ID =
   "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07";
 
 export { PYTH_CONTRACT_ABI };
-export * from "./types";
-export type * from "./types/PythContract";
+export * from "./types/index.js";
+export type * from "./types/PythContract.js";

+ 4 - 2
target_chains/fuel/sdk/js/tsconfig.build.json

@@ -3,12 +3,14 @@
   "compilerOptions": {
     "noEmit": false,
     "incremental": false,
-    "declaration": true
+    "declaration": true,
+    "noUnusedLocals": false,
+    "isolatedModules": false
   },
   "exclude": [
     "node_modules",
     "dist",
-    "examples/",
+    "src/examples/",
     "**/__tests__/*"
   ]
 }

+ 4 - 0
target_chains/fuel/sdk/js/tsconfig.json

@@ -1,4 +1,8 @@
 {
   "extends": "@cprussin/tsconfig/base.json",
+  "compilerOptions": {
+    "moduleResolution": "bundler",
+    "module": "preserve"
+  },
   "exclude": ["dist", "node_modules"]
 }