Re: [go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-10-05 Thread Joop Kiefte
the environment of the wasm decides what you have access to, so you might want 
to add the import in the HTML around it instead.

[Joop Kiefte - Chat @ 
Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=pq35q)   
[pq35q]

On October 5, 2020 at 18:03 GMT, Eduard Castany  
wrote:

So, adding  to the header does NOT 
seem to import anything into Go's wasm. I'm thinking that this is because 
modules do not have global scope so Go has to import them itself, rather than 
delegating the loading to JS, to be able to use them. Any ideas?

On Tuesday, 29 September 2020 at 16:34:13 UTC+2 iko...@gmail.com wrote:

I think that's pretty recent? The only way used to be to add a script tag, and 
I have used that in Go before. I think just putting it in as a function call 
might work though...

[Joop Kiefte - Chat @ 
Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=pengd)   
[pengd]

On September 29, 2020 at 12:55 GMT, Eduard Castany  wrote:

I guess this works on node.js but I was referring to the browser environment. 
Where normal JavaScript can just `import("module")`.

On Tuesday, 29 September 2020 at 11:44:56 UTC+2 Alvadron wrote:

This is what I have been doing and it has worked for my needs:
```
// Importing it using "require" and storing the module in a variable
core := js.Global().Call("require", "@boostercloud/framework-core")

// Now get some props/methods from that module as usual:
config := core.Get("Booster").Get("config")
```
Is this what you were asking about?

El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, eduard@gmail.com 
escribió:

In JavaScript we can 
[import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)
 JavaScript modules statically and dynamically. How could we import a 
JavaScript module dynamically in Go?

The closest/simplest thing may be to add an HTML script tag into the page 
header programatically (and I'm going to try that) but maybe there is a more 
obvious way that I'm not seeing.

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts...@googlegroups.com.
To view this discussion on the web visit 
[https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com](https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com?utm_medium=email_source=footer).

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
[https://groups.google.com/d/msgid/golang-nuts/ec9336e5-6104-4312-870b-2ccf09998da2n%40googlegroups.com](https://groups.google.com/d/msgid/golang-nuts/ec9336e5-6104-4312-870b-2ccf09998da2n%40googlegroups.com?utm_medium=email_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c-64693-kfwvx4rd-n1r0f7%3D18e3pv3%402.gethop.com.


Re: [go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-10-05 Thread Eduard Castany
So, adding  to the header does 
NOT seem to import anything into Go's wasm. I'm thinking that this is 
because modules do not have global scope so Go has to import them itself, 
rather than delegating the loading to JS, to be able to use them. Any ideas?

On Tuesday, 29 September 2020 at 16:34:13 UTC+2 iko...@gmail.com wrote:

> I think that's pretty recent? The only way used to be to add a script tag, 
> and I have used that in Go before. I think just putting it in as a function 
> call might work though...
>
>   *Joop Kiefte* - Chat @ Spike 
>  [image: 
> pengd]
>
> On September 29, 2020 at 12:55 GMT, Eduard Castany  
> wrote:
>
> I guess this works on node.js but I was referring to the browser 
> environment. Where normal JavaScript can just `import("module")`.
>
> On Tuesday, 29 September 2020 at 11:44:56 UTC+2 Alvadron wrote:
>
>> This is what I have been doing and it has worked for my needs:
>> ```
>> // Importing it using "require" and storing the module in a variable
>> core := js.Global().Call("require", "@boostercloud/framework-core")
>>
>> // Now get some props/methods from that module as usual:
>> config := core.Get("Booster").Get("config")
>> ```
>> Is this what you were asking about?
>>
>> El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, 
>> eduard@gmail.com escribió:
>>
>>> In JavaScript we can import 
>>> 
>>>  
>>> JavaScript modules statically and dynamically. How could we import a 
>>> JavaScript module dynamically in Go?
>>>
>>> The closest/simplest thing may be to add an HTML script tag into the 
>>> page header programatically (and I'm going to try that) but maybe there is 
>>> a more obvious way that I'm not seeing.
>>>
>> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com
>  
> 
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ec9336e5-6104-4312-870b-2ccf09998da2n%40googlegroups.com.


Re: [go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-09-29 Thread Joop Kiefte
I think that's pretty recent? The only way used to be to add a script tag, and 
I have used that in Go before. I think just putting it in as a function call 
might work though...

[Joop Kiefte - Chat @ 
Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=pengd)   
[pengd]

On September 29, 2020 at 12:55 GMT, Eduard Castany  
wrote:

I guess this works on node.js but I was referring to the browser environment. 
Where normal JavaScript can just `import("module")`.

On Tuesday, 29 September 2020 at 11:44:56 UTC+2 Alvadron wrote:

This is what I have been doing and it has worked for my needs:
```
// Importing it using "require" and storing the module in a variable
core := js.Global().Call("require", "@boostercloud/framework-core")

// Now get some props/methods from that module as usual:
config := core.Get("Booster").Get("config")
```
Is this what you were asking about?

El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, eduard@gmail.com 
escribió:

In JavaScript we can 
[import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)
 JavaScript modules statically and dynamically. How could we import a 
JavaScript module dynamically in Go?

The closest/simplest thing may be to add an HTML script tag into the page 
header programatically (and I'm going to try that) but maybe there is a more 
obvious way that I'm not seeing.

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
[https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com](https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com?utm_medium=email_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c-64693-kfo28wdx-8glhrh%3Drdnx29%402.gethop.com.