Giter Site home page Giter Site logo

Add ESM support about borsh-js HOT 9 CLOSED

near avatar near commented on August 21, 2024 1
Add ESM support

from borsh-js.

Comments (9)

itegulov avatar itegulov commented on August 21, 2024 2

@cristobal if you do start working on this issue feel free to take a look at my attempt I made a couple of weeks ago: bf616b5. As you said, I had to get rid of bs58, but base-x itself did not have ESM support either so I tried to temporarily copy its content in place. The end result seemed to work fine with vite, so I am not sure if we actually need to do anything about bn.js and text-encoding-utf-8, but I could very well be wrong.

from borsh-js.

cristobal avatar cristobal commented on August 21, 2024 2

Ok will start working on this next week, if i manage to get some time free this weekend i will look into it but otherwise expect some PR's from next week 🙂 👍🏽

from borsh-js.

volovyks avatar volovyks commented on August 21, 2024 1

Thanks, @cristobal ! Let's move step by step.
We can merge breaking changes to a separate branch and then release them together with a new major version update.

from borsh-js.

cristobal avatar cristobal commented on August 21, 2024

Let's add ESM alongside CJS to this project. Can be a requirement for near/near-api-js#607 cc @itegulov

Why not remove dependency on text-encoding-utf-8 and make it an optional polyfill, since the module actually does not export an default which is the one used here

// TODO: Make sure this polyfill not included when not required
import * as encoding from "text-encoding-utf-8";

Leaving this part out or modifying the text-encoding-utf-8 to include a default export, works when building with Esbuild or Snowpack i commented this in #47.

from borsh-js.

cristobal avatar cristobal commented on August 21, 2024

Perhaps some contribution to both the bn.js and bs58 to have proper esm build and exports?

Not sure if bs58 should be an dependency, due to the few lines of code:

const basex = require('base-x')
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

module.exports = basex(ALPHABET)

perhaps rather just depend on base-x instead?

from borsh-js.

volovyks avatar volovyks commented on August 21, 2024

@cristobal looks reasonable! Do you think you can create a PR?

from borsh-js.

cristobal avatar cristobal commented on August 21, 2024

@cristobal looks reasonable! Do you think you can create a PR?

Sure could try do make some PR's, what do you prefer one big PR or several smaller changes?

  • Replacing bs58 by using base-x directly would not be that hard and could be a minor upgrade.
  • Removing text-encoding-utf-8 and specifying it as a polyfill where needed is a major upgrade since it would require those that need to support older browsers have to manually polyfill it.
  • I think bn.js may be a bit trickier related issue on ethers.js with esm build.

@volovyk-s Thoughts on the process?

from borsh-js.

volovyks avatar volovyks commented on August 21, 2024

@cristobal I have created develop-breaking branch for breaking changes. You can target it in your PR's.

from borsh-js.

ailisp avatar ailisp commented on August 21, 2024

Supported in 1.0!

from borsh-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.