@modern-js/main-doc 0.0.0-next-20221228051706 → 0.0.0-next-20221228084828

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,8 +1,8 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-20221228051706
3
+ ## 0.0.0-next-20221228084828
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - Updated dependencies [dda38c9c3]
8
- - @modern-js/builder-doc@0.0.0-next-20221228051706
8
+ - @modern-js/builder-doc@0.0.0-next-20221228084828
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: autoLoadPlugins
3
+ sidebar_position: 11
4
+ ---
5
+
6
+ - Type: `boolean`
7
+ - Default: `false`
8
+
9
+ Used to configure whether Modern.js enables auto-registration of plugins.
10
+
11
+ ### Manual Registration Plugin
12
+
13
+ By default, installing the plugin requires you to register the plugin manually in the `modern.config.ts`.
14
+
15
+ ```ts title="modern.config.ts"
16
+ import AppToolsPlugin, { defineConfig } from '@modern-js/app-tools';
17
+ import I18nPlugin from '@modern-js/plugin-i18n';
18
+
19
+ default export defineConfig({
20
+ plugins: [AppToolsPlugin(), I18nPlugin()]
21
+ })
22
+
23
+ ```
24
+
25
+ ### Auto Registration plugin
26
+
27
+ In addition to means registration, Modern.js also provides a way to automatically register plugins: set the `autoLoadPlugin` configuration item to `true`.
28
+
29
+ ```ts title="modern.config.ts"
30
+ import { defineConfig } from '@modern-js/app-tools';
31
+
32
+ default export defineConfig({
33
+ autoLoadPlugins: true
34
+ })
35
+ ```
36
+
37
+ Modern.js will help you automatically register the plugin by following these steps
38
+
39
+ 1. Modern.js maintains an official list of plugins internally.
40
+
41
+ ```js
42
+ const InternalPlugins = ['@modern-js/app-tools', '@modern-js/plugin-i18n', ...];
43
+ ```
44
+
45
+ 2. Modern.js will read your `package.json` and collect the dependency information.
46
+
47
+ ```json title="package.json"
48
+ "dependencies": {
49
+ "@modern-js/plugin-i18n": "x.x.x"
50
+ ...
51
+ },
52
+ "devDependencies": {
53
+ "@modern-js/app-tools": "x.x.x"
54
+ ...
55
+ }
56
+ ```
57
+
58
+ 3. Modern.js observes that when you install dependencies such as `@modern-js/plugin-i18n` and `@modern-js/app-tools`, automatic plugin registration will be imported.
59
+
60
+ You can notice that this approach is relatively black-box and you are not even aware of the process of loading the plugin. We want to expose more details to the developer and be able to let the developer control the process.
61
+
62
+ **Therefore we recommend you to register the plugin manually.**
package/package.json CHANGED
@@ -11,20 +11,20 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-20221228051706",
14
+ "version": "0.0.0-next-20221228084828",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-20221228051706"
20
+ "@modern-js/builder-doc": "0.0.0-next-20221228084828"
21
21
  },
22
22
  "devDependencies": {
23
23
  "ts-node": "^10",
24
24
  "fs-extra": "^10",
25
25
  "@types/node": "^16",
26
26
  "@types/fs-extra": "^9",
27
- "@modern-js/builder-doc": "0.0.0-next-20221228051706"
27
+ "@modern-js/builder-doc": "0.0.0-next-20221228084828"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "npx ts-node ./scripts/sync.ts"
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: autoLoadPlugins (自动注册插件)
3
+ sidebar_position: 11
4
+ ---
5
+
6
+ - 类型:`boolean`
7
+ - 默认值:`false`
8
+
9
+ 用于配置 Modern.js 是否开启自动注册插件。
10
+
11
+ ### 手动注册插件
12
+
13
+ 默认情况下,安装插件后需要你在 `modern.config.ts` 文件中手动注册插件。
14
+
15
+ ```ts title="modern.config.ts"
16
+ import AppToolsPlugin, { defineConfig } from '@modern-js/app-tools';
17
+ import I18nPlugin from '@modern-js/plugin-i18n';
18
+
19
+ default export defineConfig({
20
+ plugins: [AppToolsPlugin(), I18nPlugin()]
21
+ })
22
+
23
+ ```
24
+
25
+ ### 自动注册插件
26
+
27
+ 除了手段注册,Modern.js 还提供自动注册插件的方式: 将 `autoLoadPlugin` 配置项置为 `true`。
28
+
29
+ ```ts title="modern.config.ts"
30
+ import { defineConfig } from '@modern-js/app-tools';
31
+
32
+ default export defineConfig({
33
+ autoLoadPlugins: true
34
+ })
35
+ ```
36
+
37
+ Modern.js 将通过以下几个步骤帮你自动注册插件
38
+
39
+ 1. Modern.js 在内部维护一份官方插件列表。
40
+
41
+ ```js
42
+ const InternalPlugins = ['@modern-js/app-tools', '@modern-js/plugin-i18n', ...];
43
+ ```
44
+
45
+ 2. Modern.js 将读取你的 `package.json` 文件,收集依赖信息。
46
+
47
+ ```json title="package.json"
48
+ "dependencies": {
49
+ "@modern-js/plugin-i18n": "x.x.x"
50
+ ...
51
+ },
52
+ "devDependencies": {
53
+ "@modern-js/app-tools": "x.x.x"
54
+ ...
55
+ }
56
+ ```
57
+
58
+ 3. Modern.js 观察到你安装了 `@modern-js/plugin-i18n` 和 `@modern-js/app-tools` 等依赖后,将会引入插件自动注册。
59
+
60
+ 可以注意到这种方式相对黑盒,你甚至对加载插件的过程是无感知的。我们希望更多的细节暴露给开发者,能让开发者去控制这一过程。
61
+
62
+ **因此我们更加推荐你手动注册插件。**
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "label": "tools (底层配置)",
3
- "position": 10
3
+ "position": 12
4
4
  }