worker-plugin

编程之家收集整理的这个编程导航主要介绍了worker-plugin编程之家,现在分享给大家,也给大家做个参考。

worker-plugin

worker-plugin 介绍

特征

自动编译Web Worker中加载的模块:

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

^^^^^^^^^^

gets bundled using webpack

安装

npm install -D worker-plugin

webpack.config.js配置

+ const WorkerPlugin = require('worker-plugin');

module.exports = {

<...>

plugins: [

+ new WorkerPlugin()

]

<...>

}

使用

worker.js: (our worker module)

// This is a module worker,so we can use imports (in the browser too!)

import { calculatePi } from './some-other-module';

addEventListener('message',event => {

postMessage(calculatePi(event.data));

});

main.js: (our demo,on the main thread)

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

piWorker.onmessage = event => {

console.log('pi: ' + event.data);

};

piWorker.postMessage(42);

网站地址:https://npm.im/worker-plugin

GitHub:https://github.com/GoogleChromeLabs/worker-plugin

网站描述:向Webpack添加本机Web Worker捆绑支持

worker-plugin官方网站

官方网站:https://npm.im/worker-plugin

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

jade,Jade 是一个高性能的模板引擎,以 JavaScript 的形式集...
curl.js,轻量级,快速,可扩展的模块加载
jspm-cli,基于SystemJS的Js包管理器
angular-cli,快速构建Angular2项目
lerna,一款多项目多模块的管理工具
duo.js,前端的下一代包管理器。