project-serum / sol-wallet-adapter

Other
185 stars 93 forks source link

Built sol-wallet-adapter still includes import statements #38

Open ebramanti opened 3 years ago

ebramanti commented 3 years ago

When this package is built into a CommonJS file, it still contains ES6 imports. From the latest version (0.2.4), the following lines will cause runners such as Jest (which assume node_modules as built CommonJS) to break:

import EventEmitter from 'eventemitter3';
import { PublicKey } from '@solana/web3.js';
import bs58 from 'bs58';

In the meantime, a workaround for anyone experiencing this is to add the following to your Jest configuration:

    "transform": {
      "(@project-serum/sol-wallet-adapter).+\\.js$": "babel-jest"
    },
    "transformIgnorePatterns": [
      "/node_modules/(?!@project-serum/sol-wallet-adapter)"
    ]