Skip to content

Commit d122c25

Browse files
committed
ci: build web on ci
1 parent 5b19e50 commit d122c25

File tree

11 files changed

+44
-33
lines changed

11 files changed

+44
-33
lines changed

.github/workflows/build-templates.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ jobs:
8686
--repo-url https://test.test
8787
--type ${{ matrix.type.name }}
8888
--languages ${{ matrix.type.language }}
89-
--example ${{ matrix.type.language == 'js' && 'expo' || 'vanilla' }}
89+
--example vanilla
90+
--tools vite
9091
--tools eslint
9192
--tools jest
9293
--tools lefthook
@@ -138,7 +139,11 @@ jobs:
138139
tgz=$(ls react-native-builder-bob-*.tgz)
139140
cd -
140141
cd ${{ env.work_dir }}
141-
YARN_CHECKSUM_BEHAVIOR=ignore yarn add --dev ../packages/react-native-builder-bob/$tgz
142+
143+
export YARN_CHECKSUM_BEHAVIOR=ignore
144+
145+
yarn add --dev ../packages/react-native-builder-bob/$tgz
146+
yarn --cwd example add --dev ../../packages/react-native-builder-bob/$tgz
142147
143148
- name: Get build target
144149
working-directory: ${{ env.work_dir }}
@@ -209,17 +214,6 @@ jobs:
209214
run: |
210215
yarn prepare
211216
212-
- name: Build example (Web)
213-
if: matrix.type.language == 'js'
214-
working-directory: ${{ env.work_dir }}
215-
shell: bash
216-
run: |
217-
# Clean up built JS files
218-
# So we test that bundling works without any pre-built files
219-
rm -rf lib/*
220-
221-
yarn example expo export --platform web
222-
223217
- name: Install JDK
224218
if: env.android_build == 1 && env.turbo_cache_hit_android != 1
225219
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
@@ -271,3 +265,13 @@ jobs:
271265
working-directory: ${{ env.work_dir }}
272266
run: |
273267
yarn turbo run build:ios --cache-dir=".turbo"
268+
269+
- name: Build example (Web)
270+
working-directory: ${{ env.work_dir }}
271+
shell: bash
272+
run: |
273+
# Clean up built JS files
274+
# So we test that bundling works without any pre-built files
275+
rm -rf lib/*
276+
277+
yarn example build:web

packages/create-react-native-library/templates/common/$.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ jobs:
194194
run: |
195195
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
196196
<% } -%>
197+
197198
<% if (example === 'expo' || tools.includes('vite')) { -%>
198199
build-web:
199200
runs-on: ubuntu-latest

packages/create-react-native-library/templates/js-view/src/{%- project.name %}View.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ type Props = ViewProps & {
44
color?: ColorValue;
55
};
66

7-
export function <%- project.name -%>View({
8-
color,
9-
style,
10-
...rest
11-
}: Props) {
7+
export function <%- project.name -%>View({ color, style, ...rest }: Props) {
128
return <View {...rest} style={[style, { backgroundColor: color }]} />;
139
}

packages/create-react-native-library/templates/tools/vite/example/vite.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
22

33
import { defineConfig, mergeConfig } from 'vite';
44

5-
import bobConfig from 'react-native-builder-bob/vite-config.mjs';
5+
import bobConfig from 'react-native-builder-bob/vite-config';
66

77
export default defineConfig((env) =>
88
mergeConfig(bobConfig(env), {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"scripts": {
3+
"web": "vite",
4+
"build:web": "vite build"
5+
},
6+
"devDependencies": {
7+
"react-native-web": "~0.21.1"
8+
}
9+
}

packages/react-native-builder-bob/babel-config.js renamed to packages/react-native-builder-bob/configs/babel-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const path = require('path');
44
// @ts-ignore -- Ignore missing types for this module
5-
const { loadConfig } = require('./lib/utils/loadConfig');
5+
const { loadConfig } = require('../lib/utils/loadConfig');
66

77
/**
88
* Get Babel configuration for the example project.

packages/react-native-builder-bob/babel-preset.js renamed to packages/react-native-builder-bob/configs/babel-preset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = function (api, options, cwd) {
5959
],
6060
require.resolve('@babel/plugin-transform-flow-strip-types'),
6161
[
62-
require.resolve('./lib/babel'),
62+
require.resolve('../lib/babel'),
6363
{
6464
extension: rewriteImportExtensions ? 'js' : undefined,
6565
},
File renamed without changes.

packages/react-native-builder-bob/vite-config.mjs renamed to packages/react-native-builder-bob/configs/vite-config.mjs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,19 @@ const jsx = (regex) => ({
3636
});
3737

3838
export default defineConfig(({ mode }) => ({
39-
plugins: [
40-
jsx(/\/(@expo|expo-.+)\//),
41-
commonjs(),
42-
react(),
43-
],
39+
plugins: [jsx(/\/(@expo|expo-.+)\//), commonjs(), react()],
4440
define: {
45-
'__DEV__': JSON.stringify(mode !== 'production'),
41+
__DEV__: JSON.stringify(mode !== 'production'),
4642
'process.env.EXPO_OS': JSON.stringify('web'),
47-
'global': 'globalThis',
43+
global: 'globalThis',
4844
},
4945
resolve: {
5046
extensions,
5147
conditions: ['source', 'module', 'browser', mode],
5248
alias: {
5349
'react-native': 'react-native-web',
5450
},
51+
dedupe: ['react', 'react-dom', 'react-native-web'],
5552
},
5653
optimizeDeps: {
5754
esbuildOptions: {

packages/react-native-builder-bob/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@
1818
},
1919
"homepage": "https://oss.callstack.com/react-native-builder-bob/build",
2020
"main": "lib/index.js",
21+
"exports": {
22+
"./package.json": "./package.json",
23+
"./babel-config": "./configs/babel-config.js",
24+
"./babel-preset": "./configs/babel-preset.js",
25+
"./metro-config": "./configs/metro-config.js",
26+
"./vite-config": "./configs/vite-config.mjs"
27+
},
2128
"bin": {
2229
"bob": "bin/bob"
2330
},
2431
"files": [
2532
"bin",
2633
"lib",
27-
"babel-preset.js",
28-
"metro-config.js",
29-
"babel-config.js",
30-
"vite-config.mjs"
34+
"configs"
3135
],
3236
"engines": {
3337
"node": "^20.19.0 || ^22.12.0 || >= 23.4.0"

0 commit comments

Comments
 (0)