-
Notifications
You must be signed in to change notification settings - Fork 386
[CI] Add Vite bundler tests for built npm packages #3079
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
Draft
adamziel
wants to merge
9
commits into
trunk
Choose a base branch
from
smoke-test-bundling-built-packages
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Tests that @php-wasm/* and @wp-playground/* packages can be bundled with Vite for both browser and Node.js targets using various import styles. ES Modules tests: - Web bundle with static ESM imports (@php-wasm/web, @php-wasm/universal) - Node bundle with static ESM imports (@php-wasm/node, @php-wasm/universal) - Node bundle with dynamic ESM imports CommonJS tests: - Node bundle with require() (@php-wasm/node, @php-wasm/universal) - Node bundle with dynamic import() in CJS context - Web bundle from CJS require() for browser target Each test builds a bundle with Vite (without externalizing dependencies) and loads it to verify no immediate errors occur. This catches issues like the "createRequire is not a function" error from #3074.
Web bundles are now loaded in a real browser via Puppeteer to verify they work correctly. The test creates a simple HTML page that loads the bundle, intercepts console logs and errors, and verifies the smoke test passes. This catches browser-specific bundling issues that wouldn't be caught by just verifying the build succeeds.
When viteExternalDynamicImports returned just a string, Rollup would resolve
it relative to the source file location. This caused paths like ./shared/icu.dat
to become ./lib/extensions/intl/shared/icu.dat in the output.
By returning an object with { id, external: true }, Rollup uses the path as-is
without further resolution, producing the correct ./shared/icu.dat path.
Jest was running PHP version tests in parallel, causing multiple tests to try binding to the same port simultaneously. Using --runInBand forces sequential execution, matching how the ESM tests already work.
Like the ESM tests, spawn a new Node process for each PHP version to avoid V8 crashes and port conflicts when calling runCLI() multiple times. This replaces the Jest-based approach with a simple custom test runner.
This avoids EADDRINUSE conflicts when tests run sequentially but the previous server hasn't fully released the port yet.
WASM, SO, and DAT files are loaded at runtime, not bundled inline. Node.js builtins should be external when targeting Node.js. This fixes V8 heap crashes from trying to inline huge WASM files and missing export errors from trying to bundle Node.js APIs for browser.
- Add --allow-file-access-from-files and --disable-web-security flags to Puppeteer to fix CORS errors when loading ES modules from file:// - Look for both .js and .mjs extensions when finding bundled output - Include file list in error message for better debugging
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds tests that verify @php-wasm/* and @wp-playground/* packages can be bundled with Vite for both browser and Node.js targets. This catches bundler-related issues like #3074 ("createRequire is not a function").
ES Modules tests:
@php-wasm/web,@php-wasm/universal) - verified in Puppeteer@php-wasm/node,@php-wasm/universal)CommonJS tests:
require()(@php-wasm/node,@php-wasm/universal)import()in CJS contextrequire()for browser target - verified in PuppeteerEach test:
import()orrequire()Closes #3074
Test plan
test-built-npm-packagesjob