Bläddra i källkod

Use type commonjs and bump

Loris Leiva 1 år sedan
förälder
incheckning
59f48852d9

+ 11 - 15
clients/js/package.json

@@ -1,22 +1,18 @@
 {
   "name": "@solana-program/token",
-  "version": "0.1.2",
+  "version": "0.1.3",
   "description": "JavaScript client for the Token program",
   "sideEffects": false,
-  "module": "./dist/src/index.js",
-  "main": "./dist/src/index.cjs",
-  "types": "./dist/types/src/index.d.ts",
-  "type": "module",
+  "module": "./dist/src/index.mjs",
+  "main": "./dist/src/index.js",
+  "types": "./dist/types/index.d.ts",
+  "type": "commonjs",
   "exports": {
-    "browser": {
-      "import": "./dist/src/index.js",
-      "require": "./dist/src/index.cjs"
-    },
-    "node": {
-      "import": "./dist/src/index.js",
-      "require": "./dist/src/index.cjs"
-    },
-    "types": "./dist/types/src/index.d.ts"
+    ".": {
+      "types": "./dist/types/index.d.ts",
+      "import": "./dist/src/index.mjs",
+      "require": "./dist/src/index.js"
+    }
   },
   "files": [
     "./dist/src",
@@ -42,10 +38,10 @@
   },
   "devDependencies": {
     "@ava/typescript": "^4.1.0",
+    "@solana-program/system": "^0.3.1",
     "@solana/eslint-config-solana": "^3.0.0",
     "@solana/web3.js": "tp3",
     "@solana/webcrypto-ed25519-polyfill": "tp3",
-    "@solana-program/system": "^0.3.1",
     "@typescript-eslint/eslint-plugin": "^7.3.1",
     "@typescript-eslint/parser": "^7.3.1",
     "ava": "^6.1.2",

+ 1 - 1
clients/js/test/_setup.ts

@@ -30,7 +30,7 @@ import {
   getMintSize,
   getMintToInstruction,
   getTokenSize,
-} from '../src/index.js';
+} from '../src';
 
 type Client = {
   rpc: Rpc<SolanaRpcApi>;

+ 2 - 2
clients/js/test/initializeAccount.test.ts

@@ -14,14 +14,14 @@ import {
   fetchToken,
   getInitializeAccountInstruction,
   getTokenSize,
-} from '../src/index.js';
+} from '../src';
 import {
   createDefaultSolanaClient,
   createDefaultTransaction,
   createMint,
   generateKeyPairSignerWithSol,
   signAndSendTransaction,
-} from './_setup.js';
+} from './_setup';
 
 test('it creates and initializes a new token account', async (t) => {
   // Given a mint account, its mint authority and two generated keypairs

+ 2 - 2
clients/js/test/initializeMint.test.ts

@@ -14,13 +14,13 @@ import {
   fetchMint,
   getInitializeMintInstruction,
   getMintSize,
-} from '../src/index.js';
+} from '../src';
 import {
   createDefaultSolanaClient,
   createDefaultTransaction,
   generateKeyPairSignerWithSol,
   signAndSendTransaction,
-} from './_setup.js';
+} from './_setup';
 
 test('it creates and initializes a new mint account', async (t) => {
   // Given an authority and a mint account.

+ 2 - 2
clients/js/test/mintTo.test.ts

@@ -10,7 +10,7 @@ import {
   fetchMint,
   fetchToken,
   getMintToInstruction,
-} from '../src/index.js';
+} from '../src';
 import {
   createDefaultSolanaClient,
   createDefaultTransaction,
@@ -18,7 +18,7 @@ import {
   createToken,
   generateKeyPairSignerWithSol,
   signAndSendTransaction,
-} from './_setup.js';
+} from './_setup';
 
 test('it mints tokens to a token account', async (t) => {
   // Given a mint account and a token account.

+ 2 - 2
clients/js/test/transfer.test.ts

@@ -10,7 +10,7 @@ import {
   fetchMint,
   fetchToken,
   getTransferInstruction,
-} from '../src/index.js';
+} from '../src';
 import {
   createDefaultSolanaClient,
   createDefaultTransaction,
@@ -19,7 +19,7 @@ import {
   createTokenWithAmount,
   generateKeyPairSignerWithSol,
   signAndSendTransaction,
-} from './_setup.js';
+} from './_setup';
 
 test('it transfers tokens from one account to another', async (t) => {
   // Given a mint account and two token accounts.

+ 2 - 1
clients/js/tsconfig.declarations.json

@@ -5,5 +5,6 @@
     "emitDeclarationOnly": true,
     "outDir": "./dist/types"
   },
-  "extends": "./tsconfig.json"
+  "extends": "./tsconfig.json",
+  "include": ["src"]
 }

+ 2 - 2
clients/js/tsup.config.ts

@@ -7,7 +7,7 @@ const SHARED_OPTIONS: Options = {
   entry: ['./src/index.ts'],
   inject: [path.resolve(__dirname, 'env-shim.ts')],
   outDir: './dist/src',
-  outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.js' }),
+  outExtension: ({ format }) => ({ js: format === 'cjs' ? '.js' : '.mjs' }),
   sourcemap: true,
   treeshake: true,
 };
@@ -22,7 +22,7 @@ export default defineConfig(() => [
     ...SHARED_OPTIONS,
     bundle: false,
     entry: ['./test/*.ts'],
-    format: 'esm',
+    format: 'cjs',
     outDir: './dist/test',
   },
 ]);