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

Update wp-scripts and test with WordPress 6.7 #29

Open
bobbingwide opened this issue Sep 24, 2024 · 2 comments
Open

Update wp-scripts and test with WordPress 6.7 #29

bobbingwide opened this issue Sep 24, 2024 · 2 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Sep 24, 2024

UK-tides blocks is currently delivered with one entry point /build/index.js.
wp-scripts has been improved considerably. It now supports multiple blocks per plugin.
UK tides doesn't need multiple blocks... but I may be moving the JavaScript source to another plugin that performs the build.
So I need to build it the same way as other blocks which do have multiple entry points.

Requirement

  • Update uk-tides to benefit from improvements to wp-scripts from the @wordpress/scripts package
  • Simplify / reduce the code needed to support internationalization
  • Register the block so that only the required code is loaded for the blocks that are used.
  • Understand what's needed to enqueue the required CSS in the block editor and on the front end.

Process

  • Update wp-scripts using npm run packages-update
  • Change webpack.config.js to deliver the UK-tides entry point.
  • Change block.json file to refer to the appropriate entry-point and CSS
  • Mark src/index.js as superceded
  • Enable internationalisation
  • Update server logic for the new entry point
    • Call wp_set_script_translations() for the block's editor-script
  • Build using npm run dev
  • Build the language files: npm run makepot, npm run l10n, npm run makejson
  • Test

For plugins which have already been changed refer to the code changes in

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 24, 2024

Interestingly, since UK-tides only had one entry point, the build worked without having to create a webpack.config.js file.
But when I moved block.json from the plugin's root directory the build failed with the same messages I got for other plugins.

[email protected] dev
wp-scripts start

Skipping "./build/index.js" listed in "C:/apache/htdocs/wordpress/wp-content/plugins/uk-tides/src/oik-uk-tides/block.json". File does not exist in the "src" directory.
[webpack-cli] TypeError: Cannot convert undefined or null to object
at Function.keys ()
at getNormalizedEntryStatic (C:\apache\htdocs\wordpress\wp-content\plugins\uk-tides\node_modules\webpack\lib\config\normalization.js:491:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@bobbingwide
Copy link
Owner Author

wp-scripts is now v30.4.0. WordPress is now 6.7

@bobbingwide bobbingwide changed the title Update wp-scripts and test with WordPress 6.6.2 Update wp-scripts and test with WordPress 6.7 Nov 14, 2024
bobbingwide added a commit that referenced this issue Nov 14, 2024
bobbingwide added a commit that referenced this issue Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant