Open FreePhoenix888 opened 1 year ago
I had conversation about this with chatgpt: https://chat.openai.com/share/452fcec7-ae51-49ab-9e0e-b22bd9c0e059
If I run this file (test.ts
):
async ({ deep, data: { newLink: notifyLink, triggeredByLinkId }, }) => {
};
export {};
//# sourceMappingURL=module.js.map
by using
npx ts-node --esm test.ts
It will run without problem
If I run this file (test.ts
):
eval(`
async ({ deep, data: { newLink: notifyLink, triggeredByLinkId }, }) => {
};
export {};
//# sourceMappingURL=module.js.map
`)
by using
npx ts-node --esm test.ts
It will throw the error:
freephoenix888@FreePhoenix:~/Programming/deep/deep-memo-app$ npx ts-node --esm test.ts
SyntaxError: Unexpected token 'export'
at file:///home/freephoenix888/Programming/deep/deep-memo-app/test.ts:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
I have talked about this with GPT-4: https://chat.openai.com/share/5bbda39d-1ad5-4eb7-93f1-59061fe47a59
@FreePhoenix888 did you try to put export before the function? Our code expects that the last expression of the code string will be function expression.
@FreePhoenix888 did you try to put export before the function? Our code expects that the last expression of the code string will be function expression.
The reason is - tsx now transpiles ts to esnext (or smth like that) but code is executed by eval by js provider
Eval does not know what export is
As workaround I remove this export
@FreePhoenix888 I think we can close this issue in favor of https://github.com/deep-foundation/js-docker-isolation-provider/issues/19
What do you think?
Or what is the specific reason to use export
? Even if handler supports ts, why would you need to export anything from it?
@FreePhoenix888 I think we can close this issue in favor of #19
What do you think? Or what is the specific reason to use
export
? Even if handler supports ts, why would you need to export anything from it?
I do not export smth manually, export is added itself when tsx bundles to jsx
Error
Unexpected token 'export'
Source Code
Dist code transpiled by
@deep-foundation/tsx
packageQuestion
Is this the problem of
js-docker-isolation-provider
or@deep-foundation/tsx
package? What should we do? The scariest thing is that I have been using handler code transpiled by that version of tsx package and everything was working. I do not know what is changed the way to brake it