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

Load unminified JS when SCRIPT_DEBUG is true. #38756

Closed
wants to merge 1 commit into from

Conversation

noahtallen
Copy link
Member

@noahtallen noahtallen commented Feb 11, 2022

Description

Resolves #23960. (Though, I wonder if this will not be possible because of #32621.)

When SCRIPT_DEBUG is true, load index.js build files instead of index.min.js build files.

Testing Instructions

Locally, in wp-env, SCRIPT_DEBUG is true by default. If you have no other overrides, you should see non-minified files in the debug devtools tab when loading the editor.

Then, add this to .wp-env.json or .wp-env.override.json:

	"config": {
		"SCRIPT_DEBUG": false
	}

Then, when loading the editor, you'll see minified files in the debug devtools tab:

Screenshots

Minified files:

Screen Shot 2022-02-11 at 1 53 58 PM

Unminified files:

Screen Shot 2022-02-11 at 1 54 36 PM

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
  • I've updated related schemas if appropriate.

@noahtallen noahtallen requested review from a team, jorgefilipecosta and ntsekouras and removed request for a team February 11, 2022 22:02
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
// We can't replace the glob call above with index.js because the PHP
// asset file is associated with the .min file. (index.min.asset.php).
$path = str_replace( '.min.js', '.js', $path );
Copy link
Contributor

Choose a reason for hiding this comment

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

When running npm run dev we only generate .min.js files, though in reality it's a non minified file. Should we update the npm run dev build step to also include .js files? maybe we can just avoid breakage in this case and always load the non minified versions.

@noahtallen noahtallen closed this Jan 25, 2024
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.

Plugin: Include readable source files
2 participants