RunJS icon indicating copy to clipboard operation
RunJS copied to clipboard

[Feature Request] Add support for ES Modules

Open SimplySayHi opened this issue 4 years ago • 13 comments

Hi, great work! I really like it :D It would be great to also have the possibility to import native ES Modules. I tried with my javascript-helpers and I got an error. Thanks

SimplySayHi avatar Jan 14 '21 14:01 SimplySayHi

Yep, this will come eventually, it's just dependent on upstream dependencies getting updated to support this.

lukehaas avatar Jan 14 '21 14:01 lukehaas

Would it be reasonable to base RunJS on Deno? Imports, TypeScript etc built in. It would certainly be non-trivial but as wonderful as node is, it has some pretty poor aspects.

Btw, one package that may be of interest for bash users is https://github.com/shelljs/shelljs. It does help to "tame" node!

backspaces avatar Feb 06 '21 18:02 backspaces

@backspaces RunJS is Electron based which is where it gets its Node integration from. To move to Deno would require Electron to integrate Deno. There's a discussion here about that: https://github.com/electron/electron/issues/23613

lukehaas avatar Feb 06 '21 19:02 lukehaas

Fascinating, Thanks!

backspaces avatar Feb 07 '21 01:02 backspaces

Another option would be to use Tauri instead of electron, though you wouldn't get TS support, and since all JS code technically just makes calls from a webview into the native layer, there might be some performance limitations. Though if you wanted to go really deep into it, it does let you bundle binaries (e.g. Node.js and Deno) and invoke them from the webview.

josh-hemphill avatar May 31 '21 05:05 josh-hemphill

Any update on this?

stormfar avatar Jul 13 '21 09:07 stormfar

@5tormTrooper some updates on this can be found here: https://github.com/electron/electron/issues/21457

lukehaas avatar Jul 13 '21 09:07 lukehaas

ReferenceError: exports is not defined Is this relevant to the current issue? When I try export const some = '123';

vladyn avatar Feb 03 '22 15:02 vladyn

@vladyn no that's not related, this is about importing ES Modules.

lukehaas avatar Feb 03 '22 15:02 lukehaas

Oh, OK I see. Bu is it possible to have import and export across my scratch files? On 3 Feb 2022, 17:43 +0200, Luke Haas @.***>, wrote:

@vladyn no that's not related, this is about importing ES Modules. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

vladyn avatar Feb 03 '22 16:02 vladyn

@vladyn no, each tab is a sandboxed playground. You could use the 'Set Working Directory' feature to point RunJS to a directory and import files from there.

lukehaas avatar Feb 03 '22 16:02 lukehaas

I've set the directory and save the file. But why I'm getting this error the moment I write "export"?

vladyn avatar Feb 03 '22 18:02 vladyn

@vladyn RunJS treats your code as a script, not a module so export is not supported.

lukehaas avatar Feb 03 '22 20:02 lukehaas

ES modules are now supported. Just enable bundling via the preferences.

lukehaas avatar Sep 21 '22 14:09 lukehaas