Skip to content

Dependency Extraction Webpack Plugin: prettify dev asset output - #79650

Open
gunjanjaswal wants to merge 6 commits into
WordPress:trunkfrom
gunjanjaswal:fix/48106-prettify-dep-extraction-output
Open

Dependency Extraction Webpack Plugin: prettify dev asset output#79650
gunjanjaswal wants to merge 6 commits into
WordPress:trunkfrom
gunjanjaswal:fix/48106-prettify-dep-extraction-output

Conversation

@gunjanjaswal

@gunjanjaswal gunjanjaswal commented Jun 29, 2026

Copy link
Copy Markdown

Fixes #48106.

Right now the generated PHP asset files (*.asset.php and assets.php) get written all on one line, which makes something like script-loader-packages.php annoying to read or diff while you're working on it. This pretty-prints them on the dev (unminified) build so they're readable and diff cleanly. Production builds don't change, they still get the compact one-liner.

The change lives in stringify(): it looks at optimization.minimize, and when that's false it uses json2php.make( { linebreak: '\n', indent: '\t' } ), otherwise it falls back to the compact json2php printer exactly like before. The minify flag comes down from addAssets(), which reads it off compilation.options.optimization.minimize.

To check it, run npm run test:unit packages/dependency-extraction-webpack-plugin, or just build a package in dev mode and open one of the generated *.asset.php files. It's spread over a few indented lines now, and a production build collapses it back to one line.

Use of AI Tools

This PR was written with AI assistance (Claude Code). I reviewed, tested, and understand every change, and I take responsibility for it.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @derekhassan, @xerpa43, @mattyrob.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: derekhassan, xerpa43, mattyrob.

Co-authored-by: gunjanjaswal <gunjanjaswal@git.wordpress.org>
Co-authored-by: tommusrhodus <tommusrhodus@git.wordpress.org>
Co-authored-by: georgestephanis <georgestephanis@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 29, 2026
@github-actions

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @gunjanjaswal! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

Pretty-print PHP asset files (.asset.php / assets.php) with line breaks
and indentation for unminified development builds, making the generated
files human-readable. Minified production output is kept compact.

The output format is keyed off `optimization.minimize`: when it is
explicitly `false`, `stringify()` uses `json2php.make()` with linebreak
and indent options; otherwise the compact printer is used as before.

Adds unit tests for the compact/pretty branches and updates the build
snapshots, which run with `minimize: false`.

Fixes WordPress#48106.
@gunjanjaswal
gunjanjaswal force-pushed the fix/48106-prettify-dep-extraction-output branch from 5490a61 to e882b04 Compare June 29, 2026 19:19
…-dep-extraction-output

# Conflicts:
#	packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
…-dep-extraction-output

# Conflicts:
#	packages/dependency-extraction-webpack-plugin/CHANGELOG.md
…-dep-extraction-output

# Conflicts:
#	packages/dependency-extraction-webpack-plugin/CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependency Extraction Webpack Plugin: Prettify the output of the development asset files

1 participant