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

Separate process worker not using TypeScript config #910

Open
Enitoni opened this issue Apr 9, 2018 · 7 comments
Open

Separate process worker not using TypeScript config #910

Enitoni opened this issue Apr 9, 2018 · 7 comments

Comments

@Enitoni
Copy link

Enitoni commented Apr 9, 2018

Description

I'm trying to import my modules in a separate process (using queue.process("path/to/processor.ts")) using TypeScript.

I get this error as soon as I try importing a module that is aliased using tsconfig-paths in the process file: Image

I need tsconfig-paths as it is what my entire application is using, is there a way to configure how the process is spawned, preferrably so I can set it to use my tsconfig.json?

Test code to reproduce

processor.ts
import { something } from "aliased/modules"

Bull version

3.3.10

@manast
Copy link
Member

manast commented Apr 16, 2018

I cannot think about a workaround for this right now other than building the .ts file and use the .js file as a processor. A bit more inconvenient but with a proper build setup it should be achievable.

@CTOlet
Copy link

CTOlet commented May 25, 2018

Hi folks! Do you have any news?

@manast
Copy link
Member

manast commented May 25, 2018

@nemmo you should build your processor and use the built .js file, that is the only solution that will work for some time.

@Enitoni
Copy link
Author

Enitoni commented May 27, 2018

@manast If there was a way to specify how the process is spawned (command arguments?) then this problem would be easier to solve, at least with tsconfig-paths.

@gcangussu
Copy link

@manast If there was a way to specify how the process is spawned (command arguments?) then this problem would be easier to solve, at least with tsconfig-paths.

We could use node's -r to specify @babel/register or any other thing that transforms files when required.

@lxcid
Copy link

lxcid commented Apr 28, 2020

I believe we need to call @babel/register before

processor = require(msg.value);
if (processor.default) {

I can't call @babel/register inside the processor script. it won't work, I'm not strong with the intricacy of babel-node but I could get it working by adding this line in master.js this:

process.on('message', function(msg) {
  switch (msg.cmd) {
    case 'init':
      // this line
      require('@babel/register').default({ extensions: [".js",".jsx",".ts",".tsx"] });
      processor = require(msg.value);
      if (processor.default) {
        // support es2015 module.
        processor = processor.default;
      }
    // ...
  }
}

This is originally passed in babel-node --extensions ".js",".jsx",".ts",".tsx" scheduler.js

The fork is not inheriting the original arguments.

For now, I'll have to use a patch it this way to make it still work for me in development.

@stale
Copy link

stale bot commented Jul 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants