Skip to content

fix: clean the files writeToDisk writes when output.clean is set - #2497

Merged
alexander-akait merged 18 commits into
mainfrom
fix/output-clean-write-to-disk
Nov 20, 2026
Merged

alexander-akait merged 18 commits into
mainfrom
fix/output-clean-write-to-disk

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes #861.

What I checked on main first. One project per run: output.clean: true, filename: "main.[contenthash].js", and a stale file left in dist/ from a "previous session". Each run did a first build, then a source change and a rebuild:

writeToDisk: true writeToDisk: (path) => …
standalone wdm(compiler, options) clean stale file kept; each rebuild adds a main.*.js
plugin wdm(compiler, options, true), host owns compiler.watch() (as with webpack-dev-server) clean the same: never cleaned

With a function, webpack writes to memory and cleans only memory, while assetEmitted copies each asset to disk, so nothing on disk is ever removed. No hook fixes that: CleanPlugin removes through compiler.outputFileSystem and nothing else. With writeToDisk: true and a file system of your own, set on the compiler or given in outputFileSystem, nothing was written to disk at all.

Fix. No webpack change is needed. Unless the served file system is the disk itself, the compiler is given a two-way file system on top of it:

  • writes (writeFile, symlink, chmod, utimes) go to the served file system, then to disk for the paths writeToDisk takes, through one mirror;
  • unlink and rmdir remove from both;
  • readdir lists both, and lstat falls back to the disk;
  • stat, readFile and readlink stay on the served side, so webpack's emit still decides what to write from it alone.

So webpack's own output.clean cleans the disk too, with clean.keep, the keep hook, clean.dry and the hot update grace period. The assetEmitted hook is gone. This works in plugin and standalone mode, for multi-compilers, on every webpack 5 version and on Rspack (checked with 5.112 and @rspack/core 2.3.2). compiler.outputFileSystem is set once, and only NodeEnvironmentPlugin assigns it in webpack, before any plugin, so nothing replaces it later.

The disk itself is Node.js fs (Rspack's default) or graceful-fs (webpack's default). It is given as it is, so nothing is written or removed twice. A file system of your own may lack the methods webpack can do without (lstat, readlink, symlink, chmod, utimes, unlink, rmdir, readdir): those are added only where it has them, and the disk is still written and cleaned.

One case output.clean cannot see: a copy on disk, left by an earlier session, of a file the function now leaves out. webpack counts it as current, so it is removed when written, unless output.clean would keep it: the keep hook first, then clean.keep (a string, RegExp or function; a glob keeps it, as webpack does not expose its matcher), or clean.dry.

One gap is webpack's, not this PR's: on webpack 5.112 CleanPlugin does not strip ?query/#hash from asset names, so lazy.js?[contenthash] is not cleaned once gone, with or without the middleware. That is fixed on webpack main by webpack/webpack#23219.

Next major. As // TODO comments in src/index.js: remove the standalone mode in favor of the plugin mode.

Tests, in test/write-to-disk-clean.test.js, against real directories, in both standalone and plugin mode (84 tests):

  • writeToDisk: true and a function: stale files removed on the first build, the previous bundle on a rebuild; clean.keep, clean.dry, no output.clean;
  • copy-webpack-plugin and output.copy: copied files written, changed, and cleaned once removed; filtered-out ones kept off disk; symlinks, file modes and times kept;
  • a file system of your own, on the compiler and in outputFileSystem:
    • what is written, served (over HTTP) and cleaned on each side, across rebuilds;
    • stale files left in it and on disk, without copying one to the other;
    • clean.keep (each form), the keep hook and clean.dry on both sides;
    • Node.js fs and webpack's own file system given as they are;
    • one lacking the optional methods, and one that cannot list or remove files;
    • a multi-compiler, and the build failing when either side cannot be written.

Against main's src/index.js, the new behavior fails and the rest guard what already worked; every line the PR adds is covered. The full suite has 7556 passed. The 2 failures are the writeToDisk EACCES logging cases, which fail on main too when run as root. npm run lint passes. webpack-dev-server's write-to-disk-clean e2e test passes against this branch as a server of its own and as a plugin. README and patch changeset are updated.


Generated by Claude Code

alexander-akait and others added 2 commits October 27, 2026 13:10
With writeToDisk as a function, webpack writes to memory and cleans only
that, while the middleware copies assets to disk, so the disk was never
cleaned. webpack's CleanPlugin is now applied a second time to a view of
the compiler whose outputFileSystem is the real one, in standalone and
plugin mode. writeToDisk: true already worked: the real file system is
the output file system then.

Also notes, as TODOs, that the standalone (non-plugin) mode goes in the
next major release.

Closes #861

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8709d95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-dev-middleware Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

When disk files are written, the middleware now applies webpack’s CleanPlugin to the real filesystem if output.clean is configured and supported. Disk-writing hooks also run for writeToDisk: true when a custom output filesystem is configured. Tests cover standalone and plugin modes, rebuilds, clean.keep, clean.dry, copied assets, and configurations without output.clean or CleanPlugin. The README and changeset describe these behaviors.

Severity of issue fixed: Medium

Merge Risk: Low · previous review 05e22

Common cleanup paths appear mergeable, but builds using query- or hash-suffixed asset names can leave stale files on disk. Normalize those names before cleaning or accept this bounded limitation.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: cleaning files written by writeToDisk when output.clean is enabled.
Linked Issues check Passed Issue #861 requires output.clean to remove stale disk files on the initial build and after rebuilds. src/index.js applies webpack CleanPlugin to the real filesystem for function-valued `writeToD…
Out of Scope Changes check Passed The changes remain connected to issue #861. Runtime changes implement disk cleanup and disk copying. Tests cover required behavior and related asset-copy and asset-filter cases. The development depend…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Linked Issues check

Explanation

Issue #861 requires output.clean to remove stale disk files on the initial build and after rebuilds. src/index.js applies webpack CleanPlugin to the real filesystem for function-valued writeToDisk and copies assets when a custom outputFileSystem is used. test/write-to-disk-clean.test.js verifies initial cleanup and rebuild cleanup in standalone and plugin modes. The tests also verify clean.keep, clean.dry, and the no-clean case.

Full details: Out of Scope Changes check

Explanation

The changes remain connected to issue #861. Runtime changes implement disk cleanup and disk copying. Tests cover required behavior and related asset-copy and asset-filter cases. The development dependency supports those tests. The README and changeset document the behavior. No unrelated runtime change is established.

Finishing Touches

🧪 Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 756a672b-3d70-4afb-bf0a-3ed4556d6014
Commits

Reviewing files that changed from the base of the PR and between 7c28912 and 52bed0b.

Files selected for processing: 4
  • .changeset/write-to-disk-output-clean.md
  • README.md
  • src/index.js
  • test/write-to-disk-clean.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread test/write-to-disk-clean.test.js Resolved
writeToDisk: true made the real file system webpack's output only when
no outputFileSystem was given; with one, it stayed webpack's and nothing
was written to disk at all. Copy assets to disk then too, as a function
does, and clean them with output.clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

Probing the rest of output.clean with writeToDisk turned up one more bug, fixed in d5c16a9.

writeToDisk: true with a custom outputFileSystem wrote nothing to disk. true makes the real fs webpack's output only when no outputFileSystem is given. With one, that fs stays webpack's (as the README says), but nothing copied assets to disk, so dist/ never got the bundle. It is now copied, as with a function, and cleaned with output.clean. A test covers both modes; it fails on the previous commit.

Checked and already correct:

  • Memory only (no writeToDisk): the previous hashed bundle is removed from memory on rebuild, so it isn't served.
  • Multi-compiler with a function: each compiler's output directory is cleaned on its own.
  • webpack-dev-server end to end, with devMiddleware: { writeToDisk: (p) => p.endsWith(".js") } and output.clean: true. With the released middleware, dist/ keeps stale.js and gains a bundle per rebuild. With this branch, it holds one bundle.

No webpack change is needed: CleanPlugin reads compiler.outputFileSystem at emit time, so it can be applied to a view of the compiler with the real fs. The tests here would catch it if that changed.

test/write-to-disk-clean.test.js passes 12/12, and the unit suite has 7484 passed (the same 2 root-only EACCES cases fail on main). npm run lint passes.


Generated by Claude Code

Dirent#parentPath arrived in Node.js 20.12; this package supports 20.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Preserve Rspack compatibility when enabling disk cleaning. · index.js:612

src/index.js:612
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Preserve Rspack compatibility when enabling disk cleaning.

If a Rspack compiler uses output.clean with function-valued writeToDisk, this call attempts to construct compiler.webpack.CleanPlugin. Rspack does not expose that plugin, so middleware setup throws before watching starts. Use a supported cleaning path for Rspack, or handle that compiler explicitly. (rspack.dev)


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1561cb90-81f9-4f94-93d4-1970636cca32
Commits

Reviewing files that changed from the base of the PR and between 52bed0b and a2a28e9.

Files selected for processing: 4
  • .changeset/write-to-disk-output-clean.md
  • README.md
  • src/index.js
  • test/write-to-disk-clean.test.js
Files skipped from review as they are similar to previous changes: 1
  • .changeset/write-to-disk-output-clean.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Comment thread README.md Resolved
Copied files reach the disk beside the bundle, survive rebuilds, are
copied again when changed and cleaned once no longer copied, with
writeToDisk true and a function, in standalone and plugin mode; a filter
leaving them off disk still serves them from memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

Added copy-webpack-plugin coverage (c0fe374, copy-webpack-plugin as a devDependency). It runs in standalone and plugin mode, with writeToDisk set to true and to a function:

  • Copied files are written to disk next to the bundle, and the stale files are cleaned.
  • A rebuild of the bundle keeps the copied files.
  • A changed source file is copied again.
  • A file that is no longer copied is cleaned from disk.
  • A filter that writes only .js leaves copied files off disk, and they are still served from memory.

On main, the cases with a function writeToDisk fail, while the true cases pass because webpack cleans the disk itself there.


Generated by Claude Code

@socket-security

socket-security Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcopy-webpack-plugin@​14.0.09910010084100

View full report

Rspack cleans natively and exposes no CleanPlugin to apply again, so the
middleware failed to start there with output.clean and a writeToDisk
function; it now writes to disk without cleaning, as before. Also fix the
writeToDisk anchor in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

Re the Rspack finding outside the diff (src/index.js:612): you're right. Rspack has no JS CleanPlugin to construct, so setup threw with output.clean and a function writeToDisk. And even with such a plugin, a native plugin would not honor the Object.create view of the compiler that overrides outputFileSystem.

Fixed in 904f558. cleanDiskForWriteToDisk now returns early when the compiler is Rspack ("rspack" in compiler) or has no compiler.webpack.CleanPlugin function. The middleware then writes to disk as it did before this PR, without cleaning disk, and starts normally. A new test covers this in standalone and plugin mode by removing CleanPlugin from the compiler. 20/20 pass, and lint and types are clean.


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Clean disk copies against the assets selected by writeToDisk. · index.js:622-624

src/index.js:622-624
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Clean disk copies against the assets selected by writeToDisk.

If dist/robots.txt exists from an earlier run, and the current build emits robots.txt with a .js-only writeToDisk predicate, the predicate skips the copy. The disk CleanPlugin still sees robots.txt in compilation.assets and keeps the old disk file. This leaves an excluded asset on disk despite output.clean. Give the disk cleaner the filtered asset set without changing the compilation seen by webpack’s normal cleaner. (raw.githubusercontent.com)


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f94f076b-01e3-4d77-9904-82c33ec8d38a
Commits

Reviewing files that changed from the base of the PR and between c0fe374 and 904f558.

Files selected for processing: 3
  • README.md
  • src/index.js
  • test/write-to-disk-clean.test.js
Files skipped from review as they are similar to previous changes: 1
  • README.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

The disk cleaner saw every asset of the build, so a file the function
skips was kept on disk from an earlier session despite output.clean. It
now sees only the assets the function writes, while webpack's own cleaner
still sees them all, and other plugins' keep hook still applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

Re the finding outside the diff (src/index.js:622-624, cleaning against the assets writeToDisk selects): you're right. Fixed in 05e2215.

The disk CleanPlugin used to see every asset in compilation.assets. So a stale dist/robots.txt stayed on disk when the function skipped it. Now the disk cleaner's emit tap receives a view of the compilation (Object.create(compilation, { assets })) with only the assets the function writes. webpack's own cleaner still gets the real compilation with every asset, so the in-memory output is unchanged.

The view's keep hook calls through to the real compilation's keep hook, so other plugins' keep rules still apply on disk. With writeToDisk: true and a custom outputFileSystem nothing is filtered.

The copy-webpack-plugin .js-only filter test now starts with an old dist/robots.txt and expects it removed from disk while still being served from memory. It fails on the previous commit and passes now in both modes: 20/20 for the file, and the full suite passes apart from 2 tests that fail only when run as root. Lint and types are clean.


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eed3cbd6-c8ed-4d5d-a5a4-12dbd0465060
Commits

Reviewing files that changed from the base of the PR and between 904f558 and 05e2215.

Files selected for processing: 2
  • src/index.js
  • test/write-to-disk-clean.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Comment thread src/index.js Resolved
alexander-akait and others added 2 commits October 27, 2026 14:08
webpack writes `lazy.js?[contenthash]` as `lazy.js`, but the disk
cleaner filtered and tracked the name with the query, so the filter saw
the wrong path and the file stayed on disk once the asset was gone. Strip
the query or hash as webpack does before filtering and cleaning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
On macOS the watcher may run one more build for the files the test wrote
before it started; the rebuild helper took that build's done for the one
after the change. Wait for a build started after the change instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

alexander-akait commented Oct 27, 2026 •

Copy link
Copy Markdown
Member Author

Test - macos-latest - Node v25.x, Webpack latest failed on 05e2215. The failing test was in plugin mode › cleans the disk on the first build and on a rebuild with "writeToDisk" a function: the bundle hash after the rebuild was the same as before. It was the only failing test in that job (7493 passed).

The cause is in the test, not the fix. On macOS the watcher can start one more build for the files the test wrote just before watching began, and the rebuild helper resolved on that build's done instead of the one triggered by the change.

Fixed in 8ad3c99: rebuild now waits for a done whose stats.startTime is after the change. The file passes 22/22 locally across repeated runs.


Generated by Claude Code

Replace the disk cleaner, which applied CleanPlugin again to views of the
compiler and compilation, with webpack's own support for more outputs:
where compiler.hooks.additionalOutputs exists, writeToDisk adds the disk
as one, so webpack writes links, permissions, times and query-named
assets there as to its own output, and output.clean cleans it too. With
an older webpack or Rspack the middleware copies to disk as before.

Cover output.copy beside copy-webpack-plugin, and a copied link and its
permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

Reworked in 5ff497e. The disk cleaner no longer re-applies CleanPlugin to fake compiler and compilation objects. Instead it uses a new webpack hook, compiler.hooks.additionalOutputs (webpack/webpack#22950).

  • With a webpack that has the hook, writeToDisk adds the real disk as an additional output, with the function as its test. webpack writes the files there as it writes its own output, including links, permissions, times and ?query names. output.clean then cleans the disk with only the files written there.
  • With an older webpack or Rspack, the middleware copies to disk as before, without cleaning. cleanDiskForWriteToDisk and its compiler/compilation views are gone.
  • output.copy is covered next to copy-webpack-plugin. A new test checks that a copied link and its permissions reach disk; it skips on Windows.

The clean tests run where the installed webpack has the hook. Against webpack/webpack#22950 linked locally, 28/28 pass in both modes and the full suite passes, apart from 2 tests that fail only when run as root. With webpack 5.112.0 (the current devDependency) they skip, and a fallback test checks today's behavior instead.

Once a webpack release carries the hook, the devDependency should be bumped so CI runs the clean tests.


Generated by Claude Code

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.14%. Comparing base (7c28912) to head (8709d95).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2497      +/-   ##
==========================================
+ Coverage   97.07%   97.14%   +0.06%     
==========================================
  Files          25       25              
  Lines        2704     2767      +63     
==========================================
+ Hits         2625     2688      +63     
  Misses         79       79              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Give the compiler that hook, so what writeToDisk adds there is checked
where the installed webpack has none yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Copy link
Copy Markdown
Member Author

codecov/project is red on b38df13: 96.90% vs 97.07% on main. codecov/patch passes ("All modified and coverable lines are covered"), and every test job is green.

Codecov reports 5 lines that main covered and this PR no longer does, outside the diff. I couldn't find them:

  • Full-suite coverage of src/ and client-src/ on main and on this branch, with the repo's Jest config, as root and as a non-root user, misses the same statements in every file. src/index.js only gains its 13 new, covered lines.
  • This PR adds tests and a new test file and removes none of main's tests, so it shouldn't make any earlier line uncovered.
  • From this environment I can't reach Codecov's line report or download the CI coverage artifacts to see which lines it means.

So I'm not pushing a speculative change for it. If someone can open the Codecov "Indirect changes" view for this PR, the 5 lines it lists would show whether the drop is real (for example an OS-only path) or variance between CI runs.


Generated by Claude Code

Replace the webpack hook with a file system given to the compiler that
writes to memory and, for the paths `writeToDisk` takes, to disk, removes
files from both and lists both, so `output.clean` cleans the disk on every
webpack 5 version and on Rspack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
A build restarted for a change keeps the startTime it began with, so it
could be taken for the build before the change and never awaited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
alexander-akait and others added 5 commits November 13, 2026 17:36
Write to disk with `writeToDisk: true` when the compiler has a file system
of its own, not only one given in `outputFileSystem`. Give a file system
that is the disk itself, Node.js `fs` or webpack's `graceful-fs`, as it is,
so nothing is written or removed twice, and keep the methods webpack does
without, such as `symlink`, only where the file system has them.

Test both modes with a file system of your own on the compiler and in
`outputFileSystem`: what is written, served and cleaned on each side,
`clean.keep` and `clean.dry`, one lacking optional methods, and a
multi-compiler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
memfs lists recursively with the full path on Windows, so the files were
looked up under the output directory twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
Cover keeping a filtered-out file's earlier copy on disk with each form of
`clean.keep` and with `clean.dry`, a multi-compiler where a path is outside
one compiler's output, copied file times, and the build failing when the
served file system or the disk cannot be written. Say why a glob
`clean.keep` keeps such a copy rather than leave that branch unexplained.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
Repeat every write on disk through one `mirror` instead of a wrapper per
method, and remove from both and list both in a few lines. Ask the `keep`
hook of `CleanPlugin` too before removing a disk copy of a file
`writeToDisk` leaves out, as `output.clean` does, with `clean.keep` where
the compiler's `CleanPlugin` has no hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
@alexander-akait
alexander-akait merged commit de67b7b into main Nov 20, 2026
24 checks passed
@alexander-akait
alexander-akait deleted the fix/output-clean-write-to-disk branch November 20, 2026 18:14
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.

output.clean : true is not working with dev server

1 participant