@aurelia/storybook 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTINUITY.md +22 -0
- package/README.md +210 -156
- package/apps/hello-world/.storybook/main.ts +0 -1
- package/apps/hello-world/package-lock.json +4485 -2626
- package/apps/hello-world/package.json +6 -16
- package/apps/hello-world/src/components/feedback-form.html +111 -0
- package/apps/hello-world/src/components/feedback-form.ts +45 -0
- package/apps/hello-world/src/components/notification-center.html +119 -0
- package/apps/hello-world/src/components/notification-center.ts +27 -0
- package/apps/hello-world/src/components/stat-card.html +107 -0
- package/apps/hello-world/src/components/stat-card.ts +33 -0
- package/apps/hello-world/src/components/weather-widget.html +89 -0
- package/apps/hello-world/src/components/weather-widget.ts +30 -0
- package/apps/hello-world/src/hello-world.html +44 -2
- package/apps/hello-world/src/services/weather-service.ts +15 -0
- package/apps/hello-world/src/stories/feedback-form.stories.ts +52 -0
- package/apps/hello-world/src/stories/hello-world.stories.ts +4 -5
- package/apps/hello-world/src/stories/notification-center.stories.ts +81 -0
- package/apps/hello-world/src/stories/stat-card.stories.ts +65 -0
- package/apps/hello-world/src/stories/weather-widget.stories.ts +57 -0
- package/apps/hello-world/tsconfig.json +4 -3
- package/apps/hello-world/vite.config.ts +0 -2
- package/apps/hello-world-webpack/.storybook/main.ts +0 -1
- package/apps/hello-world-webpack/package-lock.json +3646 -836
- package/apps/hello-world-webpack/package.json +2 -5
- package/apps/hello-world-webpack/src/components/feedback-form.html +111 -0
- package/apps/hello-world-webpack/src/components/feedback-form.ts +45 -0
- package/apps/hello-world-webpack/src/components/notification-center.html +119 -0
- package/apps/hello-world-webpack/src/components/notification-center.ts +27 -0
- package/apps/hello-world-webpack/src/components/stat-card.html +107 -0
- package/apps/hello-world-webpack/src/components/stat-card.ts +33 -0
- package/apps/hello-world-webpack/src/components/weather-widget.html +89 -0
- package/apps/hello-world-webpack/src/components/weather-widget.ts +30 -0
- package/apps/hello-world-webpack/src/hello-world.html +44 -2
- package/apps/hello-world-webpack/src/services/weather-service.ts +15 -0
- package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +52 -0
- package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +5 -6
- package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +81 -0
- package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +65 -0
- package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +57 -0
- package/apps/hello-world-webpack/tsconfig.json +1 -1
- package/package.json +5 -5
- package/apps/hello-world/.yarnrc.yml +0 -2
- package/apps/hello-world-webpack/.yarnrc.yml +0 -2
- package/dist/index.mjs +0 -132
- package/dist/index.mjs.map +0 -1
- package/dist/preset.mjs +0 -60
- package/dist/preset.mjs.map +0 -1
- package/dist/preview/render.mjs +0 -114
- package/dist/preview/render.mjs.map +0 -1
- package/dist/preview/types.mjs +0 -2
- package/dist/preview/types.mjs.map +0 -1
- package/dist/preview.mjs +0 -114
- package/dist/preview.mjs.map +0 -1
- package/dist/webpack.mjs +0 -21
- package/dist/webpack.mjs.map +0 -1
package/CONTINUITY.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Goal (incl. success criteria):
|
|
2
|
+
- Address question about empty chunk generation during build; explain whether outputs are unnecessary and options.
|
|
3
|
+
Constraints/Assumptions:
|
|
4
|
+
- Use repo instructions in AGENTS.md; maintain this ledger.
|
|
5
|
+
- Build uses Rollup per-file entries from globbed src/**/*.ts.
|
|
6
|
+
Key decisions:
|
|
7
|
+
- None yet for empty chunk handling.
|
|
8
|
+
State:
|
|
9
|
+
- Identified empty chunk comes from type-only file src/preview/types.ts.
|
|
10
|
+
Done:
|
|
11
|
+
- Inspected rollup config and types file to confirm empty output cause.
|
|
12
|
+
Now:
|
|
13
|
+
- Provide explanation and possible ways to avoid generating empty JS file.
|
|
14
|
+
Next:
|
|
15
|
+
- If requested, change rollup config or file layout to suppress empty chunk.
|
|
16
|
+
Open questions (UNCONFIRMED if needed):
|
|
17
|
+
- Should we change build config to avoid empty chunk? UNCONFIRMED.
|
|
18
|
+
- Remove the untracked .DS_Store file? UNCONFIRMED.
|
|
19
|
+
Working set (files/ids/commands):
|
|
20
|
+
- CONTINUITY.md
|
|
21
|
+
- /Users/dwayne/Code/aurelia2-storybook/rollup.config.mjs
|
|
22
|
+
- /Users/dwayne/Code/aurelia2-storybook/src/preview/types.ts
|
package/README.md
CHANGED
|
@@ -1,132 +1,134 @@
|
|
|
1
1
|
# @aurelia/storybook
|
|
2
2
|
|
|
3
|
-
> **Note:** Storybook support is
|
|
3
|
+
> **Note:** Storybook support is still early-stage. Expect a few rough edges while Aurelia 2 finishes its beta cycle, and please report anything that feels off.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@aurelia/storybook` is the glue between Aurelia 2 components and Storybook 10. It wires Aurelia's `enhance()` API into Storybook's rendering pipeline so you can preview, test, and document your components with either the Vite or Webpack builders.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Compatibility at a Glance
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
| Item | Supported versions | Notes |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Storybook | 10.x (ESM) | Tested with 10.0.5+; works with `storybook dev`/`storybook build` commands. |
|
|
12
|
+
| Aurelia | 2.0.0-beta.25+ | Uses Aurelia's `enhance()` APIs under the hood. |
|
|
13
|
+
| Bundlers | `@storybook/builder-vite` (Vite 5) · `@storybook/builder-webpack5` | Pick whichever matches your app; both share the same Aurelia preview runtime. |
|
|
14
|
+
| Node.js | ≥ 20.19.0 or ≥ 22.12.0 | Matches the engines field in `package.json` and Storybook 10's baseline.
|
|
13
15
|
|
|
14
|
-
##
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- An Aurelia 2 application (TypeScript or JavaScript) already set up with either Vite or Webpack.
|
|
19
|
+
- Storybook 10.x installed in the project. (Run `npx storybook@latest init` if you are starting fresh.)
|
|
20
|
+
- The peer dependencies listed in [`package.json`](package.json) that align with the Aurelia 2 beta train you are targeting.
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
## Installation
|
|
17
23
|
|
|
18
24
|
```bash
|
|
19
|
-
npm install --save-dev @aurelia/storybook
|
|
25
|
+
npm install --save-dev @aurelia/storybook storybook @storybook/builder-vite
|
|
26
|
+
# or, for Webpack builds:
|
|
27
|
+
npm install --save-dev @aurelia/storybook storybook @storybook/builder-webpack5
|
|
20
28
|
```
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actions`, etc.). Essentials functionality now ships with Storybook 10 core, so most projects only add optional extras.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quick Start (Vite Builder)
|
|
35
|
+
|
|
36
|
+
1. **Install** the dev dependencies as shown above (or with `pnpm`/`yarn`).
|
|
37
|
+
2. **Create `.storybook/main.ts`:**
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// .storybook/main.ts
|
|
41
|
+
import { mergeConfig, type InlineConfig } from 'vite';
|
|
42
|
+
import type { StorybookConfig } from 'storybook/internal/types';
|
|
43
|
+
|
|
44
|
+
const config: StorybookConfig & { viteFinal?: (config: InlineConfig) => InlineConfig | Promise<InlineConfig> } = {
|
|
45
|
+
stories: ['../src/stories/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
46
|
+
addons: ['@storybook/addon-links'],
|
|
47
|
+
framework: {
|
|
48
|
+
name: '@aurelia/storybook',
|
|
49
|
+
options: {},
|
|
50
|
+
},
|
|
51
|
+
core: {
|
|
52
|
+
builder: '@storybook/builder-vite',
|
|
53
|
+
},
|
|
54
|
+
viteFinal: async (viteConfig) => {
|
|
55
|
+
// Ensure problematic Aurelia deps are excluded from pre-bundling.
|
|
56
|
+
viteConfig.optimizeDeps = viteConfig.optimizeDeps ?? {};
|
|
57
|
+
viteConfig.optimizeDeps.exclude = Array.from(new Set([...(viteConfig.optimizeDeps.exclude ?? []), '@aurelia/runtime-html']));
|
|
58
|
+
|
|
59
|
+
return mergeConfig(viteConfig, {
|
|
60
|
+
define: {
|
|
61
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'development'),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default config;
|
|
68
|
+
```
|
|
23
69
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
70
|
+
- Excluding `@aurelia/runtime-html` keeps Vite from trying to pre-bundle Aurelia's DOM runtime, which is already ESM friendly.
|
|
71
|
+
- The `define` shim avoids `process is not defined` errors when Storybook code (or Aurelia plugins) look for `process.env.NODE_ENV` in the preview iframe.
|
|
72
|
+
|
|
73
|
+
3. **Create `.storybook/preview.ts`:**
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// .storybook/preview.ts
|
|
77
|
+
export { render, renderToCanvas } from '@aurelia/storybook';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
4. **Add `storybook` scripts** to `package.json`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"scripts": {
|
|
85
|
+
"storybook": "storybook dev -p 6006",
|
|
86
|
+
"build-storybook": "storybook build"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
5. **Run Storybook:** `npm run storybook` starts the dev server at http://localhost:6006.
|
|
27
92
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return mergeConfig(viteConfig, {
|
|
69
|
-
// ...any additional Vite configuration
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export default config;
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
- **.storybook/preview.ts**
|
|
78
|
-
Next, update or create your `.storybook/preview.ts` file with the following code to import the render functions from the Aurelia Storybook plugin:
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
// .storybook/preview.ts
|
|
82
|
-
// Import the render function from the plugin package.
|
|
83
|
-
export { render, renderToCanvas } from '@aurelia/storybook';
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
> **Note:** Essential features like actions, controls, backgrounds, and viewport are now built into Storybook 10 core and don't need to be installed separately. However, if you need to use the `action()` function in your stories (for programmatic actions), you may still need to install `@storybook/addon-actions`. Additional addons like `@storybook/addon-links` can be installed and added to the `addons` array in your configuration.
|
|
87
|
-
|
|
88
|
-
### Using with Webpack
|
|
89
|
-
|
|
90
|
-
If you prefer to use Webpack instead of Vite, update your `.storybook/main.ts` configuration:
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import type { StorybookConfig } from 'storybook/internal/types';
|
|
94
|
-
|
|
95
|
-
const config: StorybookConfig = {
|
|
96
|
-
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
97
|
-
addons: [
|
|
98
|
-
'@storybook/addon-links'
|
|
99
|
-
],
|
|
100
|
-
framework: {
|
|
101
|
-
name: '@aurelia/storybook',
|
|
102
|
-
options: {},
|
|
103
|
-
},
|
|
104
|
-
core: {
|
|
105
|
-
builder: '@storybook/builder-webpack5',
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default config;
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
The `.storybook/preview.ts` file remains the same for both Vite and Webpack configurations.
|
|
113
|
-
|
|
114
|
-
3. **Add scripts to your package.json**:
|
|
115
|
-
Add the following scripts to your `package.json` file to work with Storybook:
|
|
116
|
-
|
|
117
|
-
```json
|
|
118
|
-
"scripts": {
|
|
119
|
-
"storybook": "storybook dev -p 6006",
|
|
120
|
-
"build-storybook": "storybook build"
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
These scripts will allow you to start Storybook in development mode and build it for production.
|
|
124
|
-
|
|
125
|
-
### Writing Stories
|
|
126
|
-
|
|
127
|
-
Aurelia 2 stories are written similarly to standard Storybook stories, with a few Aurelia-specific details. Below is an example story file (`hello-world.stories.ts`) that demonstrates various scenarios:
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
93
|
+
## Quick Start (Webpack Builder)
|
|
94
|
+
|
|
95
|
+
1. Install `@storybook/builder-webpack5` instead of the Vite builder.
|
|
96
|
+
2. Create `.storybook/main.ts`:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import type { StorybookConfig } from 'storybook/internal/types';
|
|
100
|
+
|
|
101
|
+
const config: StorybookConfig = {
|
|
102
|
+
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
103
|
+
addons: ['@storybook/addon-links'],
|
|
104
|
+
framework: {
|
|
105
|
+
name: '@aurelia/storybook',
|
|
106
|
+
options: {},
|
|
107
|
+
},
|
|
108
|
+
core: {
|
|
109
|
+
builder: '@storybook/builder-webpack5',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default config;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The preset embedded in this package injects the `ts-loader` + `@aurelia/webpack-loader` rules so you typically do not need extra config, but `webpackFinal` is available if you need to extend it further.
|
|
117
|
+
|
|
118
|
+
3. Reuse the same `.storybook/preview.ts` and `package.json` scripts as in the Vite quick start.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Writing Aurelia Stories
|
|
123
|
+
|
|
124
|
+
Story files look exactly like standard Storybook CSF stories. The framework export automatically:
|
|
125
|
+
|
|
126
|
+
- Registers the component you set on the default export.
|
|
127
|
+
- Uses `renderToCanvas` to bootstrap an Aurelia app inside Storybook's preview iframe.
|
|
128
|
+
- Generates a template for you if you omit the `render` function (it binds every declared `bindable`).
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// src/stories/hello-world.stories.ts
|
|
130
132
|
import { HelloWorld } from '../hello-world';
|
|
131
133
|
import { fn, userEvent, within } from 'storybook/test';
|
|
132
134
|
|
|
@@ -138,82 +140,134 @@ const meta = {
|
|
|
138
140
|
}),
|
|
139
141
|
argTypes: {
|
|
140
142
|
message: { control: 'text' },
|
|
141
|
-
onIncrement: { action: 'increment' }
|
|
142
|
-
}
|
|
143
|
+
onIncrement: { action: 'increment' },
|
|
144
|
+
},
|
|
143
145
|
};
|
|
144
146
|
|
|
145
147
|
export default meta;
|
|
146
148
|
|
|
147
149
|
export const DefaultHelloWorld = {
|
|
148
150
|
args: {
|
|
149
|
-
message:
|
|
150
|
-
onIncrement: fn()
|
|
151
|
-
}
|
|
151
|
+
message: 'Hello from Storybook!',
|
|
152
|
+
onIncrement: fn(),
|
|
153
|
+
},
|
|
152
154
|
};
|
|
153
155
|
|
|
154
156
|
export const InteractiveHelloWorld = {
|
|
155
157
|
args: {
|
|
156
|
-
message:
|
|
157
|
-
onIncrement: fn()
|
|
158
|
+
message: 'Try clicking the button!',
|
|
159
|
+
onIncrement: fn(),
|
|
158
160
|
},
|
|
159
|
-
|
|
161
|
+
async play({ canvasElement }: { canvasElement: HTMLElement }) {
|
|
160
162
|
const canvas = within(canvasElement);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
await userEvent.click(button);
|
|
164
|
-
await userEvent.click(button);
|
|
165
|
-
await userEvent.click(button);
|
|
166
|
-
}
|
|
163
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
164
|
+
},
|
|
167
165
|
};
|
|
168
166
|
|
|
169
167
|
export const NoArgs = {
|
|
170
|
-
render: () => ({
|
|
171
|
-
template: `<hello-world></hello-world>`
|
|
172
|
-
})
|
|
168
|
+
render: () => ({ template: `<hello-world></hello-world>` }),
|
|
173
169
|
};
|
|
174
170
|
|
|
175
171
|
export const WithCustomTemplate = {
|
|
176
172
|
render: () => ({
|
|
177
|
-
template: `<hello-world message.bind="message">Click me!</hello-world
|
|
173
|
+
template: `<hello-world message.bind="message">Click me!</hello-world>`,
|
|
178
174
|
}),
|
|
179
175
|
args: {
|
|
180
|
-
message:
|
|
181
|
-
}
|
|
176
|
+
message: 'This is a custom message',
|
|
177
|
+
},
|
|
182
178
|
};
|
|
183
179
|
```
|
|
184
180
|
|
|
185
|
-
###
|
|
181
|
+
### Story Result Contract
|
|
186
182
|
|
|
187
|
-
|
|
188
|
-
The integration exports a render function (`renderToCanvas`) that Storybook calls to mount your Aurelia component on the preview canvas. It clears the canvas, enhances it with Aurelia, and notifies Storybook when rendering is complete.
|
|
183
|
+
When you provide a custom `render` function, return an object with any of the following fields. The Aurelia runtime consumes them while creating the preview app:
|
|
189
184
|
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
| Field | Type | Purpose |
|
|
186
|
+
| --- | --- | --- |
|
|
187
|
+
| `template` | `string` | Markup that will be enhanced inside Storybook's canvas. Required when you do not rely on the auto-generated template. |
|
|
188
|
+
| `components` | `unknown[]` | Additional custom elements, value converters, etc. to register via `aurelia.register(...)`. |
|
|
189
|
+
| `items` | `unknown[]` | Any DI registrations (e.g., `Registration.instance(...)`, services, or Aurelia plugins). |
|
|
190
|
+
| `container` | `IContainer` | Supply a pre-configured Aurelia DI container if you need full control. |
|
|
191
|
+
| `innerHtml` | `string` | Optional projection content used when a component template is auto-generated from the `component` export. |
|
|
192
|
+
| `props` | `Record<string, any>` | Story-specific props that merge with Storybook `args`. Useful when you need defaults that should not surface as controls.
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
Just like with other Storybook frameworks, you can make your stories interactive by defining args and using the testing library's `play` function to simulate user interactions.
|
|
194
|
+
## Registering Aurelia Dependencies & DI
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
Use the `components`, `items`, or `container` fields to bring along everything your component needs:
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
```ts
|
|
199
|
+
import { DI, Registration } from 'aurelia';
|
|
200
|
+
import { HttpClient } from '@aurelia/fetch-client';
|
|
201
|
+
import { OrdersPanel } from '../orders-panel';
|
|
199
202
|
|
|
200
|
-
|
|
203
|
+
const container = DI.createContainer();
|
|
204
|
+
container.register(
|
|
205
|
+
HttpClient,
|
|
206
|
+
Registration.instance('apiBaseUrl', 'https://api.example.com')
|
|
207
|
+
);
|
|
201
208
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
209
|
+
export const WithServices = {
|
|
210
|
+
render: () => ({
|
|
211
|
+
template: `<orders-panel api-base-url.bind="apiBaseUrl"></orders-panel>`,
|
|
212
|
+
components: [OrdersPanel],
|
|
213
|
+
container,
|
|
214
|
+
props: {
|
|
215
|
+
apiBaseUrl: 'https://api.example.com',
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
219
|
+
```
|
|
205
220
|
|
|
206
|
-
|
|
221
|
+
Because the Aurelia app lives for the lifetime of the story iframe, DI registrations persist until the story is torn down or Storybook forces a remount. If you need a clean state between stories, set `parameters: { forceRemount: true }` on the story or click the *Remount component* toolbar button in Storybook.
|
|
207
222
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
223
|
+
## Example Apps Inside This Repo
|
|
224
|
+
|
|
225
|
+
- `apps/hello-world` – Vite-based Aurelia starter that consumes `@aurelia/storybook`.
|
|
226
|
+
- `apps/hello-world-webpack` – Equivalent Webpack example.
|
|
227
|
+
|
|
228
|
+
To try them out:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
cd apps/hello-world
|
|
232
|
+
npm install
|
|
233
|
+
npm run storybook
|
|
234
|
+
|
|
235
|
+
cd ../hello-world-webpack
|
|
236
|
+
npm install
|
|
237
|
+
npm run storybook
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Each sample project now includes a small library of showcase stories you can open in Storybook to see different aspects of the integration:
|
|
241
|
+
|
|
242
|
+
- `HelloWorld` – the minimal counter example wired to Storybook controls and actions.
|
|
243
|
+
- `StatCard` – demonstrates args-driven styling and wiring the `onRefresh` action.
|
|
244
|
+
- `NotificationCenter` – renders repeating templates and exercises dismissal actions + play functions.
|
|
245
|
+
- `FeedbackForm` – shows two-way bindings, form state, and Storybook interaction tests that fill and submit inputs.
|
|
246
|
+
- `WeatherWidget` – uses Aurelia's DI plus `items` registration in the story to provide a mock `WeatherService` implementation.
|
|
247
|
+
|
|
248
|
+
These are great references when you want to compare your configuration against a working baseline or copy/paste patterns into your own component library.
|
|
249
|
+
|
|
250
|
+
## Troubleshooting & Tips
|
|
251
|
+
|
|
252
|
+
- **`process is not defined` inside the preview iframe** – Add `define: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'development') }` in your `viteFinal` merge (shown above).
|
|
253
|
+
- **Vite fails while pre-bundling Aurelia packages** – Ensure `@aurelia/runtime-html` (and any other Aurelia libs that re-export DOM globals) are listed in `optimizeDeps.exclude`.
|
|
254
|
+
- **State leaks between stories** – By default we reuse the Aurelia app instance for performance. Pass `parameters: { forceRemount: true }` to stories that must start fresh.
|
|
255
|
+
- **Need additional Storybook addons?** – Add them to the `addons` array as usual. The Aurelia framework only controls rendering, so controls, actions, interactions, and testing addons all work normally.
|
|
256
|
+
|
|
257
|
+
## Development
|
|
258
|
+
|
|
259
|
+
This repository publishes the Storybook framework itself. Helpful scripts:
|
|
260
|
+
|
|
261
|
+
- `npm run build` – bundle the framework with Rollup.
|
|
262
|
+
- `npm run build:types` – emit `.d.ts` files via `tsc`.
|
|
263
|
+
- `npm run watch` – development build with Rollup watch mode.
|
|
264
|
+
- `npm run test` – run the Jest suite (uses the JSDOM environment).
|
|
211
265
|
|
|
212
|
-
|
|
266
|
+
While developing, you can link the package into one of the sample apps in `apps/` to manual-test Storybook changes end to end.
|
|
213
267
|
|
|
214
268
|
## Contributing
|
|
215
269
|
|
|
216
|
-
|
|
270
|
+
Bug reports, docs tweaks, and feature PRs are all welcome. Please open an issue to discuss significant changes, and spin up one of the example apps to verify the behavior you are touching.
|
|
217
271
|
|
|
218
272
|
## License
|
|
219
273
|
|
|
@@ -221,4 +275,4 @@ Contributions, bug reports, and feature requests are welcome. Please open an iss
|
|
|
221
275
|
|
|
222
276
|
## Acknowledgements
|
|
223
277
|
|
|
224
|
-
Special shout out to Dmitry (@ekzobrain on GitHub) for the work he did on Storybook support for earlier versions of Storybook, which helped lay
|
|
278
|
+
Special shout out to Dmitry (@ekzobrain on GitHub) for the work he did on Storybook support for earlier versions of Storybook, which helped lay the groundwork for this implementation: [https://github.com/ekzobrain/storybook](https://github.com/ekzobrain/storybook).
|
|
@@ -4,7 +4,6 @@ import { mergeConfig, type InlineConfig } from 'vite';
|
|
|
4
4
|
const config: StorybookConfig & { viteFinal?: (config: InlineConfig, options: { configType: string }) => InlineConfig | Promise<InlineConfig> } = {
|
|
5
5
|
stories: ['../src/stories/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
6
6
|
addons: [
|
|
7
|
-
'@storybook/addon-links'
|
|
8
7
|
],
|
|
9
8
|
framework: {
|
|
10
9
|
name: '@aurelia/storybook',
|