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

fix: webpack5 build 模式下没有生成物理缓存 #6335

Merged
merged 3 commits into from
Mar 25, 2021
Merged

fix: webpack5 build 模式下没有生成物理缓存 #6335

merged 3 commits into from
Mar 25, 2021

Conversation

liaoyinglong
Copy link
Contributor

@liaoyinglong liaoyinglong commented Mar 24, 2021

Checklist
  • npm test passes
  • documentation is changed or added
  • tests are included
  • commit message follows commit guidelines
Description of change

@sorrycc
Copy link
Member

sorrycc commented Mar 25, 2021

本地验证过可以吗?

@liaoyinglong
Copy link
Contributor Author

before:

  1. 第一次build 完成
    image
    并且 .umi-production文件夹在完成后被删除了
    image

  2. 第二次build
    还是报找不到cache
    image
    build完成后,时间没什么变化
    image

after:

  1. 第一次build完成后,开启 WEBPACK_FS_CACHE_DEBUG 可以看到提示了保存成功
    image

  2. 第二次build
    可以看到提示读取缓存成功
    image
    耗时
    image

不过有个问题:
在第二次build完成后 .umi-production 文件夹依旧被删除了,
是否不对cache文件夹做更改,使用默认的cachedir ?

@liaoyinglong
Copy link
Contributor Author

liaoyinglong commented Mar 25, 2021

存在问题:

  1. .umi-production文件夹会在build完成后清空
    看上去是这里?
    https://github.com/umijs/umi/blob/master/packages/preset-built-in/src/plugins/commands/build/build.ts#L51
    不对cachedir做修改,使用默认的?

@@ -52,7 +52,7 @@ class Bundler {
console.error(err);
return reject(new Error('build failed'));
}

compiler.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
compiler.close()
// ref: https://github.com/webpack/webpack/issues/12345#issuecomment-755273757
// @ts-ignore
compiler.close();

@sorrycc
Copy link
Member

sorrycc commented Mar 25, 2021

.umi-production 清空的问题我修下。

@sorrycc
Copy link
Member

sorrycc commented Mar 25, 2021

#6341

@liaoyinglong
Copy link
Contributor Author

本地测试通过

@sorrycc
Copy link
Member

sorrycc commented Mar 25, 2021

image

CI 跑不过,undefined,你本地先验证一遍吧。

@liaoyinglong
Copy link
Contributor Author

image
log展示有点不对 不影响

@liaoyinglong
Copy link
Contributor Author

image

CI 跑不过,undefined,你本地先验证一遍吧。

webpack4 5 本地验证都通过了。

@liaoyinglong
Copy link
Contributor Author

4的文档没有看到close方法

或者更改调用方式为 webpack(..., callback)
https://webpack.js.org/migrate/5/#cleanup-the-build-code

@sorrycc
Copy link
Member

sorrycc commented Mar 25, 2021

我加个 ?. 跑跑用例看。

@codecov
Copy link

codecov bot commented Mar 25, 2021

Codecov Report

Merging #6335 (32b7180) into master (508fd0a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6335   +/-   ##
=======================================
  Coverage   84.59%   84.59%           
=======================================
  Files         157      157           
  Lines        3563     3564    +1     
  Branches      974      974           
=======================================
+ Hits         3014     3015    +1     
  Misses        539      539           
  Partials       10       10           
Impacted Files Coverage Δ
packages/bundler-webpack/src/index.ts 37.09% <100.00%> (+1.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 508fd0a...32b7180. Read the comment docs.

@sorrycc sorrycc merged commit ac4fc37 into umijs:master Mar 25, 2021
aquariuslt pushed a commit to aquariuslt/umi that referenced this pull request Mar 27, 2021
* fix: webpack5 build 模式下没有生成物理缓存

see
webpack/webpack#12345 (comment)

Closes umijs#6266

* Update packages/bundler-webpack/src/index.ts

* Update packages/bundler-webpack/src/index.ts

Co-authored-by: chencheng (云谦) <sorrycc@gmail.com>
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.

[Bug] 开启 webpack 5 后,打包物理缓存未生效
2 participants