Skip to content

Any way to access loaders with "inline code" (vm.Script, eval, etc.) #116

Open
@tolmasky

Description

@tolmasky

If you have serialized "content" of a specific loader format (say for example TypeScript, or whatever), it would be nice to be able to use the existing loader functionality to be able to evaluate it "inline". One might for example expect that vm.Script, given that it allows you specify a filename option, might automatically choose the right loader:

// Imagine this was run with --experimental-loader typescript-loader.mjs
vm.Script("const x: Number = 5;", { filename: "test.ts" });

As far as I'm aware though, there is no way to do this currently (please correct me if I am mistaken!). I tried seeing if I could call load() directly to go through the loading machinery and just passing in the source property, but I also couldn't find an API to do that:

doLoad({ source: "some typescript...", url: "blah.ts" });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions