Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 27, 2025

The FsaNodeSyncAdapterWorker.start() method now accepts either a Worker instance or a URL string, enabling compatibility with modern build tools like Vite that require module workers.

Changes Made

  • Changed the first parameter from url: string to urlOrWorker: string | Worker
  • Added automatic detection of module URLs containing type=module to create workers with { type: 'module' } options
  • Maintained full backward compatibility with existing string URL usage

Usage Examples

Traditional URL (backward compatible):

const adapter = await FsaNodeSyncAdapterWorker.start('/worker.js', dir);

Module URL (for Vite and similar frameworks):

import MyWorker from '../worker?worker&url';
// MyWorker becomes '/src/worker.ts?type=module&worker_file'
const adapter = await FsaNodeSyncAdapterWorker.start(MyWorker, dir);

Pre-created Worker instance:

const worker = new Worker('/worker.js', { type: 'module' });
const adapter = await FsaNodeSyncAdapterWorker.start(worker, dir);

The implementation automatically detects URLs containing type=module and creates the worker with the appropriate options, making the fsa-to-node module compatible with modern bundlers that use ES module workers.

Fixes #974.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] add ability for worker module creation Add support for Worker instances and module URLs in FsaNodeSyncAdapterWorker Jul 27, 2025
@Copilot Copilot AI requested a review from streamich July 27, 2025 10:21
Copilot finished work on behalf of streamich July 27, 2025 10:21
@streamich streamich marked this pull request as ready for review July 27, 2025 16:18
@louwers
Copy link

louwers commented Aug 17, 2025

@streamich Could you merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add ability for worker module creation
3 participants