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?] Infinite compilation loop #14

Open
colinaaa opened this issue Dec 25, 2024 · 4 comments
Open

[Bug?] Infinite compilation loop #14

colinaaa opened this issue Dec 25, 2024 · 4 comments

Comments

@colinaaa
Copy link

Versions

  System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 9.84 GB / 96.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  npmPackages:
    @rsbuild/core: ^1.1.8 => 1.1.12 
    @rsbuild/plugin-type-check: ^1.2.0 => 1.2.0 
    typescript: ^5.7.2 => 5.7.2

Details

When using

  1. pluginTypeCheck
  2. dev.writeToDisk: true
  3. No include and exclude in tsconfig.json

The rsbuild dev would cause infinite compilation loop.

Reproduce link

https://github.com/colinaaa-reproductions/rsbuild-repro-plugin-type-check-infinite-loop

Reproduce steps

  1. pnpm install
  2. pnpm dev
  3. Edit src/index.ts with meaningful changes
  4. See result:
    [webpack-dev-middleware] Compilation starting...
start   Building...
    [TsCheckerRspackPlugin] Calling reporter service for incremental check.
      Changed files: ["/Users/colin/rsbuild-project/dist/index.e9b4c8b1da18b60c.hot-update.js"]
      Deleted files: []
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.html"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/css/index.css"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js.map"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.bb731faf2c72ad50.hot-update.js"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.bb731faf2c72ad50.hot-update.json"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js"
ready   Built in 0.01 s (web)
    [webpack-dev-middleware] Compilation finished
    [webpack-dev-middleware] Compilation starting...
start   Building...
    [TsCheckerRspackPlugin] Calling reporter service for incremental check.
      Changed files: ["/Users/colin/rsbuild-project/dist/index.bb731faf2c72ad50.hot-update.js"]
      Deleted files: []
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.html"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/css/index.css"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js.map"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.08aa15561e74d2f7.hot-update.js"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.08aa15561e74d2f7.hot-update.json"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js"
ready   Built in 0.01 s (web)
    [webpack-dev-middleware] Compilation finished
    [webpack-dev-middleware] Compilation starting...
start   Building...
    [TsCheckerRspackPlugin] Calling reporter service for incremental check.
      Changed files: ["/Users/colin/rsbuild-project/dist/index.08aa15561e74d2f7.hot-update.js"]
      Deleted files: []
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.html"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/css/index.css"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js.map"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.84ac0575577b37df.hot-update.json"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/index.84ac0575577b37df.hot-update.js"
    [webpack-dev-middleware] Child "web": Asset written to disk: "/Users/colin/rsbuild-project/dist/static/js/index.js"
ready   Built in 0.01 s (web)
    [webpack-dev-middleware] Compilation finished
@colinaaa
Copy link
Author

Currently, I have two workarounds:

  1. Add exclude: ["dist"] in tsconfig.json
  2. Add dist to tools.rspack.watchOptions.ignore

@chenjiahan
Copy link
Member

I think a valid tsconfig.json must contain files or include fields. Without these two fields, tsc should not work properly.

@colinaaa
Copy link
Author

Looks like TypeScript will include everything if no include/files is specified.

I'm fine with using include/exlucde in tsconfig.json. I just wonder if we could exclude output.distPath.root in watchOptions.ignored if dev.writeToDist is enabled?

BTW, feel free to close this issue. I just want to make a reference to those facing the same problem :)

@chenjiahan
Copy link
Member

Let's leave this issue open. Maybe we will find better defaults in the future.

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