-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not use static es6 import 'gun/sea' ? #636
Comments
@Kirpich634 interesting, could you try Thanks for pointing this out. |
@amark No, I also thought about it immediately, but no. Does it work for you? |
you in browser or NodeJS? Browser still requires you add SEA script tag, because |
Hi, I test in react-native and it crash when |
@ikeyboard React-Native doesn't seem to have WebCrypto spec or allow for polyfills. To get SEA working in React-Native (I don't use React, so I'm guessing and need community help here) you will need to have React-Native bridge RPC calls to a JS webview (where WebCrypto exists) and execute it there, then pass the values back to React-Native. I know some people have successfully gotten SEA working in React-Native, so this is possible! |
Unless somebody in the community who has ES6 experience volunteers to debug this, I don't have enough bandwidth/capacity (or ES6-know-how-knowledge, I can't even figure out how to get ANY This is an area where somebody in the community that has ES6 knowledge should know exactly what is going on (unless |
babel and webpack do different things with import statements. es6 modules are not something you can use without additional tooling. in the general case babel and webpack should be able to import commonjs modules. sometimes I end up having to configure aliases to get things building.
could you be more specific about your build environment and toolchain?
… On May 9, 2019, at 18:09, Mark Nadal ***@***.***> wrote:
Closed #636.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@r14c I appreciate your comment!
In SEA, I do:
I don't know why In browser, Gun attaches itself to In nodejs, The only way this should go wrong is if:
|
es6 is spec, but afaik there aren't any stable native implementations. i'll try setting up a demo project with babel 7 one of these days to see what i can find. |
@r14c then how are other people using |
exactly what is happening depends on the particular project
unfortunately.
…On Fri, 2019-05-10 at 12:59 -0700, Mark Nadal wrote:
@r14c then how are other people using import with GUN already??? Like
Babel still? So is Babel transpiling things wrong (if require works
but import doesn't)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@r14c this is very enlightening, thank you for explaining! |
Actually ES modules are useable without tooling and flag since Edge 16, Firefox 60, Chrome 61, Safari 11 and Opera 48 (17/06/2019, Source) you need to set <script type="module">
import { tag } from './html.js'
const h1 = tag('h1', ' Hello Modules!')
document.body.appendChild(h1)
</script> You need tooling if you are trying to consume
There are some subtile differences with scopes between both system, which transpilers like |
Maybe @Kuirak can lead us blind people forward. Looks like the conclusion is that it is normal for most projects to support 2 different versions, 1 for All of GUN core should be static (altho I had to proxy There might be 1 optional module that does do something dynamic, but that can either be dropped (as it is not necessary), or ... good to know! ... |
I think the support for two versions thing is a transientary effect of the current situation - we are facing this even with our own internal libraries (like dweb-archivecontroller). Until recently, you could just use 'require', this worked fine in nodejs and webpack, and irrelevant in browsers which couldnt handle modules split across multiple files. Now - and for a short time - you've got ES6 module support in browsers (i.e. That gives us a current oddity where shifting to Once node fully supports |
@mitra42 that was a very useful summary, thank you. |
ES modules in node are not hard. It's literally just 2 steps. ES modules are the spec but they aren't yet implemented natively in nodejs. |
Quick example, how to use ES modules. Should take only a minute to try. |
In case anyone else ends up here wondering how to import gun into an es6 module, I had success with the following at the top of my module:
then, in the browser console, I see:
|
If you do this:
import 'gun/sea';
we'll get:
Uncaught Error: Cannot find module './gun.js'
but if:
require('gun/sea');
everything will be OK.
With this, is possible to do somethingcan so that I could use static es6 import?
The text was updated successfully, but these errors were encountered: