@nx/storybook 20.3.0-beta.0 → 20.3.0-beta.1
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/package.json +5 -5
- package/src/generators/configuration/configuration.js +2 -3
- package/src/generators/configuration/lib/util-functions.d.ts +2 -2
- package/src/generators/configuration/lib/util-functions.js +10 -7
- package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +16 -1
- package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "20.3.0-beta.
|
|
3
|
+
"version": "20.3.0-beta.1",
|
|
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,13 +33,13 @@
|
|
|
33
33
|
"migrations": "./migrations.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nx/devkit": "20.3.0-beta.
|
|
36
|
+
"@nx/devkit": "20.3.0-beta.1",
|
|
37
37
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
38
38
|
"semver": "^7.5.3",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/cypress": "20.3.0-beta.
|
|
41
|
-
"@nx/js": "20.3.0-beta.
|
|
42
|
-
"@nx/eslint": "20.3.0-beta.
|
|
40
|
+
"@nx/cypress": "20.3.0-beta.1",
|
|
41
|
+
"@nx/js": "20.3.0-beta.1",
|
|
42
|
+
"@nx/eslint": "20.3.0-beta.1"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
@@ -31,7 +31,6 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
31
31
|
const viteConfigFilePath = viteConfig?.fullConfigPath;
|
|
32
32
|
const viteConfigFileName = viteConfig?.viteConfigFileName;
|
|
33
33
|
const nextConfigFilePath = (0, util_functions_1.findNextConfig)(tree, root);
|
|
34
|
-
const metroConfigFilePath = (0, util_functions_1.findMetroConfig)(tree, root);
|
|
35
34
|
if (viteConfigFilePath) {
|
|
36
35
|
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
37
36
|
devkit_1.logger.info(`Your project ${schema.project} uses Vite as a bundler.
|
|
@@ -67,8 +66,8 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
67
66
|
? 'components'
|
|
68
67
|
: 'src';
|
|
69
68
|
const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
|
|
70
|
-
const
|
|
71
|
-
(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,
|
|
69
|
+
const usesReactNative = (0, util_functions_1.isUsingReactNative)(schema.project);
|
|
70
|
+
(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);
|
|
72
71
|
if (schema.uiFramework !== '@storybook/angular') {
|
|
73
72
|
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
74
73
|
}
|
|
@@ -19,7 +19,7 @@ export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureS
|
|
|
19
19
|
export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
|
|
20
20
|
export declare function addStorybookToNamedInputs(tree: Tree): void;
|
|
21
21
|
export declare function addStorybookToTargetDefaults(tree: Tree, 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,
|
|
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;
|
|
23
23
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
24
24
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
25
25
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
@@ -30,5 +30,5 @@ export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
|
30
30
|
viteConfigFileName: string | undefined;
|
|
31
31
|
};
|
|
32
32
|
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function isUsingReactNative(projectName: string): boolean;
|
|
34
34
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|
|
@@ -19,7 +19,7 @@ exports.workspaceHasRootProject = workspaceHasRootProject;
|
|
|
19
19
|
exports.rootFileIsTs = rootFileIsTs;
|
|
20
20
|
exports.findViteConfig = findViteConfig;
|
|
21
21
|
exports.findNextConfig = findNextConfig;
|
|
22
|
-
exports.
|
|
22
|
+
exports.isUsingReactNative = isUsingReactNative;
|
|
23
23
|
exports.renameAndMoveOldTsConfig = renameAndMoveOldTsConfig;
|
|
24
24
|
const devkit_1 = require("@nx/devkit");
|
|
25
25
|
const eslint_1 = require("@nx/eslint");
|
|
@@ -398,7 +398,7 @@ function addStorybookToTargetDefaults(tree, setCache = true) {
|
|
|
398
398
|
}
|
|
399
399
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
400
400
|
}
|
|
401
|
-
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName,
|
|
401
|
+
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, usesReactNative) {
|
|
402
402
|
let projectDirectory = projectType === 'application'
|
|
403
403
|
? isNextJs
|
|
404
404
|
? 'components'
|
|
@@ -431,7 +431,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
431
431
|
viteConfigFilePath,
|
|
432
432
|
hasPlugin,
|
|
433
433
|
viteConfigFileName,
|
|
434
|
-
|
|
434
|
+
usesReactNative,
|
|
435
435
|
});
|
|
436
436
|
if (js) {
|
|
437
437
|
(0, devkit_1.toJS)(tree);
|
|
@@ -506,10 +506,13 @@ function findNextConfig(tree, projectRoot) {
|
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
function
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
return
|
|
509
|
+
function isUsingReactNative(projectName) {
|
|
510
|
+
try {
|
|
511
|
+
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
512
|
+
return projectGraph?.dependencies?.[projectName]?.some((dep) => dep.target === 'npm:react-native');
|
|
513
|
+
}
|
|
514
|
+
catch {
|
|
515
|
+
return false;
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
518
|
function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree) {
|
|
@@ -25,7 +25,7 @@ const config = {
|
|
|
25
25
|
<% } %>
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
<% if (
|
|
28
|
+
<% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
|
|
29
29
|
if (config.resolve) {
|
|
30
30
|
config.resolve.alias = {
|
|
31
31
|
...config.resolve.alias,
|
|
@@ -43,6 +43,21 @@ const config = {
|
|
|
43
43
|
},<% } %><% if (usesVite && !viteConfigFilePath) { %>
|
|
44
44
|
viteFinal: async (config) =>
|
|
45
45
|
mergeConfig(config, {
|
|
46
|
+
<% if (usesReactNative) { %>define: {
|
|
47
|
+
global: 'window',
|
|
48
|
+
},
|
|
49
|
+
resolve: {
|
|
50
|
+
extensions: [
|
|
51
|
+
'.web.tsx',
|
|
52
|
+
'.web.ts',
|
|
53
|
+
'.web.jsx',
|
|
54
|
+
'.web.js',
|
|
55
|
+
...(config.resolve.extensions ?? []),
|
|
56
|
+
],
|
|
57
|
+
alias: {
|
|
58
|
+
'react-native': 'react-native-web',
|
|
59
|
+
},
|
|
60
|
+
},<% } %>
|
|
46
61
|
plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %>nxViteTsPaths()],
|
|
47
62
|
}),
|
|
48
63
|
<% } %>
|
|
@@ -25,7 +25,7 @@ const config: StorybookConfig = {
|
|
|
25
25
|
<% } %>
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
<% if (
|
|
28
|
+
<% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
|
|
29
29
|
if (config.resolve) {
|
|
30
30
|
config.resolve.alias = {
|
|
31
31
|
...config.resolve.alias,
|
|
@@ -43,6 +43,21 @@ const config: StorybookConfig = {
|
|
|
43
43
|
},<% } %><% if (usesVite && !viteConfigFilePath) { %>
|
|
44
44
|
viteFinal: async (config) =>
|
|
45
45
|
mergeConfig(config, {
|
|
46
|
+
<% if (usesReactNative) { %>define: {
|
|
47
|
+
global: 'window',
|
|
48
|
+
},
|
|
49
|
+
resolve: {
|
|
50
|
+
extensions: [
|
|
51
|
+
'.web.tsx',
|
|
52
|
+
'.web.ts',
|
|
53
|
+
'.web.jsx',
|
|
54
|
+
'.web.js',
|
|
55
|
+
...(config.resolve?.extensions ?? []),
|
|
56
|
+
],
|
|
57
|
+
alias: {
|
|
58
|
+
'react-native': 'react-native-web',
|
|
59
|
+
},
|
|
60
|
+
},<% } %>
|
|
46
61
|
plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %>nxViteTsPaths()],
|
|
47
62
|
}),
|
|
48
63
|
<% } %>
|