Skip to content

Commit 5475b00

Browse files
committed
chore: correct docs
1 parent 4989822 commit 5475b00

File tree

3 files changed

+44
-39
lines changed

3 files changed

+44
-39
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
| ⚙️ **Configuration Management** | Static application configuration | Runtime configuration updates without restarts |
3030
| 🏗️ **Declarative Services** | Complex service wiring boilerplate | Decorator-based dependency injection |
3131
| ⚛️ **React Integration** | Framework complexity in React apps | Hook-based service discovery in components |
32+
| 📦 **Rollup Bundle Plugin** | Automated bundling of modules | Simplifies and automates the bundling process |
3233

3334
## 🚀 Quick Concept Demo
3435

@@ -202,6 +203,12 @@ npm install @pandino/pandino @pandino/react-hooks
202203
```
203204
[→ React Integration Guide](./packages/react-hooks/README.md)
204205

206+
### Rollup Bundle Plugin
207+
```bash
208+
npm install -D @pandino/rollup-bundle-plugin
209+
```
210+
[→ Rollup Bundle Plugin Guide](./packages/rollup-bundle-plugin/README.md)
211+
205212
## Contributing
206213

207214
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.

packages/example/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import react from '@vitejs/plugin-react';
2-
import { defineConfig } from 'vite';
31
import { resolve } from 'node:path';
42
import { readFileSync } from 'node:fs';
3+
import { defineConfig } from 'vite';
4+
import react from '@vitejs/plugin-react';
55
import pandinoBundle from '@pandino/rollup-bundle-plugin';
66

77
// Read package.json to extract name and version

packages/rollup-bundle-plugin/README.md

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,6 @@ export default {
3131
- `components` are classes found in files that contain the configured decorator (default: `@Component`).
3232
- `activator` is set to the default export of the configured activator module, if provided.
3333

34-
## Usage with Rollup
35-
36-
```javascript
37-
// rollup.config.mjs
38-
import pandinoBundle from '@pandino/rollup-bundle-plugin';
39-
40-
export default {
41-
input: 'pandino:bundle', // or import 'pandino:bundle' in your code
42-
plugins: [
43-
pandinoBundle({
44-
// rootDir: process.cwd(),
45-
// include: ['**/*.{ts,tsx,js,jsx}'],
46-
// exclude: ['**/node_modules/**', '**/dist/**', '**/build/**'],
47-
// componentsDecorator: 'Component',
48-
// activator: 'src/Activator.ts',
49-
// outputFile: 'pandino/bundle.js',
50-
}),
51-
],
52-
output: {
53-
dir: 'dist',
54-
format: 'es',
55-
},
56-
};
57-
```
58-
59-
You can also omit `input: 'pandino:bundle'` and rely on the plugin to emit the chunk named by `outputFile`.
60-
6134
## Usage with Vite
6235

6336
```typescript
@@ -66,25 +39,50 @@ import { defineConfig } from 'vite';
6639
import pandinoBundle from '@pandino/rollup-plugin-bundle';
6740

6841
export default defineConfig({
42+
// ...
6943
plugins: [
70-
pandinoBundle({ activator: 'src/Activator.ts' }),
44+
pandinoBundle({
45+
virtualId: 'pandino:bundle:alpha',
46+
include: ['src/bundles/alpha/**/*.{ts,tsx}'],
47+
activator: 'src/bundles/alpha/activator.ts',
48+
headers: {
49+
bundleSymbolicName: `${packageJson.name}.alpha`,
50+
bundleVersion: packageJson.version,
51+
bundleDescription: 'Alpha example bundle',
52+
},
53+
}),
7154
],
72-
build: {
73-
rollupOptions: {
74-
// optionally add as an entry
75-
input: 'pandino:bundle',
76-
},
77-
},
7855
});
7956
```
8057

58+
> Every `pandinoBundle()` call creates a separate bundle. You can call it multiple times with different options if needed.
59+
8160
Then in your app you can import:
8261

83-
```typescript
84-
import bundle from 'pandino:bundle';
85-
// bundle.headers, bundle.activator, bundle.components
62+
```typescript jsx
63+
import { type FC, StrictMode } from 'react';
64+
import { createRoot } from 'react-dom/client';
65+
import { PandinoProvider } from '@pandino/react-hooks';
66+
67+
const Root: FC = () => {
68+
return (
69+
<PandinoProvider bundles={[import('pandino:bundle:alpha'), /* ... */]}>
70+
{/* ... */}
71+
</PandinoProvider>
72+
);
73+
};
74+
75+
const rootElement = document.getElementById('root')!;
76+
77+
createRoot(rootElement).render(
78+
<StrictMode>
79+
<Root />
80+
</StrictMode>,
81+
);
8682
```
8783

84+
The `virtualId` option is only necessary if you want to import the bundle module directly. If you only want the emitted chunk, you can omit it.
85+
8886
## Options
8987

9088
- **include**: string | string[]

0 commit comments

Comments
 (0)