Skip to content

ES modules InvokeFromStringAsync #201

@stephenlautier

Description

@stephenlautier

Hi,

I'm trying to invoke an .mjs or ES module from a string is this somehow possible?

I've seen this issue and from file should be supported #151

However in this case, I'm using a class library and the file is an Embedded Resource, so then its invoked with InvokeFromStringAsync

[10:54:39 WRN] [Jering.Javascript.NodeJS.HttpNodeJSService] An invocation attempt failed. Retries using existing process remaining: 0.
Exception:
  Jering.Javascript.NodeJS.InvocationException: Unexpected token 'export'
anonymous:2
export default async (
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1274:20)
    at Module._compile (node:internal/modules/cjs/loader:1320:27)
    at IncomingMessage.<anonymous> (file:///S:/git/rig/midgard.pwa/[eval1]:170:21)
    at IncomingMessage.emit (node:events:517:28)
    at endReadableNT (node:internal/streams/readable:1400:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
   at Jering.Javascript.NodeJS.HttpNodeJSService.TryInvokeAsync[T](InvocationRequest invocationRequest, CancellationToken cancellationToken)
   at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.TryInvokeCoreAsync[T](InvocationRequest invocationRequest, CancellationToken cancellationToken)

Any help would be appreciated thank you 🙇‍♂️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions