Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#52689 closed defect (bug) (fixed)

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

Reported by: afragen's profile afragen Owned by: desrosj's profile 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
3 years ago

  • Milestone changed from Awaiting Review to 5.8

#2 @johnbillion
3 years 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 3 years ago by johnbillion (previous) (diff)

#3 @johnbillion
3 years ago

  • Keywords needs-patch added

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


3 years ago
#4

  • 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.


3 years ago
#6

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 years 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 years 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 years ago

ryelle commented on PR #1252:


3 years ago
#10

committed in r51173.

Note: See TracTickets for help on using tickets.