Prerequisites
Description
I believe there's a solid opportunity to make a handful of changes such that near-api-js can compile down to many (any) JavaScript build target.
There are some usages of Buffer for instance, which works great in NodeJS code or Node REPL, but are not compatible with CommonJS, which is "the OG JavaScript" that many people desire to use for various reasons.
Buffer can actually be replaced by Uint8Array which has the green flag of "baseline widely available" which is great.
There are a couple dependencies in near-api-js that can be removed because of another Web API Crypto. For instance, we can securely generate random bytes using Crypto.getRandomValues
Another example of a healthy replacement is the TextDecoder API, which can be utilized. These are built into the sort of foundational layer of JavaScript, which isn't always advertised but quite powerful.
The effect of making these changes means people will be able to use near-api-js in systems that don't require an npm/pnpm command or app.
Reproducible demo
No response
Steps to reproduce
This isn't a bug but instead "help us improve" part of that selection. The steps to reproduce are running the existing scripts in package.json
Expected behavior
The JavaScript library is able to be used by developers who may not be using NodeJS or wish to use EcmaScript for their project. I see that the near-connect repository is one of those that wishes to do this and has accomplished it for quick load and execution without dependencies.
Actual behavior
Same functionality as before, just using different native bindings and Web APIs built into modern JavaScript in ESM and CJS
Your environment
(Not a bug, but an improvement suggestion)
Self-service
Prerequisites
near-api-js.Description
I believe there's a solid opportunity to make a handful of changes such that
near-api-jscan compile down to many (any) JavaScript build target.There are some usages of
Bufferfor instance, which works great in NodeJS code or Node REPL, but are not compatible with CommonJS, which is "the OG JavaScript" that many people desire to use for various reasons.Buffercan actually be replaced by Uint8Array which has the green flag of "baseline widely available" which is great.There are a couple dependencies in
near-api-jsthat can be removed because of another Web APICrypto. For instance, we can securely generate random bytes using Crypto.getRandomValuesAnother example of a healthy replacement is the TextDecoder API, which can be utilized. These are built into the sort of foundational layer of JavaScript, which isn't always advertised but quite powerful.
The effect of making these changes means people will be able to use
near-api-jsin systems that don't require annpm/pnpmcommand or app.Reproducible demo
No response
Steps to reproduce
This isn't a bug but instead "help us improve" part of that selection. The steps to reproduce are running the existing scripts in
package.jsonExpected behavior
The JavaScript library is able to be used by developers who may not be using NodeJS or wish to use EcmaScript for their project. I see that the
near-connectrepository is one of those that wishes to do this and has accomplished it for quick load and execution without dependencies.Actual behavior
Same functionality as before, just using different native bindings and Web APIs built into modern JavaScript in ESM and CJS
Your environment
(Not a bug, but an improvement suggestion)
Self-service