Skip to content

Subworkers loaded from incorrect URL? #31

Open
@jamiewinder

Description

@jamiewinder

I have worker that is loaded from the main code:

const worker = new Worker('./MainWorker.js', {
    name: 'main',
    type: 'module'
});

And within this worker, it tries to load a subworker:

const subworker = new Worker('./Subworker.js', {
    name: 'sub',
    type: 'module'
});

When webpack bundles this, the browser correctly and successfully loads the main worker from 'dist/main.worker.js', however it then tries to load the subworker from 'dist/dist/sub.worker.js' which isn't where the worker bundle was built to.

I'm not sure if this is a config problem on my side or an issue with the plugin. Here are the relevant parts of my webpack config:

{
    entry: ['./src/index.js'],
    output: {
        path: path.join(__dirname, 'dist'),
        filename: '[name].js',
        publicPath: 'dist/'
    },
    plugins: [
        new WorkerPlugin({
            filename: '[name].worker.js'
        })
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions