2

dexie.js 求助

 1 year ago
source link: https://www.v2ex.com/t/884322
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

dexie.js 求助

  subframe75361 · 8 小时 1 分钟前 · 639 次点击

我尝试使用 vite+dexie ,想在 webworker 使用 dexie 防止阻塞主线程,dev 时可以正常跑,build 时就会循环编译,不知道有没有大佬能帮帮我...🥲

reproduce gif

import Dexie from 'dexie'
import dbWorker from './worker?worker'

export const db = new Dexie('test')
db.version(1).stores({
  test: '++id, test'
})
const worker = new dbWorker()
export function test(data: string) {
  worker.postMessage(data)
}
  • worker
import { db } from './index'
self.addEventListener('message', event => {
  console.log(db)
})

复现: https://github.com/subframe7536/issue-dexie


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK