woodser / monero-ts

TypeScript library for using Monero
http://woodser.github.io/monero-ts/typedocs
MIT License
212 stars 71 forks source link

Support import syntax: `import moneroTs from "monero-ts"` #146

Closed woodser closed 9 months ago

woodser commented 1 year ago

Currently importing all types from monero-ts requires the syntax:

import * as moneroTs from "monero-ts";

This issue requests supporting the following syntax with equivalent functionality:

import moneroTs from "monero-ts";

hundehausen commented 1 year ago

In Next.js I had no problem using named imports import { MoneroWalletListener } from "monero-ts";

woodser commented 1 year ago

Individual named imports work without any problem, but for some reason, import moneroTs from "monero-ts"; doesn't work like other libraries, only import * as moneroTs from "monero-ts"; works to import everything.

dutu commented 1 year ago

you should add babel plugin "add-module-exports"

Update .babelrc:

  "plugins": [
    "@babel/plugin-transform-runtime",
    "add-module-exports"
  ],

and install the babel-plugin-add-module-exports package as a dev dependency:

npm install babel-plugin-add-module-exports --save-dev