@nx/storybook 24.0.0-beta.1 → 24.0.0-beta.3

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 (31) hide show
  1. package/dist/src/generators/configuration/configuration.js +14 -32
  2. package/dist/src/generators/configuration/files/v10/project-files/.storybook/main.js__tmpl__ +8 -12
  3. package/dist/src/generators/configuration/files/v10/project-files-ts/.storybook/main.ts__tmpl__ +8 -11
  4. package/dist/src/generators/configuration/files/v9/project-files/.storybook/main.js__tmpl__ +8 -12
  5. package/dist/src/generators/configuration/files/v9/project-files-ts/.storybook/main.ts__tmpl__ +8 -11
  6. package/dist/src/generators/configuration/lib/util-functions.d.ts +1 -3
  7. package/dist/src/generators/configuration/lib/util-functions.js +8 -79
  8. package/dist/src/generators/configuration/schema.d.ts +0 -2
  9. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +4 -3
  10. package/dist/src/generators/init/init.js +36 -54
  11. package/dist/src/generators/init/schema.d.ts +0 -1
  12. package/dist/src/generators/migrate-10/files/ai-instructions-for-cjs-esm.md +2 -2
  13. package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +12 -0
  14. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
  15. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +15 -0
  16. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +88 -0
  17. package/dist/src/utils/utilities.d.ts +0 -1
  18. package/dist/src/utils/utilities.js +0 -12
  19. package/dist/src/utils/versions.d.ts +1 -0
  20. package/dist/src/utils/versions.js +2 -1
  21. package/executors.json +1 -12
  22. package/migrations.json +7 -0
  23. package/package.json +8 -8
  24. package/dist/src/executors/build-storybook/build-storybook.impl.d.ts +0 -5
  25. package/dist/src/executors/build-storybook/build-storybook.impl.js +0 -32
  26. package/dist/src/executors/build-storybook/schema.json +0 -114
  27. package/dist/src/executors/storybook/schema.json +0 -119
  28. package/dist/src/executors/storybook/storybook.impl.d.ts +0 -9
  29. package/dist/src/executors/storybook/storybook.impl.js +0 -35
  30. package/dist/src/utils/deprecation.d.ts +0 -5
  31. package/dist/src/utils/deprecation.js +0 -21
@@ -7,7 +7,6 @@ const internal_1 = require("@nx/devkit/internal");
7
7
  const semver_1 = require("semver");
8
8
  const js_1 = require("@nx/js");
9
9
  const init_1 = require("../init/init");
10
- const deprecation_1 = require("../../utils/deprecation");
11
10
  const assert_supported_storybook_version_1 = require("../../utils/assert-supported-storybook-version");
12
11
  const util_functions_1 = require("./lib/util-functions");
13
12
  const utilities_1 = require("../../utils/utilities");
@@ -16,7 +15,7 @@ const ensure_dependencies_1 = require("./lib/ensure-dependencies");
16
15
  const edit_root_tsconfig_1 = require("./lib/edit-root-tsconfig");
17
16
  const internal_2 = require("@nx/js/internal");
18
17
  function configurationGenerator(tree, schema) {
19
- return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
18
+ return configurationGeneratorInternal(tree, schema);
20
19
  }
21
20
  async function configurationGeneratorInternal(tree, rawSchema) {
22
21
  (0, assert_supported_storybook_version_1.assertSupportedStorybookVersion)(tree);
@@ -24,7 +23,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
24
23
  if (storybookMajor === 8) {
25
24
  devkit_1.logger.warn(`Support for Storybook 8 is deprecated. Please upgrade to Storybook 9. See https://nx.dev/nx-api/storybook/generators/migrate-9 for more details.`);
26
25
  }
27
- const schema = normalizeSchema(tree, rawSchema);
26
+ const schema = normalizeSchema(rawSchema);
28
27
  const tasks = [];
29
28
  const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
30
29
  const { compiler } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
@@ -54,22 +53,20 @@ async function configurationGeneratorInternal(tree, rawSchema) {
54
53
  tasks.push(jsInitTask);
55
54
  const initTask = await (0, init_1.initGenerator)(tree, {
56
55
  skipFormat: true,
57
- addPlugin: schema.addPlugin,
58
56
  });
59
57
  tasks.push(initTask);
60
58
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, { uiFramework: schema.uiFramework }));
61
59
  (0, edit_root_tsconfig_1.editRootTsConfig)(tree);
62
- const nxJson = (0, devkit_1.readNxJson)(tree);
63
- const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
64
- ? p === '@nx/storybook/plugin'
65
- : p.plugin === '@nx/storybook/plugin');
66
60
  const mainDir = !!nextConfigFilePath &&
67
61
  (0, internal_2.getProjectType)(tree, root, projectType) === 'application'
68
62
  ? 'components'
69
63
  : 'src';
70
64
  const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
71
65
  const usesReactNative = (0, util_functions_1.isUsingReactNative)(schema.project);
72
- (0, util_functions_1.createProjectStorybookDir)(tree, schema.project, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextConfigFilePath, compiler === 'swc', usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, usesReactNative);
66
+ // resolve.tsconfigPaths is native only from Vite 8; older majors ignore it.
67
+ const installedVite = (0, semver_1.coerce)((0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'vite') ?? '');
68
+ const useNativeTsconfigPaths = !installedVite || (0, semver_1.major)(installedVite) >= 8;
69
+ (0, util_functions_1.createProjectStorybookDir)(tree, schema.project, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextConfigFilePath, compiler === 'swc', usesVite, viteConfigFilePath, viteConfigFileName, usesReactNative, useNativeTsconfigPaths);
73
70
  if (schema.uiFramework !== '@storybook/angular') {
74
71
  (0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
75
72
  }
@@ -79,18 +76,11 @@ async function configurationGeneratorInternal(tree, rawSchema) {
79
76
  (0, util_functions_1.updateLintConfig)(tree, schema);
80
77
  (0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
81
78
  (0, util_functions_1.addStorybookToNamedInputs)(tree, schema);
82
- if (!hasPlugin) {
83
- (0, util_functions_1.addStorybookToTargetDefaults)(tree, schema);
84
- }
85
79
  let devDeps = {};
86
- if (!hasPlugin || schema.addExplicitTargets) {
87
- (0, deprecation_1.warnStorybookExecutorGenerating)();
88
- if (schema.uiFramework === '@storybook/angular') {
89
- (0, util_functions_1.addAngularStorybookTarget)(tree, schema.project, schema.interactionTests);
90
- }
91
- else {
92
- (0, util_functions_1.addStorybookTarget)(tree, schema.project, schema.uiFramework, schema.interactionTests);
93
- }
80
+ if (schema.uiFramework === '@storybook/angular') {
81
+ // `@storybook/angular:*` builders are third-party and still supported, so
82
+ // Angular keeps an explicit target rather than relying on inference.
83
+ (0, util_functions_1.addAngularStorybookTarget)(tree, schema.project, schema.interactionTests);
94
84
  if (schema.configureStaticServe) {
95
85
  await (0, util_functions_1.addStaticTarget)(tree, schema);
96
86
  }
@@ -118,6 +108,9 @@ async function configurationGeneratorInternal(tree, rawSchema) {
118
108
  }
119
109
  if (usesVite && !viteConfigFilePath) {
120
110
  devDeps['tslib'] = versions_1.tsLibVersion;
111
+ if (!useNativeTsconfigPaths) {
112
+ devDeps['vite-tsconfig-paths'] = versions_1.viteTsconfigPathsVersion;
113
+ }
121
114
  }
122
115
  if (schema.configureStaticServe) {
123
116
  devDeps['@nx/web'] = versions_1.nxVersion;
@@ -130,28 +123,17 @@ async function configurationGeneratorInternal(tree, rawSchema) {
130
123
  });
131
124
  devDeps['core-js'] = versions_1.coreJsVersion;
132
125
  }
133
- if (schema.uiFramework?.endsWith('-vite') && !viteConfigFilePath) {
134
- // This means that the user has selected a Vite framework
135
- // but the project does not have Vite configuration.
136
- // We need to install the @nx/vite plugin in order to be able to use
137
- // the nxViteTsPaths plugin to register the tsconfig paths in Vite.
138
- devDeps['@nx/vite'] = versions_1.nxVersion;
139
- }
140
126
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDeps, undefined, true));
141
127
  if (!schema.skipFormat) {
142
128
  await (0, devkit_1.formatFiles)(tree);
143
129
  }
144
130
  return (0, devkit_1.runTasksInSerial)(...tasks);
145
131
  }
146
- function normalizeSchema(tree, schema) {
147
- const nxJson = (0, devkit_1.readNxJson)(tree);
148
- const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
149
- nxJson.useInferencePlugins !== false;
132
+ function normalizeSchema(schema) {
150
133
  const defaults = {
151
134
  interactionTests: true,
152
135
  js: false,
153
136
  tsConfiguration: true,
154
- addPlugin,
155
137
  };
156
138
  return {
157
139
  ...defaults,
@@ -2,9 +2,9 @@ import { fileURLToPath } from "node:url";
2
2
  import { dirname } from "node:path";
3
3
 
4
4
  <% if (usesVite && !viteConfigFilePath) { %>
5
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
6
5
  import { mergeConfig } from 'vite';
7
- <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
6
+ <% if (!useNativeTsconfigPaths) { %>import tsconfigPaths from 'vite-tsconfig-paths';
7
+ <% } %><% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
8
8
 
9
9
  const config = {
10
10
  stories: [
@@ -16,16 +16,11 @@ const config = {
16
16
  framework: {
17
17
  name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
18
18
  options: {
19
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
19
+ <% if (usesVite && viteConfigFilePath) { %>
20
20
  builder: {
21
21
  viteConfigPath: '<%= viteConfigFileName %>',
22
22
  },
23
23
  <% } %>
24
- <% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
25
- builder: {
26
- viteConfigPath: '<%= viteConfigFilePath %>',
27
- },
28
- <% } %>
29
24
  },
30
25
  },
31
26
  <% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
@@ -48,8 +43,9 @@ const config = {
48
43
  mergeConfig(config, {
49
44
  <% if (usesReactNative) { %>define: {
50
45
  global: 'window',
51
- },
46
+ },<% } %>
52
47
  resolve: {
48
+ <% if (useNativeTsconfigPaths) { %> tsconfigPaths: true,<% } %><% if (usesReactNative) { %>
53
49
  extensions: [
54
50
  '.mjs',
55
51
  '.web.tsx',
@@ -66,9 +62,9 @@ const config = {
66
62
  ],
67
63
  alias: {
68
64
  'react-native': 'react-native-web',
69
- },
70
- },<% } %>
71
- plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %>nxViteTsPaths()],
65
+ },<% } %>
66
+ },
67
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if (!useNativeTsconfigPaths) { %>tsconfigPaths({ loose: true })<% } %>],
72
68
  }),
73
69
  <% } %>
74
70
  };
@@ -4,9 +4,9 @@ import { dirname } from "node:path";
4
4
 
5
5
  <% } %>import type { StorybookConfig } from '<%= uiFramework %>';
6
6
  <% if (usesVite && !viteConfigFilePath) { %>
7
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
8
7
  import { mergeConfig } from 'vite';
9
- <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
8
+ <% if (!useNativeTsconfigPaths) { %>import tsconfigPaths from 'vite-tsconfig-paths';
9
+ <% } %><% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
10
10
 
11
11
  const config: StorybookConfig = {
12
12
  stories: [
@@ -18,14 +18,10 @@ const config: StorybookConfig = {
18
18
  framework: {
19
19
  name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
20
20
  options: {
21
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
21
+ <% if (usesVite && viteConfigFilePath) { %>
22
22
  builder: {
23
23
  viteConfigPath: '<%= viteConfigFileName %>',
24
24
  },
25
- <% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
26
- builder: {
27
- viteConfigPath: '<%= viteConfigFilePath %>',
28
- },
29
25
  <% } %>
30
26
  },
31
27
  },
@@ -49,8 +45,9 @@ const config: StorybookConfig = {
49
45
  mergeConfig(config, {
50
46
  <% if (usesReactNative) { %>define: {
51
47
  global: 'window',
52
- },
48
+ },<% } %>
53
49
  resolve: {
50
+ <% if (useNativeTsconfigPaths) { %> tsconfigPaths: true,<% } %><% if (usesReactNative) { %>
54
51
  extensions: [
55
52
  '.mjs',
56
53
  '.web.tsx',
@@ -67,9 +64,9 @@ const config: StorybookConfig = {
67
64
  ],
68
65
  alias: {
69
66
  'react-native': 'react-native-web',
70
- },
71
- },<% } %>
72
- plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %>nxViteTsPaths()],
67
+ },<% } %>
68
+ },
69
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %><% if (!useNativeTsconfigPaths) { %>tsconfigPaths({ loose: true })<% } %>],
73
70
  }),
74
71
  <% } %>
75
72
  };
@@ -1,7 +1,7 @@
1
1
  <% if (usesVite && !viteConfigFilePath) { %>
2
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
3
2
  import { mergeConfig } from 'vite';
4
- <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
3
+ <% if (!useNativeTsconfigPaths) { %>import tsconfigPaths from 'vite-tsconfig-paths';
4
+ <% } %><% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
5
5
 
6
6
  const config = {
7
7
  stories: [
@@ -13,16 +13,11 @@ const config = {
13
13
  framework: {
14
14
  name: '<%= uiFramework %>',
15
15
  options: {
16
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
16
+ <% if (usesVite && viteConfigFilePath) { %>
17
17
  builder: {
18
18
  viteConfigPath: '<%= viteConfigFileName %>',
19
19
  },
20
20
  <% } %>
21
- <% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
22
- builder: {
23
- viteConfigPath: '<%= viteConfigFilePath %>',
24
- },
25
- <% } %>
26
21
  },
27
22
  },
28
23
  <% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
@@ -45,8 +40,9 @@ const config = {
45
40
  mergeConfig(config, {
46
41
  <% if (usesReactNative) { %>define: {
47
42
  global: 'window',
48
- },
43
+ },<% } %>
49
44
  resolve: {
45
+ <% if (useNativeTsconfigPaths) { %> tsconfigPaths: true,<% } %><% if (usesReactNative) { %>
50
46
  extensions: [
51
47
  '.mjs',
52
48
  '.web.tsx',
@@ -63,9 +59,9 @@ const config = {
63
59
  ],
64
60
  alias: {
65
61
  'react-native': 'react-native-web',
66
- },
67
- },<% } %>
68
- plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %>nxViteTsPaths()],
62
+ },<% } %>
63
+ },
64
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if (!useNativeTsconfigPaths) { %>tsconfigPaths({ loose: true })<% } %>],
69
65
  }),
70
66
  <% } %>
71
67
  };
@@ -1,8 +1,8 @@
1
1
  import type { StorybookConfig } from '<%= uiFramework %>';
2
2
  <% if (usesVite && !viteConfigFilePath) { %>
3
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
4
3
  import { mergeConfig } from 'vite';
5
- <% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
4
+ <% if (!useNativeTsconfigPaths) { %>import tsconfigPaths from 'vite-tsconfig-paths';
5
+ <% } %><% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
6
6
 
7
7
  const config: StorybookConfig = {
8
8
  stories: [
@@ -14,14 +14,10 @@ const config: StorybookConfig = {
14
14
  framework: {
15
15
  name: '<%= uiFramework %>',
16
16
  options: {
17
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
17
+ <% if (usesVite && viteConfigFilePath) { %>
18
18
  builder: {
19
19
  viteConfigPath: '<%= viteConfigFileName %>',
20
20
  },
21
- <% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
22
- builder: {
23
- viteConfigPath: '<%= viteConfigFilePath %>',
24
- },
25
21
  <% } %>
26
22
  },
27
23
  },
@@ -45,8 +41,9 @@ const config: StorybookConfig = {
45
41
  mergeConfig(config, {
46
42
  <% if (usesReactNative) { %>define: {
47
43
  global: 'window',
48
- },
44
+ },<% } %>
49
45
  resolve: {
46
+ <% if (useNativeTsconfigPaths) { %> tsconfigPaths: true,<% } %><% if (usesReactNative) { %>
50
47
  extensions: [
51
48
  '.mjs',
52
49
  '.web.tsx',
@@ -63,9 +60,9 @@ const config: StorybookConfig = {
63
60
  ],
64
61
  alias: {
65
62
  'react-native': 'react-native-web',
66
- },
67
- },<% } %>
68
- plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %>nxViteTsPaths()],
63
+ },<% } %>
64
+ },
65
+ plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %><% if (!useNativeTsconfigPaths) { %>tsconfigPaths({ loose: true })<% } %>],
69
66
  }),
70
67
  <% } %>
71
68
  };
@@ -1,7 +1,6 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { StorybookConfigureSchema } from '../schema';
3
3
  import { UiFramework } from '../../../utils/models';
4
- export declare function addStorybookTarget(tree: Tree, projectName: string, uiFramework: UiFramework, interactionTests: boolean): void;
5
4
  export declare function addAngularStorybookTarget(tree: Tree, projectName: string, interactionTests: boolean): void;
6
5
  export declare function addStaticTarget(tree: Tree, opts: StorybookConfigureSchema): Promise<void>;
7
6
  export declare function createStorybookTsconfigFile(tree: Tree, projectRoot: string, uiFramework: UiFramework, isRootProject: boolean, mainDir: 'components' | 'src'): void;
@@ -18,8 +17,7 @@ export declare function configureTsSolutionConfig(tree: Tree, schema: StorybookC
18
17
  export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureSchema): void;
19
18
  export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
20
19
  export declare function addStorybookToNamedInputs(tree: Tree, schema: StorybookConfigureSchema): void;
21
- export declare function addStorybookToTargetDefaults(tree: Tree, schema: StorybookConfigureSchema, setCache?: boolean): void;
22
- export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string, hasPlugin?: boolean, viteConfigFileName?: string, usesReactNative?: boolean): void;
20
+ export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string, viteConfigFileName?: string, usesReactNative?: boolean, useNativeTsconfigPaths?: boolean): void;
23
21
  export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
24
22
  export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
25
23
  export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addStorybookTarget = addStorybookTarget;
4
3
  exports.addAngularStorybookTarget = addAngularStorybookTarget;
5
4
  exports.addStaticTarget = addStaticTarget;
6
5
  exports.createStorybookTsconfigFile = createStorybookTsconfigFile;
@@ -10,7 +9,6 @@ exports.configureTsSolutionConfig = configureTsSolutionConfig;
10
9
  exports.updateLintConfig = updateLintConfig;
11
10
  exports.normalizeSchema = normalizeSchema;
12
11
  exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
13
- exports.addStorybookToTargetDefaults = addStorybookToTargetDefaults;
14
12
  exports.createProjectStorybookDir = createProjectStorybookDir;
15
13
  exports.getTsConfigPath = getTsConfigPath;
16
14
  exports.addBuildStorybookToCacheableOperations = addBuildStorybookToCacheableOperations;
@@ -26,46 +24,8 @@ const path_1 = require("path");
26
24
  const utilities_1 = require("../../../utils/utilities");
27
25
  const versions_1 = require("../../../utils/versions");
28
26
  const internal_1 = require("@nx/eslint/internal");
29
- const internal_2 = require("@nx/devkit/internal");
30
- const internal_3 = require("@nx/js/internal");
27
+ const internal_2 = require("@nx/js/internal");
31
28
  const DEFAULT_PORT = 4400;
32
- function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
33
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
34
- projectConfig.targets['storybook'] = {
35
- executor: '@nx/storybook:storybook',
36
- options: {
37
- port: DEFAULT_PORT,
38
- configDir: `${projectConfig.root}/.storybook`,
39
- },
40
- configurations: {
41
- ci: {
42
- quiet: true,
43
- },
44
- },
45
- };
46
- projectConfig.targets['build-storybook'] = {
47
- executor: '@nx/storybook:build',
48
- outputs: ['{options.outputDir}'],
49
- options: {
50
- outputDir: (0, devkit_1.joinPathFragments)('dist/storybook', projectName),
51
- configDir: `${projectConfig.root}/.storybook`,
52
- },
53
- configurations: {
54
- ci: {
55
- quiet: true,
56
- },
57
- },
58
- };
59
- if (interactionTests === true) {
60
- projectConfig.targets['test-storybook'] = {
61
- executor: 'nx:run-commands',
62
- options: {
63
- command: `test-storybook -c ${projectConfig.root}/.storybook --url=http://localhost:${DEFAULT_PORT}`,
64
- },
65
- };
66
- }
67
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
68
- }
69
29
  function addAngularStorybookTarget(tree, projectName, interactionTests) {
70
30
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
71
31
  const { ngBuildTarget } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(projectConfig.targets);
@@ -126,7 +86,7 @@ async function addStaticTarget(tree, opts) {
126
86
  function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
127
87
  const storybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
128
88
  const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
129
- const useTsSolution = (0, internal_3.isUsingTsSolutionSetup)(tree);
89
+ const useTsSolution = (0, internal_2.isUsingTsSolutionSetup)(tree);
130
90
  // First let's check if old configuration file exists
131
91
  // If it exists, let's rename it and move it to the new location
132
92
  const oldStorybookTsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, '.storybook/tsconfig.json');
@@ -175,7 +135,7 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
175
135
  ],
176
136
  };
177
137
  if (useTsSolution) {
178
- const runtimeConfig = (0, internal_3.findRuntimeTsConfigName)(projectRoot, tree);
138
+ const runtimeConfig = (0, internal_2.findRuntimeTsConfigName)(projectRoot, tree);
179
139
  if (runtimeConfig) {
180
140
  storybookTsConfig.references ??= [];
181
141
  storybookTsConfig.references.push({
@@ -371,39 +331,8 @@ function addStorybookToNamedInputs(tree, schema) {
371
331
  (0, devkit_1.updateNxJson)(tree, nxJson);
372
332
  }
373
333
  }
374
- function addStorybookToTargetDefaults(tree, schema, setCache = true) {
375
- const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
376
- const existing = (0, internal_2.findTargetDefault)(nxJson.targetDefaults, {
377
- target: 'build-storybook',
378
- });
379
- const inputs = existing?.inputs
380
- ? [...existing.inputs]
381
- : [
382
- 'default',
383
- nxJson.namedInputs && 'production' in nxJson.namedInputs
384
- ? '^production'
385
- : '^default',
386
- ];
387
- if (!inputs.includes('{projectRoot}/.storybook/**/*')) {
388
- inputs.push('{projectRoot}/.storybook/**/*');
389
- }
390
- // Drop the negation glob so Storybook rebuilds when .storybook changes.
391
- const negatedIndex = inputs.indexOf('!{projectRoot}/.storybook/**/*');
392
- if (negatedIndex !== -1)
393
- inputs.splice(negatedIndex, 1);
394
- if (schema.uiFramework !== '@storybook/angular' &&
395
- !inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
396
- inputs.push('{projectRoot}/tsconfig.storybook.json');
397
- }
398
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
399
- target: 'build-storybook',
400
- ...(setCache && existing?.cache === undefined ? { cache: true } : {}),
401
- inputs,
402
- });
403
- (0, devkit_1.updateNxJson)(tree, nxJson);
404
- }
405
- function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, usesReactNative) {
406
- let projectDirectory = (0, internal_3.getProjectType)(tree, root, projectType) ===
334
+ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, viteConfigFileName, usesReactNative, useNativeTsconfigPaths = true) {
335
+ let projectDirectory = (0, internal_2.getProjectType)(tree, root, projectType) ===
407
336
  'application'
408
337
  ? isNextJs
409
338
  ? 'components'
@@ -431,15 +360,15 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
431
360
  interactionTests,
432
361
  mainDir,
433
362
  isNextJs: isNextJs &&
434
- (0, internal_3.getProjectType)(tree, root, projectType) ===
363
+ (0, internal_2.getProjectType)(tree, root, projectType) ===
435
364
  'application',
436
365
  usesSwc,
437
366
  usesVite,
438
367
  isRootProject: projectIsRootProjectInStandaloneWorkspace,
439
368
  viteConfigFilePath,
440
- hasPlugin,
441
369
  viteConfigFileName,
442
370
  usesReactNative,
371
+ useNativeTsconfigPaths,
443
372
  });
444
373
  if (js) {
445
374
  (0, devkit_1.toJS)(tree);
@@ -458,7 +387,7 @@ function getTsConfigPath(tree, projectName, path) {
458
387
  const { root, projectType } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
459
388
  return (0, path_1.join)(root, path?.length > 0
460
389
  ? path
461
- : (0, internal_3.getProjectType)(tree, root, projectType) === 'application'
390
+ : (0, internal_2.getProjectType)(tree, root, projectType) === 'application'
462
391
  ? 'tsconfig.app.json'
463
392
  : 'tsconfig.lib.json');
464
393
  }
@@ -10,10 +10,8 @@ export interface StorybookConfigureSchema {
10
10
  tsConfiguration?: boolean;
11
11
  configureStaticServe?: boolean;
12
12
  skipFormat?: boolean;
13
- addPlugin?: boolean;
14
13
 
15
14
  /**
16
15
  * @internal
17
16
  */
18
- addExplicitTargets?: boolean;
19
17
  }
@@ -40,8 +40,9 @@ async function convertToInferred(tree, options) {
40
40
  await (0, devkit_1.formatFiles)(tree);
41
41
  }
42
42
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { storybook: versions_1.storybookVersion }, undefined, true);
43
- return (0, devkit_1.runTasksInSerial)(installTask, () => {
44
- migrationLogs.flushLogs();
45
- });
43
+ // Flushed now rather than in the callback so remove-deprecated-executors, which
44
+ // skips the install callback, still prints these.
45
+ migrationLogs.flushLogs();
46
+ return installTask;
46
47
  }
47
48
  exports.default = convertToInferred;
@@ -23,15 +23,6 @@ function checkDependenciesInstalled(host, schema) {
23
23
  });
24
24
  return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions ?? true);
25
25
  }
26
- function addCacheableOperation(tree) {
27
- const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
28
- const cacheableOperations = nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations;
29
- if (cacheableOperations && !cacheableOperations.includes('build-storybook')) {
30
- nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('build-storybook');
31
- }
32
- (0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'build-storybook', cache: true });
33
- (0, devkit_1.updateNxJson)(tree, nxJson);
34
- }
35
26
  function moveToDevDependencies(tree) {
36
27
  let updated = false;
37
28
  (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
@@ -48,54 +39,45 @@ function moveToDevDependencies(tree) {
48
39
  return updated ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
49
40
  }
50
41
  function initGenerator(tree, schema) {
51
- return initGeneratorInternal(tree, { addPlugin: false, ...schema });
42
+ return initGeneratorInternal(tree, schema);
52
43
  }
53
44
  async function initGeneratorInternal(tree, schema) {
54
45
  (0, assert_supported_storybook_version_1.assertSupportedStorybookVersion)(tree);
55
- const nxJson = (0, devkit_1.readNxJson)(tree);
56
- const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
57
- nxJson.useInferencePlugins !== false;
58
- schema.addPlugin ??= addPluginDefault;
59
- if (schema.addPlugin) {
60
- await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/storybook/plugin', plugin_1.createNodesV2, {
61
- serveStorybookTargetName: [
62
- 'storybook',
63
- 'serve:storybook',
64
- 'serve-storybook',
65
- 'storybook:serve',
66
- 'storybook-serve',
67
- ],
68
- buildStorybookTargetName: [
69
- 'build-storybook',
70
- 'build:storybook',
71
- 'storybook:build',
72
- ],
73
- testStorybookTargetName: [
74
- 'test-storybook',
75
- 'test:storybook',
76
- 'storybook:test',
77
- ],
78
- staticStorybookTargetName: [
79
- 'static-storybook',
80
- 'static:storybook',
81
- 'storybook:static',
82
- ],
83
- buildDepsTargetName: [
84
- 'build-deps',
85
- 'storybook:build-deps',
86
- 'storybook-build-deps',
87
- ],
88
- watchDepsTargetName: [
89
- 'watch-deps',
90
- 'storybook:watch-deps',
91
- 'storybook-watch-deps',
92
- ],
93
- }, schema.updatePackageScripts);
94
- (0, update_gitignore_1.updateGitignore)(tree);
95
- }
96
- else {
97
- addCacheableOperation(tree);
98
- }
46
+ await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/storybook/plugin', plugin_1.createNodesV2, {
47
+ serveStorybookTargetName: [
48
+ 'storybook',
49
+ 'serve:storybook',
50
+ 'serve-storybook',
51
+ 'storybook:serve',
52
+ 'storybook-serve',
53
+ ],
54
+ buildStorybookTargetName: [
55
+ 'build-storybook',
56
+ 'build:storybook',
57
+ 'storybook:build',
58
+ ],
59
+ testStorybookTargetName: [
60
+ 'test-storybook',
61
+ 'test:storybook',
62
+ 'storybook:test',
63
+ ],
64
+ staticStorybookTargetName: [
65
+ 'static-storybook',
66
+ 'static:storybook',
67
+ 'storybook:static',
68
+ ],
69
+ buildDepsTargetName: [
70
+ 'build-deps',
71
+ 'storybook:build-deps',
72
+ 'storybook-build-deps',
73
+ ],
74
+ watchDepsTargetName: [
75
+ 'watch-deps',
76
+ 'storybook:watch-deps',
77
+ 'storybook-watch-deps',
78
+ ],
79
+ }, schema.updatePackageScripts);
80
+ (0, update_gitignore_1.updateGitignore)(tree);
99
81
  const tasks = [];
100
82
  if (!schema.skipPackageJson) {
101
83
  tasks.push(moveToDevDependencies(tree));
@@ -3,5 +3,4 @@ export interface Schema {
3
3
  skipPackageJson?: boolean;
4
4
  keepExistingVersions?: boolean;
5
5
  updatePackageScripts?: boolean;
6
- addPlugin?: boolean;
7
6
  }
@@ -57,15 +57,15 @@ B. Convert `require()` to import
57
57
  // FROM (CJS):
58
58
 
59
59
  ```
60
- const { nxViteTsPaths } = require('@nx/vite/plugins/nx-tsconfig-paths.plugin');
61
60
  const { mergeConfig } = require('vite');
61
+ const react = require('@vitejs/plugin-react');
62
62
  ```
63
63
 
64
64
  // TO (ESM):
65
65
 
66
66
  ```
67
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
68
67
  import { mergeConfig } from 'vite';
68
+ import react from '@vitejs/plugin-react';
69
69
  ```
70
70
 
71
71
  C. Handle `path.join()` patterns