GoogleChromeLabs / worker-plugin

👩‍🏭 Adds native Web Worker bundling support to Webpack.
https://npm.im/worker-plugin
Apache License 2.0
1.91k stars 79 forks source link

Failed to load module script #81

Closed alexroldan closed 4 years ago

alexroldan commented 4 years ago

I've got this error. It is either a bug or am I missing some configuration not documented. I feel, it has something to do with webpack.

Failed to load module script: The server responded with a non-JavaScript, CSS MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

I'm using vue.config.js ... and here is my configuration.

configureWebpack: {
    output: {
        globalObject: "this",
    },
    plugins: [
        new WorkerPlugin({
            globalObject: "self",
            preserveTypeModule: true,
            //workerType: 'foo'
        }),
    ],
},
alexroldan commented 4 years ago

upon exploring and researching more ... I manage to make it work ... In vuejs, there is the @ sign that correspond to the src url of the file ... @Sign tells webpack to add it as its resources ....

const worker= new Worker("@/workers.js", { type: "module" });