Skip to content

Commit

Permalink
Move to Comlink 4
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Jan 10, 2020
1 parent eb767af commit 57b5f48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"webpack": "^4.41.2"
},
"dependencies": {
"comlinkjs": "^2.4.1",
"comlink": "^4.2.0",
"loader-utils": "^1.1.0",
"slash": "^3.0.0",
"worker-loader": "^2.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/comlink-worker-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

export default function rpcWorkerLoader (content) {
return `import {Comlink} from 'comlinkjs';
return `import {expose} from 'comlink';
${content}
for(var $$ in __webpack_exports__)if ($$!='__esModule')Comlink.expose(__webpack_exports__[$$],self)`;
for(var $$ in __webpack_exports__)if ($$!='__esModule')expose(__webpack_exports__[$$],self)`;
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ loader.pitch = function (request) {
}

return `
import {Comlink} from 'comlinkjs';
import {wrap} from 'comlink';
${multi ? '' : 'var inst;'}
export default function f() {
${multi ? 'var inst =' : 'inst = inst ||'} Comlink.proxy(require('!worker-loader?${JSON.stringify(workerLoaderOptions)}!${slash(path.resolve(__dirname, 'comlink-worker-loader.js'))}!${request}')());
${multi ? 'var inst =' : 'inst = inst ||'} wrap(require('!worker-loader?${JSON.stringify(workerLoaderOptions)}!${slash(path.resolve(__dirname, 'comlink-worker-loader.js'))}!${request}')());
return this instanceof f ? new inst : inst;
}
`.replace(/\n\s*/g, '');
Expand Down

0 comments on commit 57b5f48

Please sign in to comment.