NativeScript / worker-loader

36 stars 20 forks source link

download worker script from other domain (cdn) #42

Open raronen opened 5 years ago

raronen commented 5 years ago

Hi,

I want to download my worker scripts from CDN, it means that __webpack_public_path__ = "https://amlogsextension-int.azureedge.net/" for e.g.

This isn't possible at the moment sense rootis hardcoded with ./ in the following code inside worker-loader/src/index.js.

`const getPublicPath = file => {
    const root = JSON.stringify("./");
    const filePath = JSON.stringify(file);

    return `${root} + __webpack_public_path__ + ${filePath}`;
};`

The problem that now getPublicPath returns the following string: "https://domain1/https://domain2/file.js"

It would be great if there'll be a ?customRoot option or something like that in the loader and then change the root initialization to const root = customRoot ? "" : JSON.stringify("./ + ");

I'll be happy to send a PR but I see I'm not authorized.

raronen commented 5 years ago

Not possible: from here You are limited by the same origin policy i.e. the worker script must be served from the same domain (including the protocol) as the script that is creating the worker