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

How to add preset for custom bundle of wp.data #520

Closed
eliot-akira opened this issue Jun 4, 2023 · 6 comments
Closed

How to add preset for custom bundle of wp.data #520

eliot-akira opened this issue Jun 4, 2023 · 6 comments
Labels
[Type] Developer Experience [Type] Documentation Improvements or additions to documentation [Type] Enhancement New feature or request

Comments

@eliot-akira
Copy link
Collaborator

eliot-akira commented Jun 4, 2023

I'd like to add a new preset that creates a custom bundle with a set of plugins and content loaded.

Following #501 about adding a beta preset, I added my own 6.2-custom preset in those places, particularly:

  • packages/playground/compile-wordpress/build.js
  • packages/playground/remote/src/lib/get-wordpress-module.ts

And a conditional clause in compile-wordpress/Dockerfile to handle this preset, installing plugins, importing content from WXR file.

I'm able to build the preset with the following command:

npx nx recompile-wordpress playground-remote --preset=6.2-custom

Everything builds, except for the hashed wp-6.2-custom-*.data in dist/packages/playground/remote/assets.

  • In packages/playground/remote/public, there's a newly created folder wp-6.2-custom.
  • In packages/playground/remote/src/wordpress, there are wp-6.2-custom.data and wp-6.2-custom.js.

Somehow this .data file is not getting copied to a hashed file name in dist.

EDIT: Weirdly, the built files in public and src/wordpress are owned by root user. That might be related to why the .data file isn't being copied to its destination in dist.

@eliot-akira
Copy link
Collaborator Author

eliot-akira commented Jun 4, 2023

A workaround: I named my custom bundle 6.1 instead of 6.2-custom, and it now builds the .data file with imported content. It seems there might be a line in the build scripts somewhere that uses regex to match preset names to create a hashed name for the data file - and doesn't work when the name includes a dash, maybe.

@adamziel
Copy link
Collaborator

adamziel commented Jun 5, 2023

That's weird! I don't have any idea off the top of my head. I'll try this when I have a moment.

@adamziel
Copy link
Collaborator

adamziel commented Jun 5, 2023

Oh, no, I know what this is – only the imported files are copied:

export function getWordPressModule(wpVersion: string) {
switch (wpVersion) {
case '5.9':
/** @ts-ignore */
return import('../wordpress/wp-5.9.js');
case '6.0':
/** @ts-ignore */
return import('../wordpress/wp-6.0.js');
case '6.1':
/** @ts-ignore */
return import('../wordpress/wp-6.1.js');
case '6.2':
/** @ts-ignore */
return import('../wordpress/wp-6.2.js');
}
throw new Error(`Unsupported WordPress module: ${wpVersion}`);
}

@eliot-akira
Copy link
Collaborator Author

I added the new preset in that file too, as a dynamic import.

A clue might be that the wp.data file is generated for the preset, but it's just not being copied with hashed file name to the dist directory. That seems to be because the built files in remote/public and remote/src/wordpress are owned by root user. I'll continue digging around to see how to solve it.

@adamziel adamziel added [Type] Documentation Improvements or additions to documentation [Type] Enhancement New feature or request [Type] Developer Experience labels Oct 12, 2023
@adamziel
Copy link
Collaborator

Playground now uses .zip files instead of .data files for loading WordPress and those zips may be provided in the Blueprint's "preferredVersions": { "wp": "https://..." } field so I'm closing this issue.

@eliot-akira
Copy link
Collaborator Author

That's wonderful! I hadn't noticed that change. Using the zip format will make creating custom bundles much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Experience [Type] Documentation Improvements or additions to documentation [Type] Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants