Skip to content

Commit 2fc4c08

Browse files
author
Fergus Bisset
committed
fix(behaviours): separate React component from vanilla JS behaviours
- Create separate export path for BehavioursLoader React component - Vanilla behaviours: @fergusbisset/nhs-fdp-design-system/behaviours - React component: @fergusbisset/nhs-fdp-design-system/behaviours/react - Exclude .tsx files from esbuild behaviours bundle - Add Vite build step for React behaviours module - Update all documentation and examples with new import path Fixes 'Module not found' error when importing BehavioursLoader in Next.js
1 parent 1f24932 commit 2fc4c08

File tree

14 files changed

+640
-169
lines changed

14 files changed

+640
-169
lines changed

config/vite.behaviours.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import { resolve } from 'path';
4+
5+
// Build the BehavioursLoader React component
6+
// This is separate from the vanilla behaviours bundle
7+
export default defineConfig({
8+
plugins: [react()],
9+
build: {
10+
lib: {
11+
entry: resolve(__dirname, '../src/behaviours/react.ts'),
12+
formats: ['es'],
13+
fileName: () => 'react.js',
14+
},
15+
outDir: 'dist/src/behaviours',
16+
emptyOutDir: false, // Don't delete existing files (types are already there)
17+
sourcemap: true,
18+
rollupOptions: {
19+
external: ['react', 'react/jsx-runtime'],
20+
output: {
21+
preserveModules: false,
22+
},
23+
},
24+
},
25+
});

0 commit comments

Comments
 (0)