Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changepacks/changepack_log_metro_expo_web.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"changes": {
"packages/metro-plugin/package.json": "Patch"
},
"note": "Document Expo web (part of #411): Metro compiles the web build through react-native-web with the same output as iOS and Android, which the Expo example now exports and checks in Chromium.",
"date": "2026-11-21T00:00:00.000Z"
}
16 changes: 12 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- feat/react-native-styled
- feat/react-native-states
- feat/react-native-animations
- feat/react-native-compat

# Pull requests and every job below run read-only. Only the `release` and
# `deploy-pages` jobs get write permissions, and they run on pushes to main
Expand Down Expand Up @@ -929,14 +930,15 @@ jobs:
fi
files="$(git diff --name-only "$(git merge-base "$BASE" HEAD)" HEAD)"
echo "$files"
if grep -qE '^(libs/extractor/src/native/|libs/binding/|bindings/devup-ui-(binding|wasm)/|packages/(metro-plugin|plugin-utils)/|packages/react/src/native/|apps/expo/|\.github/workflows/publish\.yml$)' <<< "$files"; then
if grep -qE '^(libs/extractor/src/native/|libs/binding/|bindings/devup-ui-(binding|wasm)/|packages/(metro-plugin|plugin-utils)/|packages/react/src/native/|packages/react/src/utils/(theme-context|with-theme).|apps/expo/|\.github/workflows/publish\.yml$)' <<< "$files"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

# The Expo example app (apps/expo) bundled for iOS and Android through
# @devup-ui/metro-plugin, as a release build does. Devup UI compiles away,
# The Expo example app (apps/expo) bundled for iOS, Android and the web
# (react-native-web) through @devup-ui/metro-plugin, as a release build
# does, and the web export opened in Chromium. Devup UI compiles away,
# so no bundle may keep a module of @devup-ui/react but its React Native
# runtime (`@devup-ui/react/native`), nor its runtime placeholder, and a
# file styled the same in every theme must not use that runtime.
Expand All @@ -955,14 +957,20 @@ jobs:
- run: bun install --frozen-lockfile
- *download-build
- *unpack-build
- name: Export the iOS and Android bundles
- name: Export the iOS, Android and web bundles
working-directory: apps/expo
env:
EXPO_NO_TELEMETRY: '1'
run: bun run export
- name: Check the bundles
working-directory: apps/expo
run: bun run check
- *record-playwright-revisions
- *restore-playwright-cache
- *install-chromium
- name: Check the web export in Chromium
working-directory: apps/expo
run: bun run check:web

# @devup-ui/vite-plugin must keep the CSS every server page needs when the
# build is vinext/RSC. The fixture shares one Devup UI header between server
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"name": "Devup UI Expo",
"slug": "devup-ui-expo",
"version": "0.1.0",
"platforms": ["ios", "android"]
"platforms": ["ios", "android", "web"]
}
}
2 changes: 1 addition & 1 deletion apps/expo/check-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function runtimeUsers(code, locate) {
return users
}

for (const platform of ['ios', 'android']) {
for (const platform of ['ios', 'android', 'web']) {
const directory = join(root, platform)
const bundles = readdirSync(directory).filter((file) => file.endsWith('.js'))
if (bundles.length === 0) failures.push(`${platform}: no JavaScript bundle`)
Expand Down
102 changes: 102 additions & 0 deletions apps/expo/check-web.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Opens the web export (`expo export --platform web` wrote dist/) in Chromium
// and checks that react-native-web renders the styles Devup UI compiled: the
// card takes the theme's color and switches with the theme, the input takes
// its focus style through the runtime's `Focused`, and the button, a
// `Pressable`, counts a press.
import { createReadStream, existsSync, statSync } from 'node:fs'
import { createServer } from 'node:http'
import { extname, join, normalize } from 'node:path'

import { chromium } from '@playwright/test'

const root = join(import.meta.dirname, 'dist')
const TYPES = {
'.html': 'text/html',
'.js': 'text/javascript',
'.json': 'application/json',
'.png': 'image/png',
}

const server = createServer((request, response) => {
const path = join(root, normalize(new URL(request.url, 'http://x').pathname))
if (!path.startsWith(root)) {
response.writeHead(404).end()
return
}
// A path that is no file is the app's page
const file =
existsSync(path) && statSync(path).isFile()
? path
: join(root, 'index.html')
response.writeHead(200, {
'content-type': TYPES[extname(file)] ?? 'application/octet-stream',
})
createReadStream(file).pipe(response)
})
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
const url = `http://127.0.0.1:${server.address().port}/`

const failures = []
/** Fail with `message` unless `actual` is `expected` */
function expectEqual(actual, expected, message) {
if (actual !== expected) {
failures.push(`${message}: expected ${expected}, got ${actual}`)
}
}

const browser = await chromium.launch()
try {
const page = await browser.newPage({ colorScheme: 'light' })
const errors = []
page.on('pageerror', (error) => errors.push(error.message))
await page.goto(url)
const card = page.getByTestId('card')
const name = page.getByTestId('name')
const count = page.getByTestId('count')
await card.waitFor()
/** The computed style `property` of `locator` */
const style = (locator, property) =>
locator.evaluate(
(element, property) => getComputedStyle(element)[property],
property,
)

expectEqual(
await style(card, 'backgroundColor'),
'rgb(255, 255, 255)',
'the card in the light theme',
)
expectEqual(
await style(count, 'backgroundColor'),
'rgb(90, 68, 255)',
'the count button',
)
await name.focus()
expectEqual(
await style(name, 'borderTopColor'),
'rgb(90, 68, 255)',
'the focused input',
)
await count.click()
expectEqual(
(await count.textContent())?.trim(),
'Pressed 1 times',
'the count after a press',
)
await page.getByTestId('theme').click()
expectEqual(
await style(card, 'backgroundColor'),
'rgb(31, 31, 46)',
'the card in the dark theme',
)
for (const error of errors) failures.push(`page error: ${error}`)
} finally {
await browser.close()
server.close()
}

if (failures.length > 0) {
console.error(failures.join('\n'))
process.exit(1)
}
console.info('web: react-native-web renders the compiled styles')
8 changes: 6 additions & 2 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
"main": "index.ts",
"scripts": {
"start": "expo start",
"export": "expo export --platform ios --platform android --no-bytecode --source-maps",
"check": "node check-bundle.mjs"
"export": "expo export --platform ios --platform android --platform web --no-bytecode --source-maps",
"check": "node check-bundle.mjs",
"check:web": "node check-web.mjs"
},
"dependencies": {
"@devup-ui/react": "workspace:^",
"@expo/metro-runtime": "~58.0.17",
"expo": "~58.0.26",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-native": "0.88.1",
"react-native-reanimated": "~4.7.1",
"react-native-web": "~0.21.4",
"react-native-worklets": "0.13.0"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions apps/expo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function App() {
boxShadow="$raised"
maxW={[null, null, '480px']}
p={[4, null, 6]}
testID="card"
w="100%"
>
<Text color="$muted" fontSize="14px" mb={2}>
Expand All @@ -72,6 +73,7 @@ export function App() {
onChangeText={setName}
px={3}
py={2}
testID="name"
value={name}
/>
<Text color={name ? '$text' : '$placeholder'} mt={2}>
Expand All @@ -88,6 +90,7 @@ export function App() {
bg="#5a44ff"
className={button}
onPress={() => setCount(count + 1)}
testID="count"
>
<Text color="#fff" fontWeight="600">
Pressed {count} times
Expand All @@ -98,6 +101,7 @@ export function App() {
border="1px solid $border"
className={button}
onPress={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
testID="theme"
>
<Text color="$text">
Switch to {theme === 'dark' ? 'light' : 'dark'}
Expand Down
Loading
Loading