@modern-js/main-doc 0.0.0-next-1686852453693 → 0.0.0-next-1686907286928

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/CHANGELOG.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-1686852453693
3
+ ## 0.0.0-next-1686907286928
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [4d4dca08f]
8
- - @modern-js/builder-doc@0.0.0-next-1686852453693
7
+ - Updated dependencies [4d4dca08f6]
8
+ - @modern-js/builder-doc@0.0.0-next-1686907286928
9
9
 
10
10
  ## 2.23.0
11
11
 
@@ -2,6 +2,7 @@
2
2
  title: storybook/
3
3
  sidebar_position: 7
4
4
  ---
5
+
5
6
  # storybook/
6
7
 
7
8
  Modern.js supports debugging using Storybook. When configuring Storybook, you need to configure it in the `config/storybook` directory of the project.
@@ -12,3 +13,26 @@ Please refer to [Storybook Configuration](https://storybook.js.org/docs/react/co
12
13
  Enabling the Visual Testing (Storybook) mode function requires running the new command to enable it under the project first.
13
14
 
14
15
  :::
16
+
17
+ #### Example
18
+
19
+ For the webpack configuration of the Storybook Manager app section, you can configure it by adding the `./config/storybook/main.js` file to configure it.
20
+
21
+ ```js
22
+ // ./config/storybook/main.js
23
+
24
+ module.exports = {
25
+ // it controls the Storybook manager app
26
+ managerWebpack: async (config, options) => {
27
+ // update config here
28
+ return config;
29
+ },
30
+ };
31
+ ```
32
+
33
+ ### Limitation
34
+
35
+ There are some limitations when using the `config/storybook` directory for configuration:
36
+
37
+ - The location where the Story file is stored cannot be modified, that is, the `stories` configuration cannot be modified in the `main.js` file.
38
+ - It is not supported to modify Webpack and Babel related configurations in `main.js`, related requirements can be passed through [`tools.webpack`](/configure/app/tools/webpack.html) /[`tools.babel`](/configure/app/tools/babel.html) modify.
@@ -6,7 +6,7 @@ sidebar_position: 7
6
6
 
7
7
  Application project Storybook files.
8
8
 
9
- You can create files in the `*.stories.[tj]sx` format in the project source code directory `src/` as Storybook files.
9
+ You can create files in the `*.stories.(js|jsx|ts|tsx|mdx)` format in the project source code directory `src/` as Storybook files.
10
10
 
11
11
  Run the `npm run dev story` command in the project to use these files to debug relevant content in Storybook.
12
12
 
@@ -0,0 +1,44 @@
1
+ ---
2
+ sidebar_position: 20
3
+ ---
4
+
5
+ # Using Storybook
6
+
7
+ [Storybook](https://storybook.js.org/) is a tool dedicated to component debugging, providing around component development.
8
+
9
+ - Develop UIs that are more durable
10
+ - Test UIs with less effort and no flakes
11
+ - Document UI for your team to reuse
12
+ - Share how the UI actually works
13
+ - Automate UI workflows
14
+
15
+ ## Enable Storybook debugging
16
+
17
+ The Modern.js framework integrates the Builder's Node Polyfill plugin by default.
18
+
19
+ If you want to debug the component, you can enable Storybook debugging through `pnpm run new`.
20
+
21
+ ```bash
22
+ $ npx modern new
23
+ ? Please select the operation you want: Enable features
24
+ ? Please select the feature name: Enable Visual Testing (Storybook)
25
+ ```
26
+
27
+ After the execution is complete, you only need to register the Modern.js Storybook plugin in the `modern.config.ts` file to enable Storybook debugging capabilities.
28
+
29
+ ```ts title="modern.config.ts"
30
+ import appTools, { defineConfig } from '@modern-js/app-tools';
31
+ import storybookPlugin from '@modern-js/plugin-storybook';
32
+
33
+ export default defineConfig({
34
+ plugins: [appTools(), storybookPlugin()],
35
+ });
36
+ ```
37
+
38
+ ## Debugging code
39
+
40
+ Modern.js recognizes files in the format of [\*.stories.(js|jsx|ts|tsx|mdx)](/apis/app/hooks/src/stories.html) under the project source code directory (src/) by default as Storybook debugging files.
41
+
42
+ ## Configure Storybook
43
+
44
+ In Modern.js, Storybook configuration files can be added to the [`config/storybook`](/apis/app/hooks/config/storybook.html) directory of the project.
@@ -2,6 +2,7 @@
2
2
  title: storybook/
3
3
  sidebar_position: 7
4
4
  ---
5
+
5
6
  # storybook/
6
7
 
7
8
  Modern.js 支持使用 Storybook 进行调试,当需要对 Storybook 进行配置时,需要在项目 config/storybook 目录进行配置。
@@ -12,3 +13,26 @@ Storybook 配置请查看:[Storybook 配置](https://storybook.js.org/docs/rea
12
13
  使用 Storybook 进行调试需要提前在项目下执行 new 命令启用「Visual Testing (Storybook)」模式功能。
13
14
 
14
15
  :::
16
+
17
+ ### 示例
18
+
19
+ 对于 Storybook Manager app 部分的 webpack 配置,可以通过增加 `./config/storybook/main.js` 文件进行配置。
20
+
21
+ ```js
22
+ // ./config/storybook/main.js
23
+
24
+ module.exports = {
25
+ // it controls the Storybook manager app
26
+ managerWebpack: async (config, options) => {
27
+ // update config here
28
+ return config;
29
+ },
30
+ };
31
+ ```
32
+
33
+ ### 限制
34
+
35
+ 在使用 config/storybook 目录进行配置时,存在以下限制:
36
+
37
+ - 不能修改 Story 文件存放的位置,即无法在 `main.js` 文件里修改 `stories` 配置。
38
+ - 不支持在 `main.js` 中修改 Webpack 和 Babel 相关配置,相关需求可通过 [`tools.webpack`](/configure/app/tools/webpack.html) / [`tools.babel`](/configure/app/tools/babel.html) 修改。
@@ -6,7 +6,7 @@ sidebar_position: 7
6
6
 
7
7
  应用项目 Storybook 调试文件。
8
8
 
9
- 可以在项目源码目录 `src/` 下创建 `*.stories.[tj]sx` 格式的文件作为 Storybook 的调试文件。
9
+ 可以在项目源码目录 `src/` 下创建 `*.stories.(js|jsx|ts|tsx|mdx)` 格式的文件作为 Storybook 的调试文件。
10
10
 
11
11
  在项目下执行 `npm run dev story` 命令,支持使用这些文件在 Storybook 中对相关内容进行调试。
12
12
 
@@ -0,0 +1,44 @@
1
+ ---
2
+ sidebar_position: 20
3
+ ---
4
+
5
+ # 使用 Storybook
6
+
7
+ [Storybook](https://storybook.js.org/) 是一个专门用于组件调试的工具,它围绕着组件开发提供了:
8
+
9
+ - 丰富多样的调试能力
10
+ - 可与一些测试工具结合使用
11
+ - 可重复使用的文档内容
12
+ - 可分享能力
13
+ - 工作流程自动化
14
+
15
+ ## 开启 Storybook 调试
16
+
17
+ EdenX 默认集成了 Storybook 的调试能力。
18
+
19
+ 当我们想要对组件进行调试的时候,可以通过 `pnpm run new` 启用 Storybook 调试功能。
20
+
21
+ ```bash
22
+ $ npx modern new
23
+ ? 请选择你想要的操作 启用可选功能
24
+ ? 请选择功能名称 启用「Visual Testing (Storybook)」模式
25
+ ```
26
+
27
+ 执行完成后,你只需在 `modern.config.ts` 文件中注册 Modern.js 的 Storybook 插件,即可启用 Storybook 调试能力。
28
+
29
+ ```ts title="modern.config.ts"
30
+ import appTools, { defineConfig } from '@modern-js/app-tools';
31
+ import storybookPlugin from '@modern-js/plugin-storybook';
32
+
33
+ export default defineConfig({
34
+ plugins: [appTools(), storybookPlugin()],
35
+ });
36
+ ```
37
+
38
+ ## 调试代码
39
+
40
+ Modern.js 默认识别项目源码目录 src/ 下 [\*.stories.(js|jsx|ts|tsx|mdx)](/apis/app/hooks/src/stories.html) 格式的文件作为 Storybook 的调试文件。
41
+
42
+ ## 配置 Storybook
43
+
44
+ 在 Modern.js 中,可以在项目的 [`config/storybook`](/apis/app/hooks/config/storybook.html) 目录下增加 Storybook 配置文件。
package/package.json CHANGED
@@ -15,14 +15,14 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-next-1686852453693",
18
+ "version": "0.0.0-next-1686907286928",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "peerDependencies": {
25
- "@modern-js/builder-doc": "0.0.0-next-1686852453693"
25
+ "@modern-js/builder-doc": "0.0.0-next-1686907286928"
26
26
  },
27
27
  "devDependencies": {
28
28
  "classnames": "^2",
@@ -34,9 +34,9 @@
34
34
  "fs-extra": "^10",
35
35
  "@types/node": "^16",
36
36
  "@types/fs-extra": "^9",
37
- "@modern-js/doc-tools": "0.0.0-next-1686852453693",
38
- "@modern-js/builder-doc": "0.0.0-next-1686852453693",
39
- "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686852453693"
37
+ "@modern-js/builder-doc": "0.0.0-next-1686907286928",
38
+ "@modern-js/doc-tools": "0.0.0-next-1686907286928",
39
+ "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686907286928"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "modern dev",