iotaledger / iota-sdk

The IOTA SDK provides developers with a seamless experience to develop on IOTA by providing account abstractions and clients to interact with node APIs.
Apache License 2.0
57 stars 41 forks source link

[Bug]: WASM Bindings don't work with ESM project structure #2218

Open coodos opened 5 months ago

coodos commented 5 months ago

Issue description

WASM bindings do not work with ESM

Version

v0.1.3

Expected behaviour

bindings work

Actual behaviour

since in package.json just files are exported in an ESM project you can't consume from directories like node and web

Can the issue reliably be reproduced?

Yes

Steps to reproduce the issue

  1. create esm project
  2. try to import from /node or /web

Errors

ModuleNotFound

Duplicate declaration

coodos commented 5 months ago

can be fixed pretty simply with adding explicit exports in package.json

 "exports": {
        "./node": {
            "require": "./node/lib/index.js",
            "import": {
                "types": "./node/lib/index.d.js",
                "default": "./node/lib/index.js"
            },
            "default": "./node/lib/index.js"
        }
    }
Thoralf-M commented 5 months ago

@coodos your example is missing the web export which results in Missing "./web" specifier in "@iota/sdk-wasm" package for packages that want to use it

For me I can use import { Client } from '@iota/sdk-wasm/node/lib/index.js'; in an ESM project