Saturday, 17 April 2021

What Does worker-loader Inline Do?

My understanding was that the following Webpack worker-loader config:

...
module: {
    rules: [
        {
            test: /worker\.js/,
            loader: "worker-loader",
            options: {
                inline: 'fallback',
            }
        }
        { ... }
    ]
}
...

would bundle a worker file (named worker.js in this case) into the output file with other JS files, resulting in a single-file output. Then loading the file in the App using

import Worker from "worker-loader!./worker.js";

would successfully load the Worker. After testing it, it seems that I am misunderstood. inline does not package the worker into a single file; it creates a separate file in the output directory.

So, what exactly is inline doing then?



from What Does worker-loader Inline Do?

No comments:

Post a Comment