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

Add React .tsx and .jsx to supportedFileTypes in worker.ts #3021

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/classes/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Worker<
}
processor = processor.href;
} else {
const supportedFileTypes = ['.js', '.ts', '.flow', '.cjs'];
const supportedFileTypes = ['.js', '.ts', '.flow', '.cjs', '.tsx', '.jsx'];
const processorFile =
processor +
(supportedFileTypes.includes(path.extname(processor)) ? '' : '.js');
Expand Down
5 changes: 5 additions & 0 deletions tests/sandboxed-worker-sample-files/worker1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Job } from '../../src/classes/job';

export default async function processJob(job: Job<any>): Promise<void> {
return void 0;
}
10 changes: 10 additions & 0 deletions tests/test_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4518,4 +4518,14 @@ describe('workers', function () {

await worker.close();
});

it('should accept file with valid extensions when initializing a sandboxed worker', async () => {
const worker = new Worker(
queueName,
`${__dirname}/../tests/sandboxed-worker-sample-files/worker1.tsx`,
{ connection: {}, concurrency: 1 },
);

await worker.close();
});
});
Loading