Repository navigation
Load vips library with new wordpress/worker-threads #74785
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
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
58821c5
74421 configure build pipeline (#74426)
adamsilverstein d13031b
74422 implement blob loader (#74468)
adamsilverstein fedaa28
74423 custom vips init (#74476)
adamsilverstein 1cb4814
Try: revert scripts package changes
adamsilverstein 8301259
Try: remove babel config change
adamsilverstein c565608
Add @wordpress/worker-threads package
adamsilverstein 8513192
Add worker bundling support to @wordpress/build
adamsilverstein 2c78a69
Migrate @wordpress/vips to use @wordpress/worker-threads
adamsilverstein abdca2e
Add unit tests for @wordpress/worker-threads
adamsilverstein 0308d35
Remove obsolete vips-worker test file
adamsilverstein 117b4c2
Fine tuning
adamsilverstein edd8e47
prettier
adamsilverstein 4651fc1
remove pr description
adamsilverstein 35334ec
Update packages/vips/src/vips-worker.ts
adamsilverstein 3c7291e
Remove unnecessary async keywords from WASM inlining test callbacks (…
Copilot f322c1a
Optimize transferables duplicate detection with Set for O(1) lookups …
Copilot 658a5ea
prettier
adamsilverstein a204117
remove shopify traces
adamsilverstein a9ca712
build vips-worker
adamsilverstein 60b08d6
Fix build for tests
adamsilverstein 2170cee
prettier
adamsilverstein 741c291
Fix TypeScript build by generating worker-code.ts placeholder before …
adamsilverstein 9ff1398
lint fix
adamsilverstein 2fca3d8
Update packages/wp-build/lib/build.mjs
adamsilverstein 8a7281e
remove heif support
adamsilverstein 1c6e593
Simplify isRPCMessage to minimal type check
adamsilverstein f76d50f
Simplify findTransferables to only check direct args/result
adamsilverstein bdbef08
Remove vips-heif.wasm inlining test
adamsilverstein 8d2dc4f
Simplify worker-threads library with worker-rpc
adamsilverstein 53a2f08
Replace worker-rpc with comctx in worker-threads package
adamsilverstein a73e21a
Fix TypeScript error in worker-thread postMessage call
adamsilverstein 879b1b5
update package lock
adamsilverstein c759d26
add re-transpilation step
adamsilverstein 17ff565
Break out placeholder generation
adamsilverstein d985c3b
remove stray diff
adamsilverstein f31636f
Extract worker build code from build.mjs into separate worker-build.m…
adamsilverstein c5d847a
Remove inadvertantly committed build files and add to gitignore
adamsilverstein e58dca6
linter fixes
adamsilverstein d1b015b
Fix prettier formatting in build.mjs
adamsilverstein f40162d
Update changelogs for vips, wp-build packages and add changelog for n…
adamsilverstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { readFile, writeFile, access, mkdir } from 'fs/promises'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import glob from 'fast-glob'; | ||
|
|
||
| const __dirname = path.dirname( fileURLToPath( import.meta.url ) ); | ||
| const ROOT_DIR = path.resolve( __dirname, '../..' ); | ||
| const PACKAGES_DIR = path.join( ROOT_DIR, 'packages' ); | ||
|
|
||
| /** | ||
| * Generate placeholder files for worker code in packages that define wpWorkers. | ||
| * This must run before TypeScript compilation because some packages | ||
| * (like vips) have source files that import from generated worker-code.ts. | ||
| */ | ||
| async function generateWorkerPlaceholders() { | ||
| console.log( '🔧 Generating worker placeholders...\n' ); | ||
|
|
||
| const startTime = Date.now(); | ||
|
|
||
| const packageJsonPaths = await glob( | ||
| path.join( PACKAGES_DIR, '*', 'package.json' ).replace( /\\/g, '/' ) | ||
| ); | ||
|
|
||
| let placeholdersCreated = 0; | ||
|
|
||
| for ( const packageJsonPath of packageJsonPaths ) { | ||
| try { | ||
| const packageJsonContent = await readFile( | ||
| packageJsonPath, | ||
| 'utf8' | ||
| ); | ||
| const packageJson = JSON.parse( packageJsonContent ); | ||
|
|
||
| if ( packageJson.wpWorkers ) { | ||
| const packageDir = path.dirname( packageJsonPath ); | ||
| const workerCodeFile = path.join( | ||
| packageDir, | ||
| 'src', | ||
| 'worker-code.ts' | ||
| ); | ||
|
|
||
| try { | ||
| await access( workerCodeFile ); | ||
| // File exists, no need to create placeholder. | ||
| } catch { | ||
| // File doesn't exist, create placeholder. | ||
| const placeholderContent = `/** | ||
| * Worker code for inline Blob URL creation. | ||
| * | ||
| * This file is a placeholder that gets overwritten by the build process. | ||
| * If you see this placeholder content at runtime, run \`npm run build\` first. | ||
| * | ||
| * @package gutenberg | ||
| */ | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| export const workerCode = '/* Placeholder - run npm run build to generate actual worker code */'; | ||
| `; | ||
| await mkdir( path.dirname( workerCodeFile ), { | ||
| recursive: true, | ||
| } ); | ||
| await writeFile( workerCodeFile, placeholderContent ); | ||
| placeholdersCreated++; | ||
| console.log( | ||
| ` ✔ Created placeholder: ${ path.relative( | ||
| ROOT_DIR, | ||
| workerCodeFile | ||
| ) }` | ||
| ); | ||
| } | ||
| } | ||
| } catch { | ||
| // Skip packages with invalid package.json. | ||
| } | ||
| } | ||
|
|
||
| const totalTime = Date.now() - startTime; | ||
|
|
||
| if ( placeholdersCreated === 0 ) { | ||
| console.log( ' ✔ All worker placeholders already exist' ); | ||
| } | ||
|
|
||
| console.log( | ||
| `\n🎉 Worker placeholder generation complete! (${ totalTime }ms)` | ||
| ); | ||
| } | ||
|
|
||
| generateWorkerPlaceholders().catch( ( error ) => { | ||
| console.error( '❌ Worker placeholder generation failed:', error ); | ||
| process.exit( 1 ); | ||
| } ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Auto-generated worker code for inline Blob URL creation. | ||
| # The build process generates a placeholder if needed, then overwrites it with real content. | ||
| src/worker-code.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I could be wrong, but I think this may need to happen in
dev.mjstoo. I’m here because after a fresh pull from trunk, thedevscript failed due to the missing file.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.
Oh, let me review - I assume you mean running
npm run dev?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.
I wasn't able to reproduce in trunk, maybe something in my local. Going to try a fresh repo checkout.
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.
@stokesman thanks for reporting this... does this go away if you run
npm run buildfirst?I was able to reproduce on a fresh checkout, opening a PR to fix!
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.
@stokesman I created a follow up PR to fix this - #75104