-
Notifications
You must be signed in to change notification settings - Fork 268
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
Use .zip files instead of .data files for loading WordPress #978
Conversation
Playground used the Emscripten's filepacker.py tool to bundle WordPress releases as zip files. This caused a lot of problems: * Filepacker splits WordPress into a `.data` file, with all the bytes concatenated as a single blob, and a `.js` file with the map of offsets and lengths for each file. Sometimes the browsers would invalidate the cache for the `.data` file, but not the `.js` file, causing the playground to fail to load. * The `.js` files had to be patched in the Dockerfile. * The `.js` files used XHR to load the `.data` files, which required custom error handling logic, progress monitoring logic, and even then some of the errors were not handled properly – see #504. * The `.data` loading code required custom loading logic. * The `.data` files were not stream–loaded. This PR doesn't stream-load the `.zip` files either, but that feature may be added in the future using the new `@wp-playground/compression-streams` package. ## Changes * The WordPress build process now produces `.zip` files instead of `.data` + `.js` files. * The worker thread now loads WordPress from zip files, including zips from arbitrary URLs. * Query API and Blueprints now accept URLs via the `?wp=` parameter. ## Testing instructions * Confirm all the E2E tests pass
The unit test failure seems intermittent. the last step here would be changing the zipFile step option to a Resource instead of adding a new zipBlob option. |
this is wonderful! way to go, using common infrastructure to remove a significant chunk of bulk. |
} | ||
} | ||
|
||
// const wordPressFile = fetch(zipFilename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot!
// Start downloading WordPress if needed | ||
let wordPressRequest = null; | ||
if (!wordPressAvailableInOPFS) { | ||
if (requestedWPVersion.startsWith('http')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading this right, we now have support for custom WordPress builds?
Having the ability to prebuild WordPress with additional plugins and themes can be useful for demos like the Woo.com example we explored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are reading this right indeed! :-)
Playground used the Emscripten's filepacker.py tool to bundle WordPress releases as zip files. This caused a lot of problems:
.data
file, with all the bytes concatenated as a single blob, and a.js
file with the map of offsets and lengths for each file. Sometimes the browsers would invalidate the cache for the.data
file, but not the.js
file, causing the playground to fail to load..js
files had to be patched in the Dockerfile..js
files used XHR to load the.data
files, which required custom error handling logic, progress monitoring logic, and even then some of the errors were not handled properly – see Playground not loading on Android and Chrome #564..data
loading code required custom loading logic..data
files were not stream–loaded. This PR doesn't stream-load the.zip
files either, but that feature may be added in the future using the new@wp-playground/compression-streams
package.Changes
.zip
files instead of.data
.js
files.?wp=
parameter.Testing instructions
cc @bgrgicak