ESR52 SpiderMonkey & ES6

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ESR52 SpiderMonkey & ES6

Kent Williams
Been beating my head on this for a couple of days.

I'm trying to get ES6 module support working with ESR52 SpiderMonkey.

I can run plain scripts just fine, but if I try using ES6 modules, it
breaks.

I solved one problem: You can't compile anything 'import' in it without
setting the Module resolver with JS::SetModuleResolveHook.

Then it turns out you can't use JS::Compile with any code with 'import'
in it -- even if it isn't a module itself.

But if you use JS::CompileModule, it isn't clear what you have to do to
execute the script.

What should happen is that you do X (where X is unknown) to execute the
script, and then the interpreter handles the 'import' statements in your
code by calling the resolve hook.

So my problem is X -- if you have to use JS::CompileModule if there are
any import statements in a script, how do you execute the script?

Looking at the JS Shell code, the resolve hook is actually in a
Javascript file.  I tried doing what that file does (ModuleLoader.js)
but it doesn't work.  I call ModuleDeclarationInstantiation followed by
ModuleEvaluation -- and both fail without any error message. They return
false, and there's no apparent error message anywhere.

Is it the case that no one uses ES6 modules with SpiderMonkey, except
perhaps the Mozilla Browswer & the js shell included?




_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: ESR52 SpiderMonkey & ES6

Jason Orendorff-2
You're right, this is super complicated. :-\

Well, I guess the first task is to get an error message. There's no pending
exception when these functions return false?

-j


On Wed, Jun 20, 2018 at 3:11 PM, Kent Williams <[hidden email]>
wrote:

> Been beating my head on this for a couple of days.
>
> I'm trying to get ES6 module support working with ESR52 SpiderMonkey.
>
> I can run plain scripts just fine, but if I try using ES6 modules, it
> breaks.
>
> I solved one problem: You can't compile anything 'import' in it without
> setting the Module resolver with JS::SetModuleResolveHook.
>
> Then it turns out you can't use JS::Compile with any code with 'import' in
> it -- even if it isn't a module itself.
>
> But if you use JS::CompileModule, it isn't clear what you have to do to
> execute the script.
>
> What should happen is that you do X (where X is unknown) to execute the
> script, and then the interpreter handles the 'import' statements in your
> code by calling the resolve hook.
>
> So my problem is X -- if you have to use JS::CompileModule if there are
> any import statements in a script, how do you execute the script?
>
> Looking at the JS Shell code, the resolve hook is actually in a Javascript
> file.  I tried doing what that file does (ModuleLoader.js) but it doesn't
> work.  I call ModuleDeclarationInstantiation followed by ModuleEvaluation
> -- and both fail without any error message. They return false, and there's
> no apparent error message anywhere.
>
> Is it the case that no one uses ES6 modules with SpiderMonkey, except
> perhaps the Mozilla Browswer & the js shell included?
>
>
>
>
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: ESR52 SpiderMonkey & ES6

philip.chimento
In reply to this post by Kent Williams
On Saturday, June 23, 2018 at 3:25:33 PM UTC-4, Jason Orendorff wrote:

> You're right, this is super complicated. :-\
>
> Well, I guess the first task is to get an error message. There's no pending
> exception when these functions return false?
>
> -j
>
>
> On Wed, Jun 20, 2018 at 3:11 PM, Kent Williams <k...@l...com>
> wrote:
>
> > Been beating my head on this for a couple of days.
> >
> > I'm trying to get ES6 module support working with ESR52 SpiderMonkey.
> >
> > I can run plain scripts just fine, but if I try using ES6 modules, it
> > breaks.
> >
> > I solved one problem: You can't compile anything 'import' in it without
> > setting the Module resolver with JS::SetModuleResolveHook.
> >
> > Then it turns out you can't use JS::Compile with any code with 'import' in
> > it -- even if it isn't a module itself.
> >
> > But if you use JS::CompileModule, it isn't clear what you have to do to
> > execute the script.
> >
> > What should happen is that you do X (where X is unknown) to execute the
> > script, and then the interpreter handles the 'import' statements in your
> > code by calling the resolve hook.
> >
> > So my problem is X -- if you have to use JS::CompileModule if there are
> > any import statements in a script, how do you execute the script?
> >
> > Looking at the JS Shell code, the resolve hook is actually in a Javascript
> > file.  I tried doing what that file does (ModuleLoader.js) but it doesn't
> > work.  I call ModuleDeclarationInstantiation followed by ModuleEvaluation
> > -- and both fail without any error message. They return false, and there's
> > no apparent error message anywhere.
> >
> > Is it the case that no one uses ES6 modules with SpiderMonkey, except
> > perhaps the Mozilla Browswer & the js shell included?

We have a branch in progress for this in GJS: https://gitlab.gnome.org/GNOME/gjs/merge_requests/150 It's currently still based on ESR52, but the basics do seem to work.
There's some information there that may help you. I believe the module is executed during the ModuleEvaluation step.

Regards,
Philip
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: ESR52 SpiderMonkey & ES6

Kent Williams
I resolved this by realizing that I know when something is a module, and
when it is not, based on my application. Will look at your solution also.


On 07/26/2018 10:14 AM, Philip Chimento wrote:

> On Saturday, June 23, 2018 at 3:25:33 PM UTC-4, Jason Orendorff wrote:
>> You're right, this is super complicated. :-\
>>
>> Well, I guess the first task is to get an error message. There's no pending
>> exception when these functions return false?
>>
>> -j
>>
>>
>> On Wed, Jun 20, 2018 at 3:11 PM, Kent Williams <k...@l...com>
>> wrote:
>>
>>> Been beating my head on this for a couple of days.
>>>
>>> I'm trying to get ES6 module support working with ESR52 SpiderMonkey.
>>>
>>> I can run plain scripts just fine, but if I try using ES6 modules, it
>>> breaks.
>>>
>>> I solved one problem: You can't compile anything 'import' in it without
>>> setting the Module resolver with JS::SetModuleResolveHook.
>>>
>>> Then it turns out you can't use JS::Compile with any code with 'import' in
>>> it -- even if it isn't a module itself.
>>>
>>> But if you use JS::CompileModule, it isn't clear what you have to do to
>>> execute the script.
>>>
>>> What should happen is that you do X (where X is unknown) to execute the
>>> script, and then the interpreter handles the 'import' statements in your
>>> code by calling the resolve hook.
>>>
>>> So my problem is X -- if you have to use JS::CompileModule if there are
>>> any import statements in a script, how do you execute the script?
>>>
>>> Looking at the JS Shell code, the resolve hook is actually in a Javascript
>>> file.  I tried doing what that file does (ModuleLoader.js) but it doesn't
>>> work.  I call ModuleDeclarationInstantiation followed by ModuleEvaluation
>>> -- and both fail without any error message. They return false, and there's
>>> no apparent error message anywhere.
>>>
>>> Is it the case that no one uses ES6 modules with SpiderMonkey, except
>>> perhaps the Mozilla Browswer & the js shell included?
> We have a branch in progress for this in GJS: https://gitlab.gnome.org/GNOME/gjs/merge_requests/150 It's currently still based on ESR52, but the basics do seem to work.
> There's some information there that may help you. I believe the module is executed during the ModuleEvaluation step.
>
> Regards,
> Philip
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine