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

Taro webpack5 cache enable时的编译问题 #62

Open
tyuan511 opened this issue Aug 19, 2022 · 8 comments
Open

Taro webpack5 cache enable时的编译问题 #62

tyuan511 opened this issue Aug 19, 2022 · 8 comments

Comments

@tyuan511
Copy link

taro3.5.2配置cache: {enable:true},当有缓存存在时,编译会出问题
复现:config/index.js中添加compiler: 'webpack5', cache: {enable:true}配置,运行两次yarn dev:weapp或者yarn build:weapp即可复现
初步来看当cache存在时module?._source?_valueAsString会变成undefined,导致跳过了后续的转换。通过module.originalSource()?.source()好像可以获取到内容

@ItsRyanWu
Copy link
Member

ItsRyanWu commented Aug 21, 2022

请问你具体遇到了什么编译问题?我这边暂时没有发现什么问题。
开启了缓存后 webpack 只会把变动的模块内容传给插件,没变动的就是 undefined 插件则会跳过对这些内容的处理。这么看起来是挺合理的。

@tyuan511
Copy link
Author

开启webapck5和cache,运行build:weapp编译成功后,再次运行build:weapp特殊字符不会被编译

@ItsRyanWu
Copy link
Member

我再次试了 build 模式,发现结果应该是符合期待的。你说的在未更改 UI 代码的情况下再次运行 build 命令插件的确不会再次编译重复的代码但上一次的编译结果也是保留的,而如果你改了某一个 UI 代码文件 webpack 也只会传递给插件已变更的代码来更新对应的编译产物。这个逻辑存在什么问题吗?

@tyuan511
Copy link
Author

tyuan511 commented Aug 22, 2022

辛苦大哥了,可能是我上下文说的不够清楚,下面提供一些复现步骤,希望能有所帮助

复现repo: https://github.com/tyuan511/taro-tailwind-demo
复现步骤:运行两次build:weapp
第二次运行结果异常:
image

第一次运行或删除node_modules/.cache下缓存后 运行结果正常:
image

@kongsiyu
Copy link

kongsiyu commented Sep 5, 2022

同问题,我这边删除node_modules/.cache有时候可以,有事后不行,就算关掉cache也一样不行

@yoyo837
Copy link

yoyo837 commented Sep 15, 2022

那此问题 cache 无关?

@agileago
Copy link

agileago commented Oct 1, 2022

+1 pnpm 也不行

@bluescurry
Copy link

请问这个问题现在有解决方案了吗

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

6 participants