Is there an easy method to use a SharedWorker?

Using a shared worker requires passing a url to SharedWorker

Is there a way to get vuejs to bundle arbitrary javascript files and then link to their output?

The following code does not bundle worker.js, it doesn’t even copy the file into the dist directory. The contents of worker.js is identical to the example code from js-ipfs.

import IPFSClient from "ipfs-message-port-client"

const plugin = {
  install (Vue) {
    const worker = new SharedWorker('./worker.js', { type: 'module' })
    const ipfs = IPFSClient.from(worker.port)
    window.ipfsNode = ipfs // for debugging object
    Vue.config.globalProperties.$ipfs = ipfs

// Auto-install
if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use (plugin)

export default plugin