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

Block supports: value changes on block.json not reflected in block store after watch task runs #33993

Closed
glendaviesnz opened this issue Aug 11, 2021 · 3 comments · Fixed by #34024
Labels
[Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling [Type] Regression Related to a regression in the latest release

Comments

@glendaviesnz
Copy link
Contributor

glendaviesnz commented Aug 11, 2021

Currently when making changes individual blocks metadata in block.json, the change is picked up by the dev watch process, and the change can be seen if logged out in the blocks index.js file at the point the block is being registered, but the change doesn't get reflected in the core/blocks store unless the dev watch process is restarted.

This means that changes to the block.json support settings can't be easily tested without restarting the dev task after each change.

To replicate

  • Start the npm run dev process and run plugin in local dev env
  • Add a Group block and check that the Dimensions panel shows in the settings panel
  • Set the Group blocks block.json supports setting for padding to false
  • Reload the browser and see that the Dimensions panel still shows
  • Stop and restart the dev task
  • Reload the browser and notice that the Dimensions panel is now not displaying
  • You could also repeat the above with any of the block metadata, but the above example is visible on UI and saves inspecting the store

Expected behaviour

Changes to block.json support settings are reflected in the local dev env after watch process has detected the change

@glendaviesnz glendaviesnz added the [Feature] Blocks Overall functionality of blocks label Aug 11, 2021
@glendaviesnz glendaviesnz changed the title Block supports: value changes on block.json not reflected in dev site by watch process Block supports: value changes on block.json not reflected in block store after watch task runs Aug 11, 2021
@talldan
Copy link
Contributor

talldan commented Aug 11, 2021

It seems like this regressed in the last day, because initially I tested using a slightly outdated version of trunk (7479921), and it works ok with that commit. #33818 is the only change to the build process since then.

To describe how watch works, my understanding is that there are the following steps that make up the watch task:

  • watch.js watches particular files in packages for changes. When there's a change it triggers build.js passing it the changed files.
  • build.js does some tracing of entry points for block.json and stylesheets (if block.json is changed, the block's index.js needs to be rebuilt). Once the right files to rebuild are known, build-worker.js is triggered.
  • build-worker.js fires the right kind of build process for the file type (e.g. scss for stylesheets, babel for js) and builds the library code for packages (the contents of each package's build/build-module/build-style folders).
  • Webpack watch (which is also running) detects the changes for package build code, and builds the Gutenberg 'application' in the root build folder.

In the console, it looks like webpack triggers ok, so it definitely gets through to that final stage.

@talldan talldan added [Type] Build Tooling Issues or PRs related to build tooling [Type] Regression Related to a regression in the latest release and removed [Feature] Blocks Overall functionality of blocks labels Aug 11, 2021
@gziolo
Copy link
Member

gziolo commented Aug 11, 2021

I wouldn't be surprised if webpack v5 impacted that. I tested JS and CSS and watch mode but I forgot about block.json that has magical handling 😅

I did a quick test and I think that I know where the issue is. I added the following line to packages/block-library/src/group/block.json:

	"attributes": {
+		"foo": "bar",
		"tagName": {

JavaScript file gets correctly updated by webpack:

Screen Shot 2021-08-11 at 10 07 23

However, the build/block-library/group/block.json file that is loaded by the server doesn't update:

Screen Shot 2021-08-11 at 10 10 47

The issue is with CopyWebpackPlugin. It triggers only when CSS or JavaScript changes are made. The same issue exists for PHP files used with core blocks.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 11, 2021
@walbo
Copy link
Member

walbo commented Aug 11, 2021

Seems like it has to do with watchOptions.ignores in wepack.

Currently all files in src are ignored. This is fine for the .js and .scss files because they are build to build and build-style outside of src before webpack picks them up.

Created a PR (#34024) to only ignore files handled by the build script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants