@nx/storybook 22.1.0-canary.20251029-4a07faf → 22.1.0-canary.20251106-e9146c7

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.
Files changed (49) hide show
  1. package/generators.json +6 -0
  2. package/migrations.json +112 -1
  3. package/package.json +7 -7
  4. package/src/executors/build-storybook/build-storybook.impl.d.ts.map +1 -1
  5. package/src/executors/build-storybook/build-storybook.impl.js +1 -4
  6. package/src/executors/build-storybook/schema.json +0 -8
  7. package/src/executors/storybook/schema.json +0 -8
  8. package/src/executors/storybook/storybook.impl.d.ts.map +1 -1
  9. package/src/executors/storybook/storybook.impl.js +1 -5
  10. package/src/generators/configuration/configuration.d.ts.map +1 -1
  11. package/src/generators/configuration/configuration.js +2 -2
  12. package/src/generators/configuration/files/v10/project-files/.storybook/main.js__tmpl__ +93 -0
  13. package/src/generators/configuration/files/v10/project-files-ts/.storybook/main.ts__tmpl__ +94 -0
  14. package/src/generators/configuration/files/v9/project-files/.storybook/preview.js__tmpl__ +0 -0
  15. package/src/generators/configuration/files/v9/project-files/.storybook/tsconfig.json__tmpl__ +15 -0
  16. package/src/generators/configuration/files/v9/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
  17. package/src/generators/configuration/files/v9/project-files-ts/.storybook/tsconfig.json__tmpl__ +16 -0
  18. package/src/generators/configuration/lib/edit-root-tsconfig.d.ts.map +1 -1
  19. package/src/generators/configuration/lib/edit-root-tsconfig.js +5 -0
  20. package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +1 -1
  21. package/src/generators/configuration/lib/ensure-dependencies.js +2 -7
  22. package/src/generators/configuration/lib/util-functions.d.ts.map +1 -1
  23. package/src/generators/configuration/lib/util-functions.js +5 -3
  24. package/src/generators/init/init.d.ts.map +1 -1
  25. package/src/generators/init/init.js +1 -7
  26. package/src/generators/migrate-10/calling-storybook-cli.d.ts +4 -0
  27. package/src/generators/migrate-10/calling-storybook-cli.d.ts.map +1 -0
  28. package/src/generators/migrate-10/calling-storybook-cli.js +51 -0
  29. package/src/generators/migrate-10/migrate-10.d.ts +5 -0
  30. package/src/generators/migrate-10/migrate-10.d.ts.map +1 -0
  31. package/src/generators/migrate-10/migrate-10.js +22 -0
  32. package/src/generators/migrate-10/schema.d.ts +4 -0
  33. package/src/generators/migrate-10/schema.json +19 -0
  34. package/src/migrations/update-22-1-0/files/ai-instructions-for-cjs-esm.md +175 -0
  35. package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts +3 -0
  36. package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts.map +1 -0
  37. package/src/migrations/update-22-1-0/migrate-to-storybook-10.js +31 -0
  38. package/src/utils/utilities.d.ts +3 -2
  39. package/src/utils/utilities.d.ts.map +1 -1
  40. package/src/utils/utilities.js +42 -2
  41. package/src/utils/versions.d.ts +1 -1
  42. package/src/utils/versions.d.ts.map +1 -1
  43. package/src/utils/versions.js +1 -1
  44. /package/src/generators/configuration/{project-files → files/v10/project-files}/.storybook/preview.js__tmpl__ +0 -0
  45. /package/src/generators/configuration/{project-files → files/v10/project-files}/.storybook/tsconfig.json__tmpl__ +0 -0
  46. /package/src/generators/configuration/{project-files-ts → files/v10/project-files-ts}/.storybook/preview.ts__tmpl__ +0 -0
  47. /package/src/generators/configuration/{project-files-ts → files/v10/project-files-ts}/.storybook/tsconfig.json__tmpl__ +0 -0
  48. /package/src/generators/configuration/{project-files → files/v9/project-files}/.storybook/main.js__tmpl__ +0 -0
  49. /package/src/generators/configuration/{project-files-ts → files/v9/project-files-ts}/.storybook/main.ts__tmpl__ +0 -0
package/generators.json CHANGED
@@ -31,6 +31,12 @@
31
31
  "schema": "./src/generators/migrate-9/schema.json",
32
32
  "description": "Migrate to Storybook version 9.",
33
33
  "hidden": false
34
+ },
35
+ "migrate-10": {
36
+ "factory": "./src/generators/migrate-10/migrate-10",
37
+ "schema": "./src/generators/migrate-10/schema.json",
38
+ "description": "Migrate to Storybook version 10.",
39
+ "hidden": false
34
40
  }
35
41
  }
36
42
  }
package/migrations.json CHANGED
@@ -11,6 +11,15 @@
11
11
  "version": "21.2.0-beta.3",
12
12
  "description": "Remove deprecated Storybook addon dependencies",
13
13
  "implementation": "./src/migrations/update-21-2-0/remove-addon-dependencies"
14
+ },
15
+ "update-22-1-0-migrate-storybook-v10": {
16
+ "cli": "nx",
17
+ "version": "22.1.0-beta.3",
18
+ "requires": {
19
+ "storybook": ">=10.0.0"
20
+ },
21
+ "description": "Update workspce to use Storybok v10",
22
+ "implementation": "./src/migrations/update-22-1-0/migrate-to-storybook-10"
14
23
  }
15
24
  },
16
25
  "packageJsonUpdates": {
@@ -529,7 +538,7 @@
529
538
  }
530
539
  },
531
540
  "21.1.0": {
532
- "version": "21.2.0-beta.3",
541
+ "version": "22.1.0-beta.3",
533
542
  "packages": {
534
543
  "@storybook/angular": {
535
544
  "version": "^9.0.5",
@@ -624,6 +633,108 @@
624
633
  "alwaysAddToPackageJson": false
625
634
  }
626
635
  }
636
+ },
637
+ "22.1.0": {
638
+ "version": "22.1.0-beta.6",
639
+ "x-prompt": "Do you want to update Storybook to version 10?",
640
+ "implementation": "./src/migrations/update-21-2-0/migrate-to-storybook-10",
641
+ "requires": {
642
+ "storybook": ">=9.0.0 <10.0.0"
643
+ },
644
+ "packages": {
645
+ "@storybook/angular": {
646
+ "version": "^10.0.0",
647
+ "alwaysAddToPackageJson": false
648
+ },
649
+ "@storybook/react": {
650
+ "version": "^10.0.0",
651
+ "alwaysAddToPackageJson": false
652
+ },
653
+ "storybook": {
654
+ "version": "^10.0.0",
655
+ "alwaysAddToPackageJson": true
656
+ },
657
+ "@storybook/addon-onboarding": {
658
+ "version": "^10.0.0",
659
+ "alwaysAddToPackageJson": false
660
+ },
661
+ "@storybook/addon-themes": {
662
+ "version": "^10.0.0",
663
+ "alwaysAddToPackageJson": false
664
+ },
665
+ "@storybook/builder-webpack5": {
666
+ "version": "^10.0.0",
667
+ "alwaysAddToPackageJson": false
668
+ },
669
+ "@storybook/core-webpack": {
670
+ "version": "^10.0.0",
671
+ "alwaysAddToPackageJson": false
672
+ },
673
+ "@storybook/html": {
674
+ "version": "^10.0.0",
675
+ "alwaysAddToPackageJson": false
676
+ },
677
+ "@storybook/html-vite": {
678
+ "version": "^10.0.0",
679
+ "alwaysAddToPackageJson": false
680
+ },
681
+ "@storybook/nextjs": {
682
+ "version": "^10.0.0",
683
+ "alwaysAddToPackageJson": false
684
+ },
685
+ "@storybook/preact": {
686
+ "version": "^10.0.0",
687
+ "alwaysAddToPackageJson": false
688
+ },
689
+ "@storybook/preact-vite": {
690
+ "version": "^10.0.0",
691
+ "alwaysAddToPackageJson": false
692
+ },
693
+ "@storybook/react-vite": {
694
+ "version": "^10.0.0",
695
+ "alwaysAddToPackageJson": false
696
+ },
697
+ "@storybook/react-webpack5": {
698
+ "version": "^10.0.0",
699
+ "alwaysAddToPackageJson": false
700
+ },
701
+ "@storybook/server": {
702
+ "version": "^10.0.0",
703
+ "alwaysAddToPackageJson": false
704
+ },
705
+ "@storybook/server-webpack5": {
706
+ "version": "^10.0.0",
707
+ "alwaysAddToPackageJson": false
708
+ },
709
+ "@storybook/svelte": {
710
+ "version": "^10.0.0",
711
+ "alwaysAddToPackageJson": false
712
+ },
713
+ "@storybook/svelte-vite": {
714
+ "version": "^10.0.0",
715
+ "alwaysAddToPackageJson": false
716
+ },
717
+ "@storybook/sveltekit": {
718
+ "version": "^10.0.0",
719
+ "alwaysAddToPackageJson": false
720
+ },
721
+ "@storybook/vue3": {
722
+ "version": "^10.0.0",
723
+ "alwaysAddToPackageJson": false
724
+ },
725
+ "@storybook/vue3-vite": {
726
+ "version": "^10.0.0",
727
+ "alwaysAddToPackageJson": false
728
+ },
729
+ "@storybook/web-components": {
730
+ "version": "^10.0.0",
731
+ "alwaysAddToPackageJson": false
732
+ },
733
+ "@storybook/web-components-vite": {
734
+ "version": "^10.0.0",
735
+ "alwaysAddToPackageJson": false
736
+ }
737
+ }
627
738
  }
628
739
  }
629
740
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/storybook",
3
- "version": "22.1.0-canary.20251029-4a07faf",
3
+ "version": "22.1.0-canary.20251106-e9146c7",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
6
6
  "repository": {
@@ -33,19 +33,19 @@
33
33
  "migrations": "./migrations.json"
34
34
  },
35
35
  "dependencies": {
36
- "@nx/devkit": "22.1.0-canary.20251029-4a07faf",
36
+ "@nx/devkit": "22.1.0-canary.20251106-e9146c7",
37
37
  "@phenomnomnominal/tsquery": "~5.0.1",
38
38
  "semver": "^7.6.3",
39
39
  "tslib": "^2.3.0",
40
- "@nx/cypress": "22.1.0-canary.20251029-4a07faf",
41
- "@nx/js": "22.1.0-canary.20251029-4a07faf",
42
- "@nx/eslint": "22.1.0-canary.20251029-4a07faf"
40
+ "@nx/cypress": "22.1.0-canary.20251106-e9146c7",
41
+ "@nx/js": "22.1.0-canary.20251106-e9146c7",
42
+ "@nx/eslint": "22.1.0-canary.20251106-e9146c7"
43
43
  },
44
44
  "devDependencies": {
45
- "nx": "22.1.0-canary.20251029-4a07faf"
45
+ "nx": "22.1.0-canary.20251106-e9146c7"
46
46
  },
47
47
  "peerDependencies": {
48
- "storybook": ">=7.0.0 <10.0.0"
48
+ "storybook": ">=7.0.0 <11.0.0"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"build-storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/build-storybook/build-storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAS3D,wBAA8B,sBAAsB,CAClD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe;;GAkBzB"}
1
+ {"version":3,"file":"build-storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/build-storybook/build-storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAS3D,wBAA8B,sBAAsB,CAClD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe;;GAczB"}
@@ -7,12 +7,9 @@ const semver_1 = require("semver");
7
7
  async function buildStorybookExecutor(options, context) {
8
8
  (0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
9
9
  const storybookMajor = (0, utilities_1.storybookMajorVersion)();
10
- if (storybookMajor > 0 && storybookMajor <= 6) {
10
+ if (storybookMajor > 0 && storybookMajor <= 7) {
11
11
  throw (0, utilities_1.pleaseUpgrade)();
12
12
  }
13
- else if (storybookMajor === 7) {
14
- devkit_1.logger.warn(`Support for Storybook 7 is deprecated. Please upgrade to Storybook 8. See https://nx.dev/nx-api/storybook/generators/migrate-8 for more details.`);
15
- }
16
13
  const buildOptions = options;
17
14
  devkit_1.logger.info(`NX Storybook builder starting ...`);
18
15
  await runInstance(buildOptions);
@@ -42,14 +42,6 @@
42
42
  "description": "Build a documentation-only site using addon-docs.",
43
43
  "default": false
44
44
  },
45
- "staticDir": {
46
- "type": "array",
47
- "description": "Directory where to load static files from, array of strings.",
48
- "items": {
49
- "type": "string"
50
- },
51
- "x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
52
- },
53
45
  "configDir": {
54
46
  "type": "string",
55
47
  "description": "Directory where to load Storybook configurations from.",
@@ -26,14 +26,6 @@
26
26
  "type": "string",
27
27
  "description": "Host to listen on."
28
28
  },
29
- "staticDir": {
30
- "type": "array",
31
- "description": "Directory where to load static files from, array of strings.",
32
- "items": {
33
- "type": "string"
34
- },
35
- "x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
36
- },
37
29
  "configDir": {
38
30
  "type": "string",
39
31
  "description": "Directory where to load Storybook configurations from.",
@@ -1 +1 @@
1
- {"version":3,"file":"storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAOrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,wBAA+B,iBAAiB,CAC9C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC,CAuBD"}
1
+ {"version":3,"file":"storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAOrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,wBAA+B,iBAAiB,CAC9C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC,CAmBD"}
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = storybookExecutor;
4
- const devkit_1 = require("@nx/devkit");
5
4
  const utilities_1 = require("../../utils/utilities");
6
5
  const semver_1 = require("semver");
7
6
  async function* storybookExecutor(options, context) {
8
7
  const storybookMajor = (0, utilities_1.storybookMajorVersion)();
9
- if (storybookMajor > 0 && storybookMajor <= 6) {
8
+ if (storybookMajor > 0 && storybookMajor <= 7) {
10
9
  throw (0, utilities_1.pleaseUpgrade)();
11
10
  }
12
- else if (storybookMajor === 7) {
13
- devkit_1.logger.warn(`Support for Storybook 7 is deprecated. Please upgrade to Storybook 8. See https://nx.dev/nx-api/storybook/generators/migrate-8 for more details.`);
14
- }
15
11
  (0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
16
12
  const buildOptions = options;
17
13
  const result = await runInstance(buildOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAsCpD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,8BAGjC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,wBAAwB,8BA4KpC;AAwBD,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAuCpD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,8BAGjC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,wBAAwB,8BA4KpC;AAwBD,eAAe,sBAAsB,CAAC"}
@@ -15,7 +15,7 @@ function configurationGenerator(tree, schema) {
15
15
  return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
16
16
  }
17
17
  async function configurationGeneratorInternal(tree, rawSchema) {
18
- const storybookMajor = (0, utilities_1.storybookMajorVersion)();
18
+ const storybookMajor = (0, utilities_1.storybookMajorVersion)(tree);
19
19
  if (storybookMajor > 0 && storybookMajor === 7) {
20
20
  throw new Error((0, utilities_1.pleaseUpgrade)());
21
21
  }
@@ -93,7 +93,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
93
93
  }
94
94
  }
95
95
  else {
96
- devDeps['storybook'] = versions_1.storybookVersion;
96
+ devDeps['storybook'] = (0, utilities_1.getStorybookVersionToInstall)(tree);
97
97
  }
98
98
  if (schema.tsConfiguration) {
99
99
  devDeps['ts-node'] = versions_1.tsNodeVersion;
@@ -0,0 +1,93 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname } from "node:path";
3
+
4
+ <% if (usesVite && !viteConfigFilePath) { %>
5
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
6
+ import { mergeConfig } from 'vite';
7
+ <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
8
+
9
+ const config = {
10
+ stories: [
11
+ <% if((uiFramework === '@storybook/angular' && projectType === 'library') || uiFramework === '@storybook/nextjs') { %>
12
+ '../**/*.@(mdx|stories.@(js|jsx|ts|tsx))' <% } else { %>
13
+ '../<%= projectDirectory %>/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'
14
+ <% } %>],
15
+ addons: [<% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
16
+ framework: {
17
+ name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
18
+ options: {
19
+ <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
20
+ builder: {
21
+ viteConfigPath: '<%= viteConfigFileName %>',
22
+ },
23
+ <% } %>
24
+ <% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
25
+ builder: {
26
+ viteConfigPath: '<%= viteConfigFilePath %>',
27
+ },
28
+ <% } %>
29
+ },
30
+ },
31
+ <% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
32
+ if (config.resolve) {
33
+ config.resolve.alias = {
34
+ ...config.resolve.alias,
35
+ 'react-native$': 'react-native-web',
36
+ };
37
+ config.resolve.extensions = [
38
+ '.web.tsx',
39
+ '.web.ts',
40
+ '.web.jsx',
41
+ '.web.js',
42
+ ...(config.resolve.extensions ?? []),
43
+ ];
44
+ }
45
+ return config;
46
+ },<% } %><% if (usesVite && !viteConfigFilePath) { %>
47
+ viteFinal: async (config) =>
48
+ mergeConfig(config, {
49
+ <% if (usesReactNative) { %>define: {
50
+ global: 'window',
51
+ },
52
+ resolve: {
53
+ extensions: [
54
+ '.mjs',
55
+ '.web.tsx',
56
+ '.tsx',
57
+ '.web.ts',
58
+ '.ts',
59
+ '.web.jsx',
60
+ '.jsx',
61
+ '.web.js',
62
+ '.js',
63
+ '.css',
64
+ '.json',
65
+ ...(config.resolve?.extensions ?? []),
66
+ ],
67
+ alias: {
68
+ 'react-native': 'react-native-web',
69
+ },
70
+ },<% } %>
71
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %>nxViteTsPaths()],
72
+ }),
73
+ <% } %>
74
+ };
75
+ <% if(uiFramework !== '@storybook/angular') { %>
76
+ function getAbsolutePath(value: string): any {
77
+ return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
78
+ }
79
+ <% } %>
80
+
81
+ export default config;
82
+
83
+ <% if(!usesVite) { %>
84
+ // To customize your webpack configuration you can use the webpackFinal field.
85
+ // Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
86
+ // and https://nx.dev/recipes/storybook/custom-builder-configs
87
+ <% } %>
88
+
89
+ <% if(usesVite) { %>
90
+ // To customize your Vite configuration you can use the viteFinal field.
91
+ // Check https://storybook.js.org/docs/react/builders/vite#configuration
92
+ // and https://nx.dev/recipes/storybook/custom-builder-configs
93
+ <% } %>
@@ -0,0 +1,94 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname } from "node:path";
3
+
4
+ import type { StorybookConfig } from '<%= uiFramework %>';
5
+ <% if (usesVite && !viteConfigFilePath) { %>
6
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
7
+ import { mergeConfig } from 'vite';
8
+ <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
9
+
10
+ const config: StorybookConfig = {
11
+ stories: [
12
+ <% if((uiFramework === '@storybook/angular' && projectType === 'library') || uiFramework === '@storybook/nextjs') { %>
13
+ '../**/*.@(mdx|stories.@(js|jsx|ts|tsx))' <% } else { %>
14
+ '../<%= projectDirectory %>/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'
15
+ <% } %>],
16
+ addons: [<% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
17
+ framework: {
18
+ name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
19
+ options: {
20
+ <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
21
+ builder: {
22
+ viteConfigPath: '<%= viteConfigFileName %>',
23
+ },
24
+ <% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
25
+ builder: {
26
+ viteConfigPath: '<%= viteConfigFilePath %>',
27
+ },
28
+ <% } %>
29
+ },
30
+ },
31
+ <% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
32
+ if (config.resolve) {
33
+ config.resolve.alias = {
34
+ ...config.resolve.alias,
35
+ 'react-native$': 'react-native-web',
36
+ };
37
+ config.resolve.extensions = [
38
+ '.web.tsx',
39
+ '.web.ts',
40
+ '.web.jsx',
41
+ '.web.js',
42
+ ...(config.resolve.extensions ?? []),
43
+ ];
44
+ }
45
+ return config;
46
+ },<% } %><% if (usesVite && !viteConfigFilePath) { %>
47
+ viteFinal: async (config) =>
48
+ mergeConfig(config, {
49
+ <% if (usesReactNative) { %>define: {
50
+ global: 'window',
51
+ },
52
+ resolve: {
53
+ extensions: [
54
+ '.mjs',
55
+ '.web.tsx',
56
+ '.tsx',
57
+ '.web.ts',
58
+ '.ts',
59
+ '.web.jsx',
60
+ '.jsx',
61
+ '.web.js',
62
+ '.js',
63
+ '.css',
64
+ '.json',
65
+ ...(config.resolve?.extensions ?? []),
66
+ ],
67
+ alias: {
68
+ 'react-native': 'react-native-web',
69
+ },
70
+ },<% } %>
71
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %>nxViteTsPaths()],
72
+ }),
73
+ <% } %>
74
+ };
75
+
76
+ <% if(uiFramework !== '@storybook/angular') { %>
77
+ function getAbsolutePath(value: string): any {
78
+ return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
79
+ }
80
+ <% } %>
81
+
82
+ export default config;
83
+
84
+ <% if(!usesVite) { %>
85
+ // To customize your webpack configuration you can use the webpackFinal field.
86
+ // Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
87
+ // and https://nx.dev/recipes/storybook/custom-builder-configs
88
+ <% } %>
89
+
90
+ <% if(usesVite) { %>
91
+ // To customize your Vite configuration you can use the viteFinal field.
92
+ // Check https://storybook.js.org/docs/react/builders/vite#configuration
93
+ // and https://nx.dev/recipes/storybook/custom-builder-configs
94
+ <% } %>
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "emitDecoratorMetadata": true
5
+ },
6
+ "exclude": ["../**/*.spec.ts"],
7
+ "include": [
8
+ "../src/**/*.stories.ts",
9
+ "../src/**/*.stories.js",
10
+ "../src/**/*.stories.jsx",
11
+ "../src/**/*.stories.tsx",
12
+ "../src/**/*.stories.mdx",
13
+ "*.js"
14
+ ]
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "emitDecoratorMetadata": true
5
+ },
6
+ "exclude": ["../**/*.spec.ts"],
7
+ "include": [
8
+ "../src/**/*.stories.ts",
9
+ "../src/**/*.stories.js",
10
+ "../src/**/*.stories.jsx",
11
+ "../src/**/*.stories.tsx",
12
+ "../src/**/*.stories.mdx",
13
+ "*.js",
14
+ "*.ts"
15
+ ]
16
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"edit-root-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/edit-root-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAG7D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,QAyB1C"}
1
+ {"version":3,"file":"edit-root-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/edit-root-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,QA8B1C"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.editRootTsConfig = editRootTsConfig;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
+ const utilities_1 = require("../../../utils/utilities");
6
7
  /**
7
8
  * This is a temporary fix for Storybook to support TypeScript configuration files.
8
9
  * The issue is that if there is a root tsconfig.json file, Storybook will use it, and
@@ -13,6 +14,10 @@ function editRootTsConfig(tree) {
13
14
  if (!tree.exists('tsconfig.json')) {
14
15
  return;
15
16
  }
17
+ if ((0, utilities_1.storybookMajorVersion)(tree) >= 10) {
18
+ // This is not needed from storybook 10+
19
+ return;
20
+ }
16
21
  (0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
17
22
  json['ts-node'] ??= {};
18
23
  json['ts-node'].compilerOptions ??= {};
@@ -1 +1 @@
1
- {"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,0CA+FnC"}
1
+ {"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,0CAuFnC"}
@@ -6,13 +6,8 @@ const semver_1 = require("semver");
6
6
  const utilities_1 = require("../../../utils/utilities");
7
7
  const versions_1 = require("../../../utils/versions");
8
8
  function ensureDependencies(tree, options) {
9
- let storybookVersionToInstall = versions_1.storybookVersion;
10
- const installedStorybookMajorVersion = (0, utilities_1.storybookMajorVersion)();
11
- if (installedStorybookMajorVersion >= 7 &&
12
- (0, utilities_1.getInstalledStorybookVersion)() &&
13
- (0, semver_1.gte)((0, utilities_1.getInstalledStorybookVersion)(), '7.0.0')) {
14
- storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)();
15
- }
9
+ const storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)(tree);
10
+ const installedStorybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
16
11
  const dependencies = {};
17
12
  const devDependencies = installedStorybookMajorVersion < 9
18
13
  ? {
@@ -1 +1 @@
1
- {"version":3,"file":"util-functions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,IAAI,EAML,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAYpD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,OAAO,QAwC1B;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,OAAO,QAmD1B;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,wBAAwB,iBAqB/B;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,YAAY,GAAG,KAAK,QAoH9B;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAe9C;AAED,wBAAgB,wBAAwB,CACtC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EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,OAAO,GACvB,OAAO,CAkBT;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB;IACD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CAYA;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAS/D;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,yBAAyB,EAAE,MAAM,EACjC,IAAI,EAAE,IAAI,QAmEX"}
1
+ {"version":3,"file":"util-functions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,IAAI,EAML,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAYpD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,OAAO,QAwC1B;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,OAAO,QAmD1B;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,wBAAwB,iBAqB/B;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,YAAY,GAAG,KAAK,QA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AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,WAEjD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,OAAO,GACvB,OAAO,CAkBT;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB;IACD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CAYA;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAS/D;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,yBAAyB,EAAE,MAAM,EACjC,IAAI,EAAE,IAAI,QAmEX"}
@@ -124,6 +124,7 @@ async function addStaticTarget(tree, opts) {
124
124
  (0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
125
125
  }
126
126
  function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
127
+ const storybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
127
128
  const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
128
129
  const useTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
129
130
  // First let's check if old configuration file exists
@@ -156,8 +157,8 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
156
157
  uiFramework === '@storybook/react-vite'
157
158
  ? ''
158
159
  : undefined,
159
- module: useTsSolution ? 'esnext' : undefined,
160
- moduleResolution: useTsSolution ? 'bundler' : undefined,
160
+ module: storybookMajorVersion === 10 || useTsSolution ? 'esnext' : undefined,
161
+ moduleResolution: storybookMajorVersion === 10 || useTsSolution ? 'bundler' : undefined,
161
162
  jsx: useTsSolution && uiFramework !== '@storybook/angular'
162
163
  ? 'preserve'
163
164
  : undefined,
@@ -415,7 +416,8 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
415
416
  devkit_1.logger.warn(`Storybook configuration files already exist for ${projectName}!`);
416
417
  return;
417
418
  }
418
- const templatePath = (0, path_1.join)(__dirname, `../project-files${tsConfiguration ? '-ts' : ''}`);
419
+ const storybookMajor = ((0, utilities_1.storybookMajorVersion)(tree) ?? 10) <= 9 ? 9 : 10;
420
+ const templatePath = (0, path_1.join)(__dirname, `../files/v${storybookMajor}/project-files${tsConfiguration ? '-ts' : ''}`);
419
421
  (0, devkit_1.generateFiles)(tree, templatePath, root, {
420
422
  tmpl: '',
421
423
  uiFramework,
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqElC,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAEvD;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAiErE;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA8DlC,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAEvD;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAiErE;AAED,eAAe,aAAa,CAAC"}
@@ -4,7 +4,6 @@ exports.initGenerator = initGenerator;
4
4
  exports.initGeneratorInternal = initGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
- const semver_1 = require("semver");
8
7
  const plugin_1 = require("../../plugins/plugin");
9
8
  const utilities_1 = require("../../utils/utilities");
10
9
  const versions_1 = require("../../utils/versions");
@@ -14,12 +13,7 @@ function checkDependenciesInstalled(host, schema) {
14
13
  '@nx/storybook': versions_1.nxVersion,
15
14
  '@nx/web': versions_1.nxVersion,
16
15
  };
17
- let storybookVersionToInstall = versions_1.storybookVersion;
18
- if ((0, utilities_1.storybookMajorVersion)() >= 7 &&
19
- (0, utilities_1.getInstalledStorybookVersion)() &&
20
- (0, semver_1.gte)((0, utilities_1.getInstalledStorybookVersion)(), '7.0.0')) {
21
- storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)();
22
- }
16
+ const storybookVersionToInstall = (0, utilities_1.getStorybookVersionToInstall)(host);
23
17
  devDependencies['storybook'] = storybookVersionToInstall;
24
18
  return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions);
25
19
  }
@@ -0,0 +1,4 @@
1
+ import { Schema } from './schema';
2
+ export declare function callUpgrade(schema: Schema): 1 | Buffer;
3
+ export declare function checkStorybookInstalled(packageJson: Record<string, any>): boolean;
4
+ //# sourceMappingURL=calling-storybook-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calling-storybook-cli.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/calling-storybook-cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,CA4CtD;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC/B,OAAO,CAOT"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callUpgrade = callUpgrade;
4
+ exports.checkStorybookInstalled = checkStorybookInstalled;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const child_process_1 = require("child_process");
7
+ function callUpgrade(schema) {
8
+ const packageManager = (0, devkit_1.detectPackageManager)();
9
+ const pm = (0, devkit_1.getPackageManagerCommand)(packageManager);
10
+ try {
11
+ devkit_1.output.log({
12
+ title: `Calling sb upgrade`,
13
+ bodyLines: [
14
+ `ℹ️ Nx will call the Storybook CLI to upgrade your @storybook/* packages to the latest version.`,
15
+ `📖 You can read more about the Storybook upgrade command here: https://storybook.js.org/docs/react/configure/upgrading`,
16
+ ],
17
+ color: 'blue',
18
+ });
19
+ (0, child_process_1.execSync)(`${pm.dlx} ${packageManager === 'yarn' ? 'storybook' : 'storybook@latest'} upgrade ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, {
20
+ stdio: [0, 1, 2],
21
+ windowsHide: false,
22
+ });
23
+ devkit_1.output.log({
24
+ title: `Storybook packages upgraded.`,
25
+ bodyLines: [
26
+ `☑️ The upgrade command was successful.`,
27
+ `Your Storybook packages are now at the latest version.`,
28
+ ],
29
+ color: 'green',
30
+ });
31
+ }
32
+ catch (e) {
33
+ devkit_1.output.log({
34
+ title: 'Migration failed',
35
+ bodyLines: [
36
+ `🚨 The Storybook CLI failed to upgrade your @storybook/* packages to the latest version.`,
37
+ `Please try running the sb upgrade command manually:`,
38
+ `${pm.exec} storybook@latest upgrade`,
39
+ ],
40
+ color: 'red',
41
+ });
42
+ console.log(e);
43
+ return 1;
44
+ }
45
+ }
46
+ function checkStorybookInstalled(packageJson) {
47
+ return ((packageJson.dependencies['storybook'] ||
48
+ packageJson.devDependencies['storybook']) &&
49
+ (packageJson.dependencies['@nx/storybook'] ||
50
+ packageJson.devDependencies['@nx/storybook']));
51
+ }
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function migrate10Generator(tree: Tree, schema: Schema): Promise<void>;
4
+ export default migrate10Generator;
5
+ //# sourceMappingURL=migrate-10.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/migrate-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,IAAI,EAAE,MAAM,YAAY,CAAC;AAIzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAgBlE;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrate10Generator = migrate10Generator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const output_1 = require("nx/src/utils/output");
6
+ const calling_storybook_cli_1 = require("./calling-storybook-cli");
7
+ async function migrate10Generator(tree, schema) {
8
+ const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
9
+ if (!(0, calling_storybook_cli_1.checkStorybookInstalled)(packageJson)) {
10
+ output_1.output.error({
11
+ title: 'No Storybook packages installed',
12
+ bodyLines: [
13
+ `🚨 Nx did not find any Storybook packages installed in your workspace.`,
14
+ `So no migration is necessary.`,
15
+ ],
16
+ });
17
+ return;
18
+ }
19
+ (0, calling_storybook_cli_1.callUpgrade)(schema);
20
+ await (0, devkit_1.formatFiles)(tree);
21
+ }
22
+ exports.default = migrate10Generator;
@@ -0,0 +1,4 @@
1
+ export interface Schema {
2
+ autoAcceptAllPrompts?: boolean;
3
+ configDirs?: string[];
4
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "cli": "nx",
3
+ "title": "Migrate Storybook to version 10.",
4
+ "description": "Migrate Storybook to version 10.",
5
+ "$id": "migrate-10",
6
+ "type": "object",
7
+ "properties": {
8
+ "autoAcceptAllPrompts": {
9
+ "type": "boolean",
10
+ "description": "Say yes to all the prompts from the Storybook CLI migration scripts.",
11
+ "default": false
12
+ },
13
+ "configDir": {
14
+ "type": "array",
15
+ "description": "Directory(ies) where to load Storybook configurations from. Use this if you want to customize the Storybook projects you'd like to migrate.",
16
+ "default": []
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,175 @@
1
+ # Instructions for LLM: Transform Storybook Config Files from CommonJS to ESM
2
+
3
+ ## Task Overview
4
+
5
+ Find all .storybook/main.ts and .storybook/main.js files in the workspace and transform
6
+ any CommonJS (CJS) configurations to ES Modules (ESM).
7
+
8
+ ### Step 1: Find All Storybook Config Files
9
+
10
+ Use glob patterns to locate all Storybook main configuration files:
11
+ **/.storybook/main.js
12
+ **/.storybook/main.ts
13
+
14
+ ### Step 2: Identify CommonJS vs ESM
15
+
16
+ For each file found, read its contents and determine if it uses CommonJS syntax by
17
+ checking for:
18
+
19
+ CommonJS indicators:
20
+
21
+ - `module.exports =` or `module.exports.`
22
+ - `exports.`
23
+ - `require()` function calls
24
+
25
+ ESM indicators (already correct):
26
+
27
+ - export default
28
+ - export const/export function
29
+ - import statements
30
+
31
+ ### Step 3: Transform CJS to ESM
32
+
33
+ For each file identified as CommonJS, perform the following transformations:
34
+
35
+ A. Convert `module.exports`
36
+
37
+ // FROM (CJS):
38
+
39
+ ```
40
+ module.exports = {
41
+ stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
42
+ addons: ['@storybook/addon-essentials']
43
+ };
44
+ ```
45
+
46
+ // TO (ESM):
47
+
48
+ ```
49
+ export default {
50
+ stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
51
+ addons: ['@storybook/addon-essentials']
52
+ };
53
+ ```
54
+
55
+ B. Convert `require()` to import
56
+
57
+ // FROM (CJS):
58
+
59
+ ```
60
+ const { nxViteTsPaths } = require('@nx/vite/plugins/nx-tsconfig-paths.plugin');
61
+ const { mergeConfig } = require('vite');
62
+ ```
63
+
64
+ // TO (ESM):
65
+
66
+ ```
67
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
68
+ import { mergeConfig } from 'vite';
69
+ ```
70
+
71
+ C. Handle `path.join()` patterns
72
+
73
+ // FROM (CJS):
74
+
75
+ ```
76
+ const path = require('path');
77
+ const rootMain = require(path.join(__dirname, '../../.storybook/main'));
78
+ ```
79
+
80
+ // TO (ESM):
81
+
82
+ ```
83
+ import { join } from 'path';
84
+ import rootMain from '../../.storybook/main';
85
+ ```
86
+
87
+ D. Handle Dynamic Requires in Config Functions
88
+
89
+ // FROM (CJS):
90
+
91
+ ```
92
+ module.exports = {
93
+ viteFinal: async (config) => {
94
+ const { mergeConfig } = require('vite');
95
+ return mergeConfig(config, {});
96
+ }
97
+ };
98
+ ```
99
+
100
+ // TO (ESM):
101
+
102
+ ```
103
+ import { mergeConfig } from 'vite';
104
+
105
+ export default {
106
+ viteFinal: async (config) => {
107
+ return mergeConfig(config, {});
108
+ }
109
+ };
110
+ ```
111
+
112
+ ### Step 4: Validation Checks
113
+
114
+ After transformation, verify:
115
+
116
+ 1. All require() calls have been converted to import statements at the top of the file
117
+ 2. All module.exports have been converted to export default or named exports
118
+ 3. Imports are at the top of the file (before the export)
119
+ 4. The file maintains proper TypeScript typing if it's a .ts file
120
+
121
+ ### Step 5: Report Results
122
+
123
+ Provide a summary of:
124
+
125
+ - Total files found
126
+ - Files that were already ESM (no changes needed)
127
+ - Files that were transformed from CJS to ESM
128
+ - List the specific files that were modified
129
+
130
+ ### Example Complete Transformation
131
+
132
+ Before (CJS):
133
+
134
+ ```
135
+ const path = require('path');
136
+ const { mergeConfig } = require('vite');
137
+
138
+ module.exports = {
139
+ stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
140
+ addons: ['@storybook/addon-essentials'],
141
+ viteFinal: async (config) => {
142
+ return mergeConfig(config, {
143
+ resolve: {
144
+ alias: {}
145
+ }
146
+ });
147
+ }
148
+ };
149
+ ```
150
+
151
+ After (ESM):
152
+
153
+ ```
154
+ import { join } from 'path';
155
+ import { mergeConfig } from 'vite';
156
+
157
+ export default {
158
+ stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
159
+ addons: ['@storybook/addon-essentials'],
160
+ viteFinal: async (config) => {
161
+ return mergeConfig(config, {
162
+ resolve: {
163
+ alias: {}
164
+ }
165
+ });
166
+ }
167
+ };
168
+ ```
169
+
170
+ ## Important Notes
171
+
172
+ - Preserve all comments in the original files
173
+ - Maintain the same indentation and formatting style
174
+ - For TypeScript files (.ts), ensure type imports use import type when appropriate
175
+ - Test that the transformations don't break the Storybook configuration
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function migrateToStorybook10(tree: Tree): Promise<string[]>;
3
+ //# sourceMappingURL=migrate-to-storybook-10.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-to-storybook-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/migrations/update-22-1-0/migrate-to-storybook-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,wBAA8B,oBAAoB,CAAC,IAAI,EAAE,IAAI,qBA6B5D"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = migrateToStorybook10;
4
+ const output_1 = require("nx/src/utils/output");
5
+ const migrate_10_1 = require("../../generators/migrate-10/migrate-10");
6
+ const path_1 = require("path");
7
+ const fs_1 = require("fs");
8
+ async function migrateToStorybook10(tree) {
9
+ output_1.output.log({
10
+ title: 'Migrating Storybook to v10',
11
+ bodyLines: [
12
+ `🚀 This migration will update your Storybook configuration to v10.`,
13
+ `It will call the @nx/storybook:migrate-10 generator for you.`,
14
+ `You can read more about the migration and how this generator works here:`,
15
+ `https://nx.dev/nx-api/storybook/generators/migrate-10`,
16
+ ],
17
+ });
18
+ await (0, migrate_10_1.default)(tree, {
19
+ autoAcceptAllPrompts: true,
20
+ });
21
+ const pathToAiInstructions = (0, path_1.join)(__dirname, 'files', 'ai-instructions-for-cjs-esm.md');
22
+ if (!(0, fs_1.existsSync)(pathToAiInstructions)) {
23
+ return;
24
+ }
25
+ const contents = (0, fs_1.readFileSync)(pathToAiInstructions);
26
+ tree.write('MIGRATE_STORYBOOK_10.md', contents);
27
+ return [
28
+ `Storybook 10 requires Storybook Configs to use ESM.`,
29
+ `We created 'MIGRATE_STORYBOOK_10.md' with instructions for an AI Agent to convert CJS Storybook Configs to ESM in your workspace.`,
30
+ ];
31
+ }
@@ -11,8 +11,9 @@ export declare const Constants: {
11
11
  coreAddonPrefix: string;
12
12
  uiFrameworks7: string[];
13
13
  };
14
- export declare function storybookMajorVersion(): number | undefined;
15
- export declare function getInstalledStorybookVersion(): string | undefined;
14
+ export declare function getStorybookVersionToInstall(tree: Tree): string;
15
+ export declare function storybookMajorVersion(tree?: Tree): number | undefined;
16
+ export declare function getInstalledStorybookVersion(tree?: Tree): string | undefined;
16
17
  export declare function safeFileDelete(tree: Tree, path: string): boolean;
17
18
  export type TsConfig = {
18
19
  extends: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAIlC,eAAO,MAAM,SAAS;;;;;;;;;CA0BrB,CAAC;AAGF,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAU1D;AAED,wBAAgB,4BAA4B,IAAI,MAAM,GAAG,SAAS,CAUjE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAOhE;AAED,MAAM,MA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,MAAM,CAAC;CACnB,CA2EA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA4CjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAcvE;AAED,wBAAgB,aAAa,IAAI,MAAM,CAQtC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Constants = void 0;
4
+ exports.getStorybookVersionToInstall = getStorybookVersionToInstall;
4
5
  exports.storybookMajorVersion = storybookMajorVersion;
5
6
  exports.getInstalledStorybookVersion = getInstalledStorybookVersion;
6
7
  exports.safeFileDelete = safeFileDelete;
@@ -10,11 +11,13 @@ exports.findStorybookAndBuildTargetsAndCompiler = findStorybookAndBuildTargetsAn
10
11
  exports.isTheFileAStory = isTheFileAStory;
11
12
  exports.getTsSourceFile = getTsSourceFile;
12
13
  exports.pleaseUpgrade = pleaseUpgrade;
14
+ const devkit_1 = require("@nx/devkit");
13
15
  const fs_1 = require("fs");
14
16
  const js_1 = require("@nx/js");
15
17
  const ts = require("typescript");
16
18
  const semver_1 = require("semver");
17
19
  const path_1 = require("path");
20
+ const versions_1 = require("./versions");
18
21
  exports.Constants = {
19
22
  addonDependencies: ['@storybook/addons'],
20
23
  tsConfigExclusions: ['stories', '**/*.stories.ts'],
@@ -42,7 +45,33 @@ exports.Constants = {
42
45
  '@storybook/web-components-vite',
43
46
  ],
44
47
  };
45
- function storybookMajorVersion() {
48
+ function getStorybookVersionToInstall(tree) {
49
+ let storybookVersionToInstall = versions_1.storybookVersion;
50
+ const installedStorybookMajorVersion = storybookMajorVersion(tree);
51
+ const installedStorybookVersion = getInstalledStorybookVersion(tree);
52
+ if (installedStorybookMajorVersion >= 7 &&
53
+ installedStorybookVersion &&
54
+ (0, semver_1.gte)(installedStorybookVersion, '7.0.0')) {
55
+ storybookVersionToInstall = installedStorybookVersion;
56
+ }
57
+ return storybookVersionToInstall;
58
+ }
59
+ function storybookMajorVersion(tree) {
60
+ let foundStorybookPackageVersion;
61
+ if (tree) {
62
+ const rootPkgJson = (0, devkit_1.readJson)(tree, 'package.json');
63
+ foundStorybookPackageVersion =
64
+ rootPkgJson?.dependencies?.['storybook'] ||
65
+ rootPkgJson?.devDependencies?.['storybook'];
66
+ }
67
+ if (foundStorybookPackageVersion) {
68
+ try {
69
+ return (0, semver_1.major)(foundStorybookPackageVersion);
70
+ }
71
+ catch {
72
+ // unable to parse, fallback to requiring version from disk
73
+ }
74
+ }
46
75
  try {
47
76
  const storybookPackageVersion = require((0, path_1.join)('storybook', 'package.json')).version;
48
77
  return (0, semver_1.major)(storybookPackageVersion);
@@ -51,7 +80,18 @@ function storybookMajorVersion() {
51
80
  return undefined;
52
81
  }
53
82
  }
54
- function getInstalledStorybookVersion() {
83
+ function getInstalledStorybookVersion(tree) {
84
+ let foundStorybookPackageVersion;
85
+ if (tree) {
86
+ const rootPkgJson = (0, devkit_1.readJson)(tree, 'package.json');
87
+ foundStorybookPackageVersion =
88
+ rootPkgJson?.dependencies?.['storybook'] ||
89
+ rootPkgJson?.devDependencies?.['storybook'];
90
+ }
91
+ if (foundStorybookPackageVersion) {
92
+ return foundStorybookPackageVersion;
93
+ }
94
+ // unable to find in root packageJson, fallback to requiring version from disk
55
95
  try {
56
96
  const storybookPackageVersion = require((0, path_1.join)('storybook', 'package.json')).version;
57
97
  return storybookPackageVersion;
@@ -2,7 +2,7 @@ export declare const nxVersion: any;
2
2
  export declare const litVersion = "^2.6.1";
3
3
  export declare const tsNodeVersion = "10.9.1";
4
4
  export declare const tsLibVersion = "^2.3.0";
5
- export declare const storybookVersion = "^9.0.5";
5
+ export declare const storybookVersion = "^10.0.0";
6
6
  export declare const reactVersion = "^18.2.0";
7
7
  export declare const viteVersion = "^6.0.0";
8
8
  export declare const coreJsVersion = "^3.36.1";
@@ -1 +1 @@
1
- {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,aAAa,YAAY,CAAC"}
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,aAAa,YAAY,CAAC"}
@@ -5,7 +5,7 @@ exports.nxVersion = require('../../package.json').version;
5
5
  exports.litVersion = '^2.6.1';
6
6
  exports.tsNodeVersion = '10.9.1';
7
7
  exports.tsLibVersion = '^2.3.0';
8
- exports.storybookVersion = '^9.0.5';
8
+ exports.storybookVersion = '^10.0.0';
9
9
  exports.reactVersion = '^18.2.0';
10
10
  exports.viteVersion = '^6.0.0';
11
11
  exports.coreJsVersion = '^3.36.1';