Skip to content

Commit dcb40c6

Browse files
committed
fix(administration): decouple Storybook from Shopware tsconfig
1 parent 89ba0f7 commit dcb40c6

5 files changed

Lines changed: 71 additions & 49 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
the stable `sw-page` host boundary remains.
2727
- Add a standalone Vue 3 Storybook component viewer with interactive stories for the complete
2828
`jetpack-*` catalog, deterministic DAL fixtures, generated docs, and a static documentation build.
29+
- Decouple the Storybook typecheck and Vite/esbuild build from Shopware's Administration
30+
`tsconfig.json`, allowing documentation CI to build from a standalone Frosh Jetpack checkout.
2931
- Add a boot-order-safe global Administration CRUD API with typed DAL listings, detail/create forms,
3032
lifecycle hooks, association selectors, and immutable registration snapshots.
3133
- Add deterministic cross-plugin CRUD extensions for columns, cards, fields, row actions, bulk

‎docs/administration-components/storybook.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ navigation and overlays, and data and media.
2020
## Build static documentation
2121

2222
```bash
23+
npm run storybook:typecheck
2324
npm run storybook:build
2425
```
2526

@@ -30,6 +31,11 @@ generated Storybook files in the Shopware plugin package.
3031

3132
## How the standalone environment works
3233

34+
Storybook owns a self-contained TypeScript configuration and local declarations for its Twig imports
35+
and limited Shopware facade. Vite receives an explicit raw esbuild configuration, so neither the
36+
typecheck nor the production build resolves the Shopware Administration `tsconfig.json`. The viewer
37+
can therefore be built from a standalone Frosh Jetpack checkout in documentation CI.
38+
3339
The Storybook bootstrap provides only the Shopware boundaries that the components intentionally use:
3440

3541
- `Shopware.Component.register()` and `wrapComponentConfig()`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "*.html.twig" {
2+
const template: string;
3+
4+
export default template;
5+
}

‎src/Resources/app/administration/.storybook/main.ts‎

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,57 @@ import type { StorybookConfig } from "@storybook/vue3-vite";
22
import type { Plugin } from "vite";
33

44
function jetpackTwigPlugin(): Plugin {
5-
return {
6-
name: "frosh-jetpack-storybook-twig",
7-
enforce: "pre",
8-
transform(source, id) {
9-
if (!id.endsWith(".html.twig")) {
10-
return null;
11-
}
5+
return {
6+
name: "frosh-jetpack-storybook-twig",
7+
enforce: "pre",
8+
transform(source, id) {
9+
if (!id.endsWith(".html.twig")) {
10+
return null;
11+
}
1212

13-
const template = source.replaceAll(
14-
/\{%\s*(?:block\s+[A-Za-z0-9_]+|endblock)\s*%\}/g,
15-
"",
16-
);
13+
const template = source.replaceAll(
14+
/\{%\s*(?:block\s+[A-Za-z0-9_]+|endblock)\s*%\}/g,
15+
"",
16+
);
1717

18-
return {
19-
code: `export default ${JSON.stringify(template)};`,
20-
map: null,
21-
};
22-
},
23-
};
18+
return {
19+
code: `export default ${JSON.stringify(template)};`,
20+
map: null,
21+
};
22+
},
23+
};
2424
}
2525

2626
const config: StorybookConfig = {
27-
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.ts"],
28-
addons: ["@storybook/addon-docs"],
29-
framework: {
30-
name: "@storybook/vue3-vite",
31-
options: {},
32-
},
33-
core: {
34-
disableTelemetry: true,
35-
},
36-
viteFinal(viteConfig) {
37-
viteConfig.build = {
38-
...viteConfig.build,
39-
target: "esnext",
40-
};
41-
viteConfig.esbuild = {
42-
...viteConfig.esbuild,
43-
target: "esnext",
44-
};
45-
viteConfig.plugins = [
46-
...(viteConfig.plugins ?? []),
47-
jetpackTwigPlugin(),
48-
];
27+
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.ts"],
28+
addons: ["@storybook/addon-docs"],
29+
framework: {
30+
name: "@storybook/vue3-vite",
31+
options: {},
32+
},
33+
core: {
34+
disableTelemetry: true,
35+
},
36+
viteFinal(viteConfig) {
37+
viteConfig.build = {
38+
...viteConfig.build,
39+
target: "esnext",
40+
};
41+
viteConfig.esbuild = {
42+
...viteConfig.esbuild,
43+
target: "esnext",
44+
// Vite 6 still discovers a local tsconfig when this is an object. A raw JSON string
45+
// deliberately bypasses the Shopware-dependent root tsconfig in standalone CI.
46+
tsconfigRaw: JSON.stringify({
47+
compilerOptions: {
48+
useDefineForClassFields: true,
49+
},
50+
}),
51+
};
52+
viteConfig.plugins = [...(viteConfig.plugins ?? []), jetpackTwigPlugin()];
4953

50-
return viteConfig;
51-
},
54+
return viteConfig;
55+
},
5256
};
5357

5458
export default config;
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
2-
"extends": "./tsconfig.json",
32
"compilerOptions": {
4-
"baseUrl": ".",
3+
"target": "ES2022",
4+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
55
"module": "ESNext",
66
"moduleResolution": "Bundler",
7+
"baseUrl": ".",
8+
"types": ["vite/client"],
9+
"resolveJsonModule": true,
10+
"noEmit": true,
11+
"isolatedModules": true,
12+
"esModuleInterop": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"strict": true,
715
"noImplicitAny": false,
8-
"types": ["node"]
16+
"skipLibCheck": true
917
},
1018
"include": [
1119
".storybook/**/*.ts",
1220
".storybook/**/*.d.ts",
1321
"stories/**/*.ts",
14-
"src/component/jetpack-ui/**/*.ts",
15-
"../../../../../../../src/Administration/Resources/app/administration/src/html-shim.d.ts",
16-
"../../../../../../../src/Administration/Resources/app/administration/node_modules/vite/client.d.ts"
22+
"src/component/jetpack-ui/**/*.ts"
1723
],
18-
"exclude": ["node_modules", "storybook-static", "src/**/*.spec.ts"],
19-
"files": []
24+
"exclude": ["node_modules", "storybook-static", "src/**/*.spec.ts"]
2025
}

0 commit comments

Comments
 (0)