-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hello!
I'm starting a new project with TypeScript and currently experimenting with Comedy as a solution for scaling the application.
I ran into an issue with the way Resources are serialized and sent to the forked process which is causing a lot of headaches and seems like a big limitation (if I'm understanding this correctly).
The original Resource definition is as follows:
import { ActorSystem, ResourceDefinition } from 'comedy';
import { getResource } from '../helpers/test';
import { ComedyResource } from '../decorators/ComedyResource';
@ComedyResource('TestResource')
export default class TestResource implements ResourceDefinition<string> {
destroy(): Promise<void> | void {
// nothing to do here
return undefined;
}
getResource(): string {
// return from an imported function as a test
return getResource();
}
initialize(system: ActorSystem): Promise<void> | void {
// nothing to do here
return undefined;
}
}But what is sent to the child process (in the create-actor message) is:
class TestResource {
destroy() {
// nothing to do here
return undefined;
}
getResource() {
// return from an imported function as a test
return test_1.getResource();
}
initialize(system) {
// nothing to do here
return undefined;
}
}; TestResource;
As you can see, the imports are all missing and there is no way this can work.
@Zephyrrus noticed that you can use require() inside the definition and to import things, but they are imported from the wrong working directory and therefore don't resolve properly.
As a workaround I considered creating dummy "shells" that would dynamically load the correct file (from disk) with require(), but that sounds very cumbersome to maintain.
Is there any solution to this? Am I missing something?