Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite build with worker format with es notice #948

Closed
wants to merge 1 commit into from

Conversation

AlreadyM
Copy link

添加使用vite进行打包时遇到worker文件内报错解决提示,
原因为在默认iief模式下,worker子文件内会被加入document.style.......然后,worker环境内没有该对象,导致脚本不能正常运行。现阶找寻到的解决方案是将worker格式从默认iief变更为es。

添加使用vite进行打包时遇到worker文件内报错解决提示,
原因为在默认iief模式下,worker子文件内会被加入document.style.......然后,worker环境内没有该对象,导致脚本不能正常运行。现阶找寻到的解决方案是将worker格式从默认iief变更为es。
Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cn-vitejs-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2024 0:36am

@AlreadyM
Copy link
Author

记忆有误,原始内容为:
var $a = document.createElement("style");
$a.textContent = `@charset "UTF-8";....................单行后续很多内容
document.head.appendChild($a);
问题就来自于这个变量的声明,不能在worker内正常执行。

@AlreadyM
Copy link
Author

附加
导入模式为:const worker = new Worker(new URL('./worker.js', import.meta.url)),故仅在该模式下添加提示语句。

@ShenQingchuan
Copy link
Member

很感激您这边根据自己的踩坑经验想要为文档进行贡献。
但是很抱歉,我们不能合并你的 PR。中文文档目前的目标是与英文原文档内容保持一致,目的是保持英文文档为唯一可信源(Single source of truth),如果你认为在 Vite 使用方式上有值得讨论的地方,可以去往 Vite 主仓库的 docs 内进行 PR,添加也应该需要经过一番讨论。

若您的意见和想要添加的内容最终被官方主仓库接收,那么之后会自动同步英文原文内容到中文,我们这边也将对应的给出翻译。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants