Skip to content

hash.js import issue with ESM: “does not provide an export named 'sha256'” #99

@bilou42

Description

@bilou42

Currently WharfKit packages (for example @wharfkit/session) assume a Node or bundler environment such as Vite or Webpack. When attempting to load them directly in the browser as ESM modules via a CDN like jsDelivr, the imports fail due to internal CommonJS dependencies such as hash.js.

Example:
import SessionKit from 'https://cdn.jsdelivr.net/npm/@wharfkit/[email protected]/+esm'

Error shown in console:
Uncaught SyntaxError: The requested module '/npm/[email protected]/+esm' does not provide an export named 'sha256'

This happens because hash.js is CommonJS-only, but WharfKit’s generated ESM build expects named exports from it.

For lightweight dApps or static sites, it would be very useful to load WharfKit modules directly from a CDN without needing a bundler or build step — similar to how Anchor-Link supported pure browser ESM usage.

I understand WharfKit is designed for modern JS app environments, but adding browser-compatible builds would make it much easier to integrate with small web projects or simple dApp frontends that don’t use build tooling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions