#45535 closed defect (bug) (fixed)
Unminified react and react-dom
Reported by: | emilushi | Owned by: | ocean90 |
---|---|---|---|
Milestone: | 5.0.3 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Script Loader | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
Even if you define SCRIPT_DEBUG
to true
React and React-Dom are loaded minified and based on my inspection that is caused $dev_suffix
on line 79 of wp-includes/script-loader.php
.
The wp_scripts_get_suffix()
will always return .min
if passed arguments is equal to dev
. As seen on line 757 of wp-includes/script-loader.php
the wp_scripts_get_suffix()
is setting $develop_src
to false
if $wp_version
doesn't contain string -src
for which I don't know why $wp_version
will have to contain that string.
I wanted to fix it but I din't understand this part: $develop_src = false !== strpos( $wp_version, '-src' )
, why $develop_src
is depended on $wp_version
.
Personally I think it should be depended on SCRIPT_DEBUG
constant.
Attachments (1)
Change History (12)
#2
in reply to:
↑ 1
@
6 years ago
Thanks for the information.
I now understand it clear, then it means is needed to add another condition for cases when using stable release with SCRIPT_DEBUG
to true
Replying to afercia:
@emilushi that line of code is meant for the development trunk version, where the version is always identified with a
-src
suffix. For example:
$wp_version = '5.1-alpha-43677-src'
Instead, stable versions have just the version number:
$wp_version = '4.9.8';
This is intentional so that the trunk version always uses the non minified files.
This ticket was mentioned in Slack in #core-js by earnjam. View the logs.
6 years ago
#4
@
6 years ago
- Keywords needs-patch removed
So it's not clear to me what the determination is between when to use $suffix
vs $dev_suffix
on any given script, however in 45535.diff I simply switched to following the normal use of $suffix
, which allows it to check SCRIPT_DEBUG
value first and then falls back to checking for -src
in the WP version.
This is particularly helpful when developing with React, which otherwise shows minified errors and requires you to click to visit reactjs.org for the full error messages.
I'm not sure why we don't just honor SCRIPT_DEBUG
and then fall back to -src
for all scripts. It appears this change was first introduced in [27170], but I couldn't find any discussion around why and it seems scripts included in core are split between the two suffix options to follow.
#5
@
6 years ago
I ran into this today as well. We should absolutely respect SCRIPT_DEBUG
with this otherwise the developer experience of creating new blocks for the editor is horrible.
I've worked around it for now with this mu-plugin https://gist.github.com/roborourke/887ccc6a8070cb7dbd69b897bee6af7f
Would love to see this resolved in core!
#6
@
6 years ago
This should be fixed because:
- Core breaks with a convention established by the Gutenberg plugin, see lib/client-assets.php.
- Whether a script is minified or not doesn't change its functionality. But React has a production version and a development version, which differ a lot. And the production version does not have any debugging helpers in it, which makes block development in Core impossible.
This ticket was mentioned in Slack in #core-js by earnjam. View the logs.
6 years ago
#8
@
6 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.0.3
- Owner set to ocean90
- Status changed from new to reviewing
@emilushi that line of code is meant for the development trunk version, where the version is always identified with a
-src
suffix. For example:$wp_version = '5.1-alpha-43677-src'
Instead, stable versions have just the version number:
$wp_version = '4.9.8';
This is intentional so that the trunk version always uses the non minified files.