Skip to content

[Feature]: Support web-worker #929

Open
@SoonIter

Description

@SoonIter

What problem does this feature solve?

the bundleless workaround

defineConfig({
lib: [{
  bundle: false,
  format: 'esm',
      syntax: 'esnext',
      tools: {
        rspack: {
          module: {
            parser: {
              javascript: {
                worker: false,
              },
            },
          },
        },
      },
}]
})

but in bundle mode

there are tons of webpack runtime

Image

What does the proposed API look like?

test demo: https://github.com/SoonIter/rslib-worker-demo

in bundle the output should be:

index.js
fib-worker.js
chat-worker.js
// ...
const chatWorker = new SharedWorker(new URL('./chat-worker.js', import.meta.url), {
    name: 'chat',
    type: 'module'
});
// ...
const fibWorker = new Worker(new URL('./fib-worker.js', import.meta.url), {
    name: 'fibonacci',
    type: 'module'
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions