Skip to content

Commit c262c10

Browse files
committed
Add package-bundlers job to CI workflow for testing library with multiple bundlers
1 parent 1a4ffa0 commit c262c10

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

.github/workflows/ci.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,118 @@ jobs:
154154
cd examples/todomvc
155155
npm ci
156156
npm run build
157+
158+
package-bundlers:
159+
runs-on: ubuntu-latest
160+
strategy:
161+
fail-fast: false
162+
matrix:
163+
bundler: [vite, webpack, rollup, esbuild]
164+
steps:
165+
- name: Checkout code
166+
uses: actions/checkout@v4
167+
168+
- name: Setup Node.js
169+
uses: actions/setup-node@v4
170+
with:
171+
node-version: '20'
172+
cache: 'npm'
173+
174+
- name: Install dependencies
175+
run: npm ci
176+
177+
- name: Build library
178+
run: npm run build
179+
180+
- name: Pack library
181+
run: npm pack --filename reflex.tgz
182+
183+
- name: Test with ${{ matrix.bundler }}
184+
run: |
185+
# Create test directory
186+
mkdir -p bundler-test
187+
cd bundler-test
188+
189+
# Initialize consumer project
190+
npm init -y
191+
192+
# Install peer dependencies
193+
npm install react@18 react-dom@18
194+
195+
# Install the packed library
196+
npm install ../reflex.tgz
197+
198+
# Create entry file that imports from the library
199+
cat > index.js << 'EOF'
200+
import { initAppDb } from "@flexsurfer/reflex";
201+
console.log("Successfully imported initAppDb:", typeof initAppDb);
202+
console.log("Library bundled successfully!");
203+
EOF
204+
205+
# Configure bundler-specific setup and build
206+
case "${{ matrix.bundler }}" in
207+
vite)
208+
npm install --save-dev vite
209+
cat > vite.config.js << 'EOF'
210+
export default {
211+
build: {
212+
lib: {
213+
entry: 'index.js',
214+
formats: ['es'],
215+
fileName: 'bundle'
216+
}
217+
}
218+
}
219+
EOF
220+
npx vite build
221+
;;
222+
223+
webpack)
224+
npm install --save-dev webpack webpack-cli
225+
cat > webpack.config.js << 'EOF'
226+
const path = require('path');
227+
module.exports = {
228+
entry: './index.js',
229+
output: {
230+
filename: 'bundle.js',
231+
path: path.resolve(__dirname, 'dist'),
232+
library: { type: 'commonjs2' }
233+
},
234+
mode: 'production',
235+
resolve: {
236+
extensions: ['.js']
237+
}
238+
};
239+
EOF
240+
npx webpack --mode=production
241+
# Test execution of bundled output
242+
node dist/bundle.js
243+
;;
244+
245+
rollup)
246+
npm install --save-dev rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs
247+
cat > rollup.config.js << 'EOF'
248+
import { nodeResolve } from '@rollup/plugin-node-resolve';
249+
import commonjs from '@rollup/plugin-commonjs';
250+
251+
export default {
252+
input: 'index.js',
253+
output: {
254+
file: 'dist/bundle.js',
255+
format: 'cjs'
256+
},
257+
plugins: [nodeResolve(), commonjs()]
258+
};
259+
EOF
260+
npx rollup -c
261+
# Test execution of bundled output
262+
node dist/bundle.js
263+
;;
264+
265+
esbuild)
266+
npm install --save-dev esbuild
267+
npx esbuild index.js --bundle --outfile=dist/bundle.js --format=cjs --platform=node
268+
# Test execution of bundled output
269+
node dist/bundle.js
270+
;;
271+
esac

0 commit comments

Comments
 (0)