WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 3 months ago

Last modified 3 months ago

#52689 closed defect (bug) (fixed)

Error with `npm run build` as `verify:source-maps` task runs in `build/wp-content`

Reported by: afragen Owned by: desrosj
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Apparently since r50441 there are new assertions that run after the build is finished. https://wordpress.slack.com/archives/C02RQBWTW/p1614633511079100

This results in an error and script aborting depending upon the contents of build/wp-content this can be in any of the subfolders. In my case I have a number of inactive plugins in build/wp-content/plugins.

It would seem skipping some of these tests in build/wp-content would be a solution.

Pinging @johnbillion and @desrosj

Change History (10)

#1 @desrosj
7 months ago

  • Milestone changed from Awaiting Review to 5.8

#2 @johnbillion
7 months ago

What gets skipped should technically match what's in .gitignore I think. No this is not true because that would defeat the point of scanning the build dir.

I've used gitignore-globs successfully in the past for this.

Last edited 7 months ago by johnbillion (previous) (diff)

#3 @johnbillion
7 months ago

  • Keywords needs-patch added

This ticket was mentioned in PR #1061 on WordPress/wordpress-develop by johnbillion.


7 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

https://core.trac.wordpress.org/ticket/52689

In [50441] the tests were switched to run against src by default instead of build.

This introduced one issue, the test_php_and_js_shortcode_attribute_regexes_match() now fails when run against build because it assumes the js/_enqueues/wp/shortcode.js file exists, which it does not in build. Running the tests against build is still possible so we should fix this, especially as existing contributors will see this unless (or until) they switch to using src for their tests.

## To test:

  1. Delete the build directory if you have one
  2. Change ABSPATH in wp-tests-config.php to point to src
  3. Run npm run env:restart
  4. Run npm run test:php -- --filter test_php_and_js_shortcode_attribute_regexes_match and confirm it passes
  5. Change ABSPATH in wp-tests-config.php to point to build
  6. Run npm run env:restart
  7. Run npm run build
  8. Run npm run test:php -- --filter test_php_and_js_shortcode_attribute_regexes_match and confirm it passes

This ticket was mentioned in PR #1252 on WordPress/wordpress-develop by ryelle.


4 months ago

This switches the verify:source-maps command to only check core files, by using the buildFiles array. It will only check JS files in 'wp-includes/**', 'wp-admin/**', 'wp-content/themes/twenty*/**', 'wp-content/plugins/akismet/**', instead of all build/**/*.js.

Currently, if you have a plugin in build/ that has sourcemaps, it will flag the npm run build process as incomplete/aborted, for example:

Running "verify:source-maps" task
Warning: The build/wp-content/plugins/demo/index.js file must not contain a sourceMappingURL. Use --force to continue.

Aborted due to warnings.

With this PR, it won't pick up that plugin file, but would flag a sourcemap in a core file. You can test by running npx grunt build:js to build the files, then npx grunt verify:source-maps; that will leave sourcemaps, and trigger the warning. npm run build removes the sourcemaps and should complete successfully.

Trac ticket: https://core.trac.wordpress.org/ticket/52689

#7 @desrosj
3 months ago

This is a build/test tool update, which can be committed during the beta cycle. Leaving in 5.8 for now.

#8 @desrosj
3 months ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 51173:

Build/Test Tools: Ignore sourceMaps for non WordPress Core files.

If a custom plugin or theme exists in the build/wp-content directory with a sourcemap, the build` script is currently returning a warning and failing.

This improves the verify:source-maps task in Grunt to ignore directories and files that do not belong to WordPress Core.

Props ryelle, afragen, johnbillion.
Fixes #52689.

This ticket was mentioned in Slack in #core by sergey. View the logs.


3 months ago

#10 @prbot
3 months ago

ryelle commented on PR #1252:

committed in r51173.

Note: See TracTickets for help on using tickets.