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

[bug]if activeFile !== mainFile, mainFile would not compile #224

Open
chenyulun opened this issue Feb 29, 2024 · 3 comments
Open

[bug]if activeFile !== mainFile, mainFile would not compile #224

chenyulun opened this issue Feb 29, 2024 · 3 comments

Comments

@chenyulun
Copy link

chenyulun commented Feb 29, 2024

src/store.ts
if(activeFile.value !== mainFile.value)

// if
const activeFile = ref('app.vue')
const mainFile = ref('appWarp.vue')
  function init() {
    watchEffect(() =>
      compileFile(store, activeFile.value).then( //  not activeFile, sould be mainFile
        (errs) => (errors.value = errs),
      ),
    )
// ...
 for (const [filename, file] of Object.entries(files.value)) {
      if (filename !== mainFile.value) { // no compile mainFile.value
        compileFile(store, file).then((errs) => errors.value.push(...errs))
      }
    }

这种情况下,mainFile的file对象里面的compiled的js,css,ssr都是空的导致渲染不了

@chenyulun
Copy link
Author

如何避免首次聚焦文件非入口文件的,导致入口文件不编译的问题,
或者最后遍历的时候判断条件去掉,或者
if (filename !== mainFile.value || activeFile.value !== mainFile.value)
首次如果入口文件不是聚焦文件,那也需要编译一次

@chenyulun
Copy link
Author

chenyulun commented Mar 1, 2024

by the way:
还有一个创建沙盒的时候,能保证所有文件都编译(异步)完成了吗?虽然速度很快,但是他们之间没有异步的等待, 如果要关联,得在File里面设置状态属性或者函数,读取的时候保证编译成功

还有一个想法就: 把编译动作集成到File类里面,读取compiled的时候再去编译,并且缓存,存在的情况下不再编译,修改后清除编译缓存,页面重新执行渲染的时候再编译,可以避免文件未使用的时候进行多次无意义的编译

这样好像会把很多都变成异步,也不太行

@sxzz
Copy link
Member

sxzz commented May 23, 2024

Could you please provide a minimal reproduction for me? I'll appreciate it.

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

No branches or pull requests

2 participants