Make WordPress Core

Opened 2 years ago

Last modified 9 months ago

#47749 new enhancement

Build tools: remove all old files when cleaning

Reported by: azaozz Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-testing needs-refresh
Focuses: Cc:


Currently running clean doesn't delete all old files. It either cleans only /build or only the inline files in /src. This can get confusing when switching the building location.

The presence of the build files in /src can also cause some problems when doing grunt precommit or building to /build, see #47078.

Attachments (2)

47749.diff (23.3 KB) - added by azaozz 2 years ago.
47749.1.diff (30.9 KB) - added by azaozz 2 years ago.

Download all attachments as: .zip

Change History (9)

2 years ago

#1 @azaozz
2 years ago

  • Keywords needs-testing added

In 47749.diff: fix the clean task to clean old files from both /build and /src.

The patch also contains some unrelated WPCS fixes in Gruntfile.js.

Last edited 2 years ago by azaozz (previous) (diff)

#2 @dkarfa
2 years ago

  • Keywords dev-feedback added
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Warning: Task "build" not found. Use --force to continue.

Aborted due to warnings.

#3 @dkarfa
2 years ago

My bad, I update the babel runtime

npm install @babel/runtime@latest

Then check, working fine with the patch, it worked :).

Last edited 2 years ago by dkarfa (previous) (diff)

#4 @azaozz
2 years ago

  • Keywords dev-feedback removed

@dkarfa Thanks for testing! Yeah, I forget to run npm install sometimes too. Glad it's working as expected.

2 years ago

#5 @azaozz
2 years ago

Was looking a bit more at what "grunt clean" does and why:

  • clean:files cleans everything from /build. Wondering if there's need to separately clean /js and /css there.
  • Running Webpack when building the js also creates /src/wp-includes/css/dist. It needs to be "cleaned" when cleaning the js or it may get deleted after it's created.
  • After building to /build there's a leftover /src/wp-includes/js directory with some of the js files.

In 47749.1.diff:

  • Switch grunt clean:js and grunt clean:css to only clean in /src. Can make that that dependent on passing --dev but not sure it's needed.
  • Delete /src/wp-includes/css/dist when running clean:js.
  • Run clean:js after building in /build to remove /src/wp-includes/js.
Last edited 2 years ago by azaozz (previous) (diff)

#6 @desrosj
2 years ago

  • Milestone changed from 5.3 to Future Release

With 5.3 beta 1 in a few hours, I'm punting this one. However, because it is test and tooling related, it can be moved back and committed during the beta period if someone has time to own.

#7 @isabel_brison
9 months ago

  • Keywords needs-refresh added

Tested and the patch no longer applies cleanly.

Also, the WPCS changes make it really hard to read where the actual code changed, so I'm not 100% sure what's happening here. To clarify: the clean task referred to in the description is the one that runs when running grunt build or grunt build:dev`, right? So the purpose is to make sure that old files are cleaned from both build/ and src/, whichever directory we're building from?

Version 0, edited 9 months ago by isabel_brison (next)
Note: See TracTickets for help on using tickets.