@modern-js/main-doc 2.23.0 → 2.23.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @modern-js/main-doc
2
2
 
3
+ ## 2.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4d4dca0]
8
+ - @modern-js/builder-doc@2.23.1
9
+
3
10
  ## 2.23.0
4
11
 
5
12
  ### Patch Changes
@@ -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
 
@@ -11,10 +11,10 @@ Before using this option, you need to install and register the `@modern-js/plugi
11
11
  # npm
12
12
  npm add @modern-js/plugin-proxy -D
13
13
 
14
- #yarn
14
+ # yarn
15
15
  yarn add @modern-js/plugin-proxy -D
16
16
 
17
- #pnpm
17
+ # pnpm
18
18
  pnpm add @modern-js/plugin-proxy -D
19
19
  ```
20
20
 
@@ -8,14 +8,10 @@ sidebar_position: 1
8
8
  - **Type:** `'babel-jest' | 'ts-jest'`
9
9
  - **Default:** `babel-jest`
10
10
 
11
- :::caution Caution
12
- First you need to enable the "Unit Test" function using [new](/apis/app/commands#modern-new) command.
11
+ First need to run `new` command to enable [Unit Test / Integration Test] features.
13
12
 
14
- :::
15
-
16
- Configure the compiler for source code when executing tests: [babel-jest](https://www.npmjs.com/package/babel-jest) or [ts-jest](https://github.com/kulshekhar/ts-jest). `babel-jest` is used by default.
17
-
18
- :::info Additional information
19
- `Babel-jest` can also compile TS files, but there is no type error. If you need to check the TS type when running tests, then use `ts-jest`.
13
+ Configure the compilation tool used during test execution. By default, `babel-jest` is used. You can configure it to use either [babel-jest](https://www.npmjs.com/package/babel-jest) or [ts-jest](https://github.com/kulshekhar/ts-jest).
20
14
 
15
+ :::info Additional
16
+ `babel-jest` can compile TypeScript files but does not perform type checking. If you want to perform type checking on your TypeScript files while running test cases, you can use `ts-jest`.
21
17
  :::
@@ -6,9 +6,9 @@ sidebar_position: 5
6
6
 
7
7
  ## Browserslist Configuration
8
8
 
9
- Modern.js supports setting the browserslist for your web applications. You can set the [Browserslist](https://browsersl.ist/) in the `.browserslistrc` file.
9
+ Modern.js supports setting the browserslist for your web applications. You can set the value of [Browserslist](https://browsersl.ist/) in the `.browserslistrc` file.
10
10
 
11
- When you create a new Modern.js project, it includes a `.browserslistrc` configuration by default, which means that JavaScript code will be compiled to ES6.
11
+ When you create a new Modern.js project, it will includes a `.browserslistrc` configuration by default, which means that the JavaScript code will be compiled to ES6.
12
12
 
13
13
  ```yaml title=".browserslistrc"
14
14
  chrome >= 51
@@ -22,32 +22,11 @@ ios_saf >= 10
22
22
  Please refer to [Modern.js Builder - Browserslist](https://modernjs.dev/builder/en/guide/advanced/browserslist) for more information.
23
23
  :::
24
24
 
25
- ## Browserslist
26
-
27
- Modern.js supports the `browserslist` field in the `package.json` file, or a `.browserslistrc` file to specify the target browser range covered by the project.
28
-
29
- This value is used by ['@babel/preset-env'] (https://babeljs.io/docs/en/babel-preset-env) and ['autoprefixer'] (https://github.com/postcss/autoprefixer) to determine the JavaScript syntax features to be converted and the CSS browser prefix to be added.
30
-
31
- The default value in Modern.js as follow:
32
-
33
- ```js
34
- ['> 0.01%', 'not dead', 'not op_mini all'];
35
- ```
36
-
37
- You can learn how to customize the browserslist [here](https://github.com/browserslist/browserslist).
38
-
39
- See Modern.js Builder docs to learn more [Browserslist](https://modernjs.dev/builder/en/guide/advanced/browserslist.html) info.
40
-
41
- :::note
42
- Modern.js also supports configuring [output.override Browserslist](/configure/app/output/override-browserslist) to override the default browserslist value.
43
-
44
- :::
45
-
46
25
  ## Polyfill
47
26
 
48
27
  ### Polyfill At Compile
49
28
 
50
- Modern.js inject the Polyfill code via [core-js] (https://github.com/zloirock/core-js) at compile time by default.
29
+ Modern.js defaults to importing corresponding polyfill code from [core-js] (https://github.com/zloirock/core-js) during compilation.
51
30
 
52
31
  By default, the required Polyfill code will be introduced according to the settings of the Browserslist, so there is no need to worry about the Polyfill problem of the project source code and third-party dependencies, but because it contains some Polyfill code that is not used, the final bundle size may be increased.
53
32
 
@@ -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
 
@@ -8,9 +8,12 @@ sidebar_position: 1
8
8
  - **类型:** `'babel-jest' | 'ts-jest'`
9
9
  - **默认值:** `babel-jest`
10
10
 
11
- 配置执行测试的时候对于源码的编译工具: [babel-jest](https://www.npmjs.com/package/babel-jest) 或 [ts-jest](https://github.com/kulshekhar/ts-jest)。默认使用 `babel-jest`。
11
+ :::caution Caution
12
+ 请先在当前应用项目根目录使用 [new](/apis/app/commands#modern-new) 启用测试功能。
13
+ :::
12
14
 
13
- :::info 补充信息
14
- `babel-jest` 也可以编译 TS 文件,但不会类型报错,如果你需要跑测试的时候对 TS 类型进行校验,那么请使用 `ts-jest`。
15
+ 配置执行测试时的编译工具,默认使用 `babel-jest`。可配置为 [babel-jest](https://www.npmjs.com/package/babel-jest) 或 [ts-jest](https://github.com/kulshekhar/ts-jest)。
15
16
 
17
+ :::info 补充信息
18
+ `babel-jest` 可以编译 TS 文件,但没有类型校验。如果你希望运行测试用例的时,能对 TS 类型进行校验,可以使用 `ts-jest`。
16
19
  :::
@@ -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": "2.23.0",
18
+ "version": "2.23.1",
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": "^2.23.0"
25
+ "@modern-js/builder-doc": "^2.23.1"
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/builder-doc": "2.23.0",
38
- "@modern-js/doc-tools": "2.23.0",
39
- "@modern-js/doc-plugin-auto-sidebar": "2.23.0"
37
+ "@modern-js/builder-doc": "2.23.1",
38
+ "@modern-js/doc-tools": "2.23.1",
39
+ "@modern-js/doc-plugin-auto-sidebar": "2.23.1"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "modern dev",