Skip to content

Conversation

@snickell
Copy link
Contributor

@snickell snickell commented Nov 6, 2025

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Tests added? no
Docs updated? no
Fixed tickets #246
License MIT

As per #246, grunt-webpack has been observed to not work with webpack 5 filesystem caching. This is a result of not calling (and waiting for) compiler.close(callback). Webpack defaults to waiting until idle to flush its cache to the filesystem, so this does not impact dev/watch mode, but with compiler.run() you exit before hitting idle, and thus, never write the filesystem cache (bug!).

Details of PR

This PR modifies a few more lines than might be expected because we have to handles change in async flow control. I tried to keep the diff very short and easy to compare to before for easy verification of same-behavior.

This is a standard webpack 5 migration issue that grunt-webpack still needs

The need to invoke compiler.close() is specified in the webpack 5 migration guide:
image

Additionally you can find a resolved issue on the webpack issue tracker containing the same advice to remedy the same problem: webpack/webpack#12342 (comment)

Verification of PR

This has been tested and fixes outputting webpack cache data to the filesystem in code.org's fairly large webpack config.

Using this PR combined with a webpack.config.js with cache: { type: 'filesystem' } results in webpack cache being output to disk, whereas before this PR the build succeeds but no cache is written to disk.

Fixes: #246

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 6, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

@danez
Copy link
Collaborator

danez commented Nov 6, 2025

Nice find, can you ensure the code is formatted with prettier. pnpm run lint --fix. An also fix the lint warnings.

@danez
Copy link
Collaborator

danez commented Nov 25, 2025

Thanks again, I wasn't able to push to your branch, so I created a new branch with your changes.

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.

Webpack incremental build does not work

3 participants