Skip to content

[compile-extension] Emit the new PHPExtensionManifest shape, add --extra-files - #3596

Merged
adamziel merged 2 commits into
trunkfrom
compile-extension-new-manifest-shape
May 3, 2026
Merged

[compile-extension] Emit the new PHPExtensionManifest shape, add --extra-files#3596
adamziel merged 2 commits into
trunkfrom
compile-extension-new-manifest-shape

Conversation

@adamziel

@adamziel adamziel commented May 3, 2026

Copy link
Copy Markdown
Collaborator

What it does

Updates @php-wasm/compile-extension to emit manifests in the shape the loader merged in #3580 expects, and adds a --extra-files <hostDir>:<vfsRoot> CLI flag for staging sidecar assets (web UIs, data dirs, etc.) alongside the .so files.

The package's manifest output now matches PHPExtensionManifest from @php-wasm/universal exactly:

Why

The loader merged in #3580 validates manifests against a strict schema generated from PHPExtensionManifest, and rejects the old shape. Without this update, anything built with the published 3.1.25 fails at runtime with "Invalid PHP extension manifest". This is the prerequisite for stacking an SPX build PR that uses @php-wasm/compile-extension to produce the .so and the new manifest API to stage SPX's web UI files.

How to use --extra-files

npx @php-wasm/compile-extension \
  --source ./spx-src \
  --name spx \
  --php-versions 8.2 \
  --extra-files ./web-ui:/internal/shared/spx \
  --out ./dist

./web-ui is copied next to the manifest. Each file becomes one node under extraFiles.nodes with vfsPath relative to vfsRoot and sourcePath relative to the manifest URL. Empty directories are recorded as type: "directory" nodes so the loader creates them before PHP starts.

Multiple --extra-files entries are allowed; they must agree on vfsRoot because the manifest format stores a single root per group.

Testing instructions

npm exec nx -- test php-wasm-compile-extension
npm exec nx -- typecheck php-wasm-compile-extension
npm exec nx -- lint php-wasm-compile-extension

The existing integration suite (tests/run-integration-tests.sh) keeps working because the loader-side tests already pass manifestUrl straight through and use the new manifest shape.

The loader merged in #3580 expects manifests with sourcePath and the
extraFiles+nodes+vfsRoot shape, plus dropped sha256. Update the package
to write that shape and add a --extra-files <hostDir>:<vfsRoot> CLI
flag that copies sidecar assets next to the manifest and records them
under extraFiles.nodes (with empty directories tracked as type=directory).
@adamziel
adamziel requested review from a team, ashfame and Copilot May 3, 2026 21:46
@github-actions github-actions Bot added the [Type] Documentation Improvements or additions to documentation label May 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates @php-wasm/compile-extension to emit a loader-compatible PHPExtensionManifest shape and adds support for staging sidecar assets via a new --extra-files <hostDir>:<vfsRoot> CLI flag.

Changes:

  • Update manifest schema: filesourcePath, remove sha256, add extraFiles at manifest/artifact level.
  • Add extra-files staging implementation + tests (copy into outDir, emit extraFiles.nodes, record empty dirs).
  • Wire the new flag into the CLI, and document the new manifest shape and flag usage.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/php-wasm/compile-extension/src/manifest.ts Adjusts manifest types/output to match PHPExtensionManifest and adds extraFiles support.
packages/php-wasm/compile-extension/src/manifest.spec.ts Updates artifact assertions and adds coverage for createManifest output + extraFiles.
packages/php-wasm/compile-extension/src/extra-files.ts Implements --extra-files parsing and staging into outDir with manifest node generation.
packages/php-wasm/compile-extension/src/extra-files.spec.ts Adds tests for parsing and staging behavior, including empty directories and mixed roots.
packages/php-wasm/compile-extension/src/compile.ts Plumbs extraFiles through compile options into the written manifest.
packages/php-wasm/compile-extension/src/cli.ts Adds --extra-files flag, stages assets, and passes extraFiles into compilation.
packages/php-wasm/compile-extension/README.md Documents the new manifest schema and --extra-files usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/php-wasm/compile-extension/src/extra-files.ts Outdated
Comment thread packages/php-wasm/compile-extension/src/extra-files.ts Outdated
Comment thread packages/php-wasm/compile-extension/src/extra-files.ts
Comment thread packages/php-wasm/compile-extension/src/extra-files.ts Outdated
Comment thread packages/php-wasm/compile-extension/src/manifest.ts
Comment thread packages/php-wasm/compile-extension/src/extra-files.ts Outdated
- Split --extra-files spec on the last colon so Windows hostDirs with drive letters round-trip
- Detect duplicate vfsPath nodes and on-disk basename collisions across multiple --extra-files specs, throw clear errors
- Sort manifest nodes with a locale-independent comparator (was localeCompare, host-locale-dependent)
- Rename walk()'s visitor parameter from 'path' to 'entryPath' to avoid shadowing the imported path module
- Add tests for Windows-style hostDir, basename collisions, and vfsPath collisions
@adamziel
adamziel merged commit c8eb261 into trunk May 3, 2026
52 checks passed
@adamziel
adamziel deleted the compile-extension-new-manifest-shape branch May 3, 2026 22:27
adamziel added a commit that referenced this pull request May 3, 2026
After #3596 the helper emits manifests in the PHPExtensionManifest shape:
artifacts use sourcePath instead of file, sha256 was removed because the
loader stopped verifying hashes, and there is a new --extra-files flag for
staging sidecar assets. The README on trunk already reflects this; bring
the public docs page in line and document --extra-files alongside the
matrix example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package][@php-wasm] Compile [Type] Documentation Improvements or additions to documentation [Type] Enhancement New feature or request

2 participants