Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Feature: Arbitrary sources for module source text #97

Closed
GeoffreyBooth opened this issue May 19, 2018 · 4 comments
Closed

Feature: Arbitrary sources for module source text #97

GeoffreyBooth opened this issue May 19, 2018 · 4 comments
Labels

Comments

@GeoffreyBooth
Copy link
Member

  • I want to load modules from a database and not from the filesystem.
  • I want to load modules from a URL.

Use case 6. Related to use case 38, about --eval for ESM code.

@Jamesernator
Copy link

This can be partially solved by the vm.Module constructor and linking and evaluating the module yourself. Obviously it's not that elegant so I wouldn't call it a done solution, but at the very least the use case is accomplishable.

Perhaps the --loader flag thing would also enable this use case, but I'm not too familiar with it.

@xtuc
Copy link
Contributor

xtuc commented May 21, 2018

Sorry I don't understand this use case, could you please provide a few examples?

Are the following example in this use case?

import tty from "unix:///dev/tty0"
import file from "file://tmp/foo"
import something from "tcp://localhost"

@GeoffreyBooth
Copy link
Member Author

Pinging @ceejbot as this was their use case.

@ljharb
Copy link
Member

ljharb commented May 22, 2018

I would expect that there'd be a way to do both of the following:

  1. programmatically create a module, perhaps with VM.module, from an arbitrary string, and define it to be importable at some path
  2. define a custom loader that can handle custom URL protocols, or custom paths, that can load source text in real time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants