-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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.json files aren't rebuilt when running npm run dev
#16104
Comments
npm run dev
Looked into it some more. Usually when babel builds a js file, it outputs the compiled version into For json files, it's inlining them (I think using https://www.npmjs.com/package/babel-plugin-inline-json-import). The json for a block.json is inlined into the index.js it's imported by. This can be seen if you look at `block-library/build-module/[block]/index.js, the metadata from the json file is all there. The challenge for watching is that when a change to the For Another solution would be to transform the json into js, so that there's an equivalent |
It's all based on convention, so we could assume that the change in
It's a different proposal, it's still based on reading JSON file and inlining it into the JS file which imports it. With macros you can teach webpack to never cache files transpiled with Babel which use them: facebook/create-react-app@11737bc. However, I don't know how it works in practice. It's mostly the issue on our side because we use a custom watch solution to build packages. |
I'll try to tackle this now. |
Describe the bug
When running
npm run dev
and making changes to a block.json files, the files are not rebuilt.The watch script does notice the change as the
isSourceFile
function returns true for a json file:https://github.com/WordPress/gutenberg/blob/master/bin/packages/watch.js
However, the build worker script doesn't handle json files in its
BUILD_TASK_BY_EXTENSION
object and ignores the change:https://github.com/WordPress/gutenberg/blob/master/bin/packages/build-worker.js#L85
To reproduce
Steps to reproduce the behavior:
npm run dev
Expected behavior
Changes to block.json files should be rebuilt by
npm run dev
The text was updated successfully, but these errors were encountered: