Skip to content

Commit 54feaa4

Browse files
committed
refactor: unify element player runtime and harden IIFE workflows
Consolidate delivery/author/print rendering onto a single strategy-driven element player while removing legacy demo-specific hosts. Add per-bundle workspace-fingerprinted IIFE caching and resilient one-server orchestration so long test runs stay stable and incremental runs are faster. Made-with: Cursor
1 parent 0a9f032 commit 54feaa4

32 files changed

Lines changed: 1688 additions & 1729 deletions

apps/element-demo/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"predev": "bun run generate-imports && bun run --cwd ../.. verify:no-local-paths apps/element-demo/src/lib/element-imports.js apps/element-demo/src/lib/element-imports.d.ts",
1414
"test:e2e": "playwright test",
1515
"test:e2e:iife": "RUN_IIFE_E2E=1 playwright test iife-usefulness.spec.ts",
16+
"test:e2e:iife:suite": "RUN_IIFE_E2E=1 playwright test iife-usefulness.spec.ts smoke-matrix.spec.ts",
17+
"test:e2e:iife:suite:orchestrated": "PIE_IIFE_EXTERNAL_SERVER=1 RUN_IIFE_E2E=1 playwright test iife-usefulness.spec.ts smoke-matrix.spec.ts",
1618
"test:iife:bundle": "bun run scripts/test-iife-bundle-contract.ts",
1719
"test:e2e:ui": "playwright test --ui",
1820
"test:e2e:headed": "playwright test --headed",

apps/element-demo/playwright.config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function resolveLocalBrowsersDir(): string | undefined {
3838

3939
const localBrowsersDir = resolveLocalBrowsersDir();
4040
const runIifeE2e = process.env.RUN_IIFE_E2E === '1';
41+
const useExternalServer = process.env.PIE_IIFE_EXTERNAL_SERVER === '1';
4142

4243
function resolveLocalChromium(): string | undefined {
4344
if (!localBrowsersDir || !existsSync(localBrowsersDir)) {
@@ -103,10 +104,12 @@ export default defineConfig({
103104
use: { ...devices['Desktop Chrome'] },
104105
},
105106
],
106-
webServer: {
107-
command: 'bun run dev',
108-
url: 'http://localhost:5222',
109-
reuseExistingServer: true, // Use existing dev server
110-
timeout: 120_000,
111-
},
107+
webServer: useExternalServer
108+
? undefined
109+
: {
110+
command: 'bun run dev',
111+
url: 'http://localhost:5222',
112+
reuseExistingServer: true, // Use existing dev server
113+
timeout: 120_000,
114+
},
112115
});

apps/element-demo/scripts/test-iife-bundle-contract.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
22
import { join } from 'node:path';
33
import { Bundler, mkDependencyHash, type BuildBundleName } from '@pie-element/bundler-shared';
44
import { loadReactElementMatrix } from '../src/lib/testing/react-element-matrix';
5+
import { createWorkspaceCacheSalt } from '../src/lib/testing/workspace-fingerprint';
56

67
interface ContractFailure {
78
element: string;
@@ -56,7 +57,7 @@ function assertBundleContract(
5657
async function main() {
5758
const workspaceRoot = join(process.cwd(), '..', '..');
5859
const elementFilter = normalizeElementFilter(process.env.IIFE_ELEMENTS);
59-
const clearCache = process.env.IIFE_CLEAR_CACHE !== '0';
60+
const clearCache = process.env.IIFE_CLEAR_CACHE === '1';
6061
const instanceDir = join(process.cwd(), '.cache', 'iife-contract-tests');
6162
const outputDir = join(instanceDir, 'bundles');
6263
const cacheDir = join(instanceDir, 'cache');
@@ -86,10 +87,19 @@ async function main() {
8687
const requestedBundles: BuildBundleName[] = entry.hasAuthor
8788
? ['client-player', 'editor']
8889
: ['client-player'];
89-
const hash = mkDependencyHash([dependency]);
90+
const baseHash = mkDependencyHash([dependency]);
91+
const cacheSalt = createWorkspaceCacheSalt({
92+
workspaceRoot,
93+
dependencies: [dependency],
94+
packageDirs: [entry.packageDir],
95+
requestedBundles,
96+
resolutionMode: 'workspace-fast',
97+
sourceMaps: false,
98+
extraFiles: [join('packages', 'shared', 'bundler-shared', 'src', 'index.ts')],
99+
});
90100

91101
console.log(
92-
`[iife-contract][${entry.name}] building bundles=${requestedBundles.join(',')} hash=${hash}`
102+
`[iife-contract][${entry.name}] building bundles=${requestedBundles.join(',')} hash=${baseHash} salt=${cacheSalt.slice(0, 20)}`
93103
);
94104

95105
const result = await bundler.build({
@@ -99,6 +109,7 @@ async function main() {
99109
workspaceRoot,
100110
requestedBundles,
101111
sourceMaps: false,
112+
cacheSalt,
102113
},
103114
});
104115

@@ -111,6 +122,8 @@ async function main() {
111122
continue;
112123
}
113124

125+
const hash = result.hash;
126+
114127
if (result.cached) {
115128
cacheHits += 1;
116129
}

apps/element-demo/src/lib/element-player/components/AuthorView.svelte

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)