结合browserify和WebWorker(Combine browserify and WebWorker)

编程入门 行业动态 更新时间:2024-10-27 07:26:55
结合browserify和WebWorker(Combine browserify and WebWorker)

我正在使用browserify打包我的应用程序并使用js文件作为模块。

现在我想使用webworker在后台上传一个非常大的文件。

我遇到的问题是要为这个工人创建指令

new Worker('./worker.js')

必须收到js文件的名称。 这样该文件不能成为模块。 我认为这使得我的应用程序变得更加复杂,因为现在我必须结合使用js文件的两种方式。

另一方面,我也有兴趣从这个worker访问browserify模块。

所以问题是,将browserify和Web worker一起使用的最佳方法是什么?

I'm using browserify to pack my app and use js files as modules.

Now I want to use a webworker to upload a very big file on the background.

The problem I have is that to create this worker the instruction

new Worker('./worker.js')

must receive the name of a js file. So that this file cannot be a module. I think that this makes my app much more complicated, because now I have to combine two ways of using js files.

On the other hand, I'm interested in accessing a browserify module from this worker too.

So the question is, Which is the best way of using browserify and web workers together?

最满意答案

您可以使用webworkify来处理此问题

You can use webworkify to handle this

更多推荐

本文发布于:2023-07-05 08:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035444.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:browserify   WebWorker   Combine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!