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

Plain eval is used without transpilation. Ts handlers do not work #19

Open
Archer-Lotos opened this issue Sep 19, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Archer-Lotos
Copy link
Member

Describe the bug

Plain eval is used without transpilation:

const fn = memoEval(code);

Example Of Non-Working Typescript Handler

Handler Code

import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js";
import { Link } from "@deep-foundation/deeplinks/imports/minilinks.js";
import { DeepClientInstance } from "@deep-foundation/deeplinks/imports/client";

async (options: {
  deep: DeepClient;
  data: {
    newLink: Link<number>;
  };
}) => {
    return 5
};

Error

{
  "stack": "SyntaxError: Cannot use import statement outside a module\n    at eval (<anonymous>)\n    at memoized (/node_modules/lodash/memoize.js:62:23)\n    at makeFunction (file:///index.js:29:16)\n    at file:///index.js:61:20\n    at Generator.next (<anonymous>)\n    at file:///index.js:7:71\n    at new Promise (<anonymous>)\n    at __awaiter (file:///index.js:3:12)\n    at file:///index.js:56:33\n    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)",
  "message": "Cannot use import statement outside a module"
}

Expected Behavior

No response

Current Behavior

No response

Steps to reproduce

No response

Environment

No response

@Archer-Lotos Archer-Lotos added the bug Something isn't working label Sep 19, 2023
@Konard
Copy link
Member

Konard commented Mar 23, 2024

Workaround 1

Use await deep.import(...), require(...) or await import(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants