Skip to content
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

Proposal. support https import static and dynamic #255

Open
frank-dspeed opened this issue Mar 1, 2020 · 7 comments
Open

Proposal. support https import static and dynamic #255

frank-dspeed opened this issue Mar 1, 2020 · 7 comments
Labels
enhancement New feature or request Node.js Relevant for Graal.js' Node.js recast

Comments

@frank-dspeed
Copy link
Contributor

frank-dspeed commented Mar 1, 2020

In NodeJS This feature is not possible without custom loaders and will not get implemented as they don't want to handle cache and that. They say it belongs to the user land.

Anyway it is a feature that for example is supported by deno a JS/TS Runtime written in rust by the creator of nodejs ryan dahl.

import { createAdapter } from 'https://unpkg.com/@direktspeed/[email protected]/core.mjs'

import('https://unpkg.com/@direktspeed/[email protected]/core.mjs').then(({ createAdapter })=>createAdapter())

i think it would be really great if we could simply on compile fetch the resources and then also support browser resolve so relativ resolve by url

@wirthi wirthi added enhancement New feature or request Node.js Relevant for Graal.js' Node.js recast labels Mar 2, 2020
@wirthi
Copy link
Member

wirthi commented Mar 2, 2020

Hi,

thanks for your suggestion. That seems to be a reasonable extension, we might have to add it behind a flag in order to stay compatible. Sounds like something a student or intern could do, or where we could use an external contribution.

Is there any "specification" for this available? You write this is not available on Node.js, not even as an experimental feature or in a branch?

Thanks,
Christian

@frank-dspeed
Copy link
Contributor Author

@wirthi thanks for your reply i will write all infos into this issue and ping you back maybe even with a pull request as i am aware of the specs and how it works i only wanted to make sure that you would accept that.

@jazdw
Copy link

jazdw commented Apr 30, 2020

I think #257 is related to this, @eleinadani should be able to confirm. I think technically it would be possible to use a custom Truffle file system that supports the http/https scheme to load files. However this would be a pain as AFAIK it requires you to register a custom java.nio.file.spi.FileSystemProvider.

Using load() seems to be able to load files from http/https out of the box (with the js.load-from-url option enabled). This is because it first tries to load the Source from the URL using the file system then drops back to opening a connection from the URL -
https://github.com/oracle/graal/blob/9dd433c63575957376f8411cd48c9974d96b145e/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java#L1095-L1099

Unfortunately it doesn't seem to support using the URL connection unless the default Truffle file system is being used.

@frank-dspeed
Copy link
Contributor Author

@jazdw good point and ya sure its a bit complex for example in deno we solved that via using a bundler on startup that populates a cache folder so the important algo is
if import URL is used it needs to look into the local cache if it is not there download it put it there and load it

@burakakca
Copy link

Is this issue say deno support work on progress?

@frank-dspeed
Copy link
Contributor Author

frank-dspeed commented Nov 23, 2022

Today with current ECMAScript 2022 i have switched to TLA Top Level Await and using fetch to request the resources then taking the text body messaging that to the engine and let it do its work so implemented that in userland without hooks.

when i do not want or need to use the engine as it is a small script then i even go for

Pseudo code needed to write fast

fetch().then(res=>import(`data:text/javascript;base64,${base64(res.text())}`))

@lemanschik
Copy link

lemanschik commented Dec 4, 2022

closed by:

as graaljs runs already in the browser with above posted modifications it also will use the browser cache this can be closed.

@burakakca yes the linked issue in this comment tracks also graaljs deno support out of the box in fact i invented a web platform compatible shared module and package format in on this changes everything fundamental

so deno and graaljs support the new web-modules standard today out of the box only ecosystem adoption is needed and happens just now via integration into vscode which will then run directly without a backend in the browser again supporting web-modules graaljs is only a device in that stack every external source is a device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Node.js Relevant for Graal.js' Node.js recast
Projects
None yet
Development

No branches or pull requests

5 participants