cloudflare / stpyv8

Python 3 and JavaScript interoperability. Successor To PyV8 (https://github.com/flier/pyv8)
Apache License 2.0
437 stars 38 forks source link

support for JavaScript modules #101

Open declann opened 7 months ago

declann commented 7 months ago

Hi,

I'm interested in running JavaScript code that uses JS modules, including remote imports like import { memoize } from 'https://cdn.jsdelivr.net/npm/underscore/+esm';

but I get the error SyntaxError: Cannot use import statement outside a module

I can get this to work in STPyV8 by making an old-school bundle (or adapting the bundler made by @liran-funaro in issue #60 !)

However, V8 does support JavaScript modules, so I wonder if there's a way for STPyV8 to support this, how tricky it might be and if there is an interest in develop it?

I guess that this might be mostly just providing a switch, similar to the --input-type flag in nodejs.

Thanks! Declan

buffer commented 6 months ago

I am well aware of the issue and would like to fix it soon or later. But unfortunately I will not be able to do that soon due to lack of time. I will keep the issue open as a reminder for myself that I have to take care of that.

himakshi25 commented 2 months ago

Hi @buffer , I am trying to import node-fetch and getting similar issue

SyntaxError: SyntaxError: Cannot use import statement outside a module ( @ 1 : 0 ) -> import fetch from 'node-fetch';

Is this issue being worked upon or yet to be picked in near future?