Closed bgins closed 3 years ago
Initial tests in #277 indicate that we may be able to replace noble-ed25519
with tweetnacl
. In addition, these tests have confirmed for us that noble-ed25519
is the only library we are currently using with big integer literals.
Some of the initial motivation for supporting older build targets has dissipated. SvelteKit now permits es2020
as a build target: https://github.com/sveltejs/kit/issues/2220.
We should still consider the change in #277 for a few reasons:
tweetnacl
has been audited and has been in use for many years
Note: This issue may not be resolved with additional build targets. The goal is to document and consider the options.
Summary
Webnative builds currently targets
es2020
. We would like to support a wider range of targets, as old as possible.Problem
Webnative will not work in some browsers that lack full
es2020
support. Mostly, this means Internet Explorer and less used mobile browsers, though notablyexport * as namespace
is not available in Safari on iOS or Android Browser. See es2020 features summary.In addition to browsers, some bundlers and build tools may not support
es2020
and may require users to target some other environment. Notably, SvelteKit only supportses2019
builds.Impact
Webnative will not work in some older browsers, mostly notably Internet Explorer. We have not encountered build environment issues in Safari for iOS or Android Brower. (Please add a comment below if you have noticed otherwise!)
Webnative will not build in SvelteKit due to the lack of support for big integer literals. SvelteKit does not currently offer a way to configure the Vite build target, which is set at
es2019
. See https://github.com/sveltejs/kit/issues/859#issuecomment-894556133 for a summary.There may be additional bundlers and build environments with similar restrictions. (Please add them below :pray:)
Solution
We have explored a couple of solutions. None stands out yet as the right way to go. See the details below.
Detail
Is your feature request related to a problem? Please describe.
Webnative does not build in SvelteKit.
Describe the solution you'd like
Unclear. No solution stands out as the best option yet.
Describe alternatives you've considered
Transpile or polyfill to older targets. Unfortunately, this does not seem like a viable solution. Webnative uses noble-ed25519 which uses big integer literals. The general consensus is that big integer literals are "impossible to polyfill and infeasible to transpile because the performance would be terrible".
Google wrote the JSBI with this in mind. In their README:
Esbuild cites this as their reason for not transforming big integer literals: https://github.com/evanw/esbuild/issues/732#issuecomment-770519567
Find replacement libraries. We may be able to find alternative implementations that do not rely on big integer literals or other features that cannot be transpiled.
Open questions:
Do other libraries use big integer literals or other
es2020
-only features?Does webnative use any of these features directly?
One related is alternative is asking library authors about alternatives that use JSBI or similar alternatives that provide compatibility with older build targets. This request may be declined because, in some cases, it would essentially mean a re-write.
Do nothing. Wait for the ecosystem to catch up. This would mean that webnative would not be available in some environments for a time.
Something else? Please suggest other alternatives below. This is all based on initial research that should not be considered exhaustive or complete.