tc39/proposal-asset-references

Is there a way to get the content of the asset without calling `import()`?

justinmchase opened this issue · 1 comments

Suppose I just wanted to get the string or bytes of the asset and then interpret it, how would that be done?

I'm just imagining this as a way to dynamically compile DSLs or custom languages such as:

example.js
import { ExampleLang } from "./lang.js"
import asset Foo from "./foo.ex"

const lang = new ExampleLang()
export const foo = await lang.compile(Foo);

lang.js

export class ExampleLang {
  async compile(asset) {
    const content = fetch(asset) // how do you do this?
    const result = interpret(content);
    return result
  }
}

Is this within the scope of this proposal?

Implicitly, yes, for several of the examples depend on it. Would like to see a few more details on this, though - seems nonsensical to just delegate to fetch for this.