@modern-js/module-tools-docs 2.30.0 → 2.31.0
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 +7 -0
- package/docs/en/api/config/build-config.mdx +49 -49
- package/docs/en/api/config/build-preset.mdx +15 -33
- package/docs/en/api/config/design-system.md +42 -34
- package/docs/en/api/config/plugins.md +3 -3
- package/docs/en/api/config/testing.md +2 -2
- package/docs/en/api/plugin-api/plugin-hooks.md +24 -24
- package/docs/en/components/register-esbuild-plugin.mdx +2 -2
- package/docs/en/guide/advance/asset.mdx +8 -27
- package/docs/en/guide/advance/build-umd.mdx +18 -66
- package/docs/en/guide/advance/external-dependency.mdx +7 -27
- package/docs/en/guide/advance/in-depth-about-build.md +4 -4
- package/docs/en/guide/advance/in-depth-about-dev-command.md +2 -2
- package/docs/en/guide/advance/theme-config.mdx +4 -8
- package/docs/en/guide/basic/before-getting-started.md +1 -1
- package/docs/en/guide/basic/publish-your-project.md +8 -7
- package/docs/en/guide/basic/test-your-project.mdx +10 -47
- package/docs/en/guide/basic/use-micro-generator.md +4 -4
- package/docs/en/guide/basic/using-storybook.mdx +12 -44
- package/docs/en/guide/best-practices/components.mdx +44 -402
- package/docs/en/guide/faq/build.mdx +16 -0
- package/docs/en/guide/intro/getting-started.md +2 -2
- package/docs/en/plugins/guide/getting-started.mdx +8 -24
- package/docs/en/plugins/guide/plugin-object.mdx +2 -8
- package/docs/en/plugins/official-list/plugin-import.mdx +9 -52
- package/docs/en/plugins/official-list/plugin-node-polyfill.md +2 -2
- package/docs/zh/api/config/build-config.mdx +52 -52
- package/docs/zh/api/config/build-preset.mdx +12 -30
- package/docs/zh/api/config/design-system.md +6 -6
- package/docs/zh/api/config/plugins.md +3 -3
- package/docs/zh/api/config/testing.md +2 -2
- package/docs/zh/components/register-esbuild-plugin.mdx +2 -2
- package/docs/zh/guide/advance/asset.mdx +9 -30
- package/docs/zh/guide/advance/build-umd.mdx +19 -67
- package/docs/zh/guide/advance/external-dependency.mdx +8 -28
- package/docs/zh/guide/advance/in-depth-about-build.md +4 -4
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +2 -2
- package/docs/zh/guide/advance/theme-config.mdx +4 -8
- package/docs/zh/guide/basic/publish-your-project.md +2 -2
- package/docs/zh/guide/basic/test-your-project.mdx +11 -49
- package/docs/zh/guide/basic/use-micro-generator.md +4 -4
- package/docs/zh/guide/basic/using-storybook.mdx +13 -45
- package/docs/zh/guide/best-practices/components.mdx +50 -410
- package/docs/zh/guide/faq/build.mdx +16 -0
- package/docs/zh/guide/intro/getting-started.md +1 -1
- package/docs/zh/plugins/guide/getting-started.mdx +8 -24
- package/docs/zh/plugins/guide/plugin-object.mdx +2 -8
- package/docs/zh/plugins/official-list/plugin-import.mdx +10 -55
- package/docs/zh/plugins/official-list/plugin-node-polyfill.md +2 -2
- package/modern.config.ts +1 -12
- package/package.json +3 -5
- package/theme/index.ts +0 -2
- package/theme/index.css +0 -9
|
@@ -6,7 +6,7 @@ sidebar_position: 4
|
|
|
6
6
|
|
|
7
7
|
Generally, third-party dependencies required by a project can be installed via the `install` command in the package manager. After the third-party dependencies are successfully installed, they will generally appear under `dependencies` and `devDependencies` in the project `package.json`.
|
|
8
8
|
|
|
9
|
-
```json pacakge.json
|
|
9
|
+
```json title="pacakge.json"
|
|
10
10
|
{
|
|
11
11
|
"dependencies": {},
|
|
12
12
|
"devDependencies": {}
|
|
@@ -25,25 +25,11 @@ This is because when the npm package is installed, its `"dependencies"` will als
|
|
|
25
25
|
|
|
26
26
|
If you need to package some dependencies, it is recommended to move them from `"dependencies"` to `"devDependencies"`, which is equivalent to **prebundle** the dependencies and reduces the size of the dependency installation.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```json ./v1/package.json
|
|
31
|
-
{
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"react": "^17"
|
|
34
|
-
},
|
|
35
|
-
// or
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"react": "^17"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
28
|
+
### Example
|
|
43
29
|
|
|
44
30
|
If the project has a dependency on `react`.
|
|
45
31
|
|
|
46
|
-
```json
|
|
32
|
+
```json title="package.json"
|
|
47
33
|
{
|
|
48
34
|
"dependencies": {
|
|
49
35
|
"react": "^17"
|
|
@@ -55,26 +41,20 @@ If the project has a dependency on `react`.
|
|
|
55
41
|
}
|
|
56
42
|
```
|
|
57
43
|
|
|
58
|
-
|
|
44
|
+
When a `react` dependency is used in the source code:
|
|
59
45
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
```tsx src/index.ts
|
|
46
|
+
```tsx title="src/index.ts"
|
|
63
47
|
import React from 'react';
|
|
64
48
|
console.info(React);
|
|
65
49
|
```
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
The `react` code is not bundled into the artifact at this point.
|
|
51
|
+
The `react` code is not bundled into the artifact:
|
|
70
52
|
|
|
71
|
-
```js dist/index.js
|
|
53
|
+
```js title="dist/index.js"
|
|
72
54
|
import React from 'react';
|
|
73
55
|
console.info(React);
|
|
74
56
|
```
|
|
75
57
|
|
|
76
|
-
</CH.Spotlight>
|
|
77
|
-
|
|
78
58
|
If you want to modify the default processing, you can use the following API.
|
|
79
59
|
|
|
80
60
|
- [`buildConfig.autoExternal`](/api/config/build-config#autoexternal)
|
|
@@ -50,7 +50,7 @@ We know from the defaults: **Bundle builds can generally specify a file path as
|
|
|
50
50
|
|
|
51
51
|
In addition to setting `input` to an array, you can also set it to an object during the Bundle build process. **By using the object form, we can modify the name of the file that the build artifacts outputs**. So for the following example, `. /src/index.ts` corresponds to the path of the build artifacts file as `. /dist/main.js`.
|
|
52
52
|
|
|
53
|
-
```js modern.config.ts
|
|
53
|
+
```js title="modern.config.ts"
|
|
54
54
|
import { defineConfig } from '@modern-js/module-tools';
|
|
55
55
|
|
|
56
56
|
export default defineConfig({
|
|
@@ -85,7 +85,7 @@ The [`buildConfig.dts`](/en/api/config/build-config#dts) configuration is mainly
|
|
|
85
85
|
|
|
86
86
|
Type generation is turned on by default, if you need to turn it off, you can configure it as follows:
|
|
87
87
|
|
|
88
|
-
```js modern.config.ts
|
|
88
|
+
```js title="modern.config.ts"
|
|
89
89
|
import { defineConfig } from '@modern-js/module-tools';
|
|
90
90
|
|
|
91
91
|
export default defineConfig({
|
|
@@ -112,7 +112,7 @@ The **Module Tools also supports bundling of type files**, although care needs t
|
|
|
112
112
|
|
|
113
113
|
During the Bundleless build process, if an alias appears in the source code, e.g.
|
|
114
114
|
|
|
115
|
-
```js ./src/index.ts
|
|
115
|
+
```js title="./src/index.ts"
|
|
116
116
|
import utils from '@common/utils';
|
|
117
117
|
```
|
|
118
118
|
|
|
@@ -231,7 +231,7 @@ Note, however: If the project is a TypeScript project, then you may need to add
|
|
|
231
231
|
|
|
232
232
|
> If the `.d.ts` file does not exist, then you can create it manually.
|
|
233
233
|
|
|
234
|
-
```ts env.d.ts
|
|
234
|
+
```ts title="env.d.ts"
|
|
235
235
|
declare const YOUR_ADD_GLOBAL_VAR;
|
|
236
236
|
```
|
|
237
237
|
|
|
@@ -25,7 +25,7 @@ If you need to extend the dev command, or rather provide your own Module Tools d
|
|
|
25
25
|
|
|
26
26
|
In general, the code to implement a debugging tool that does nothing and the associated configuration is as follows.
|
|
27
27
|
|
|
28
|
-
```
|
|
28
|
+
```ts do-nothing.ts
|
|
29
29
|
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
30
30
|
name: 'do-nothing',
|
|
31
31
|
setup() {
|
|
@@ -54,7 +54,7 @@ export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
|
54
54
|
|
|
55
55
|
If this debugging tool plugin is required, it needs to be added to the configuration file.
|
|
56
56
|
|
|
57
|
-
```
|
|
57
|
+
```ts
|
|
58
58
|
import doNothingPlugin from './plugins/do-nothing';
|
|
59
59
|
|
|
60
60
|
export default defineConfig({
|
|
@@ -31,7 +31,7 @@ When using tailwindcss, its [`theme`](https://v2.tailwindcss.com/docs/theme#exte
|
|
|
31
31
|
|
|
32
32
|
For example, the following configuration extends the original color configuration:
|
|
33
33
|
|
|
34
|
-
```ts
|
|
34
|
+
```ts title="modern.config.ts"
|
|
35
35
|
export default {
|
|
36
36
|
designSystem: {
|
|
37
37
|
extend: {
|
|
@@ -47,7 +47,7 @@ We can have two ways of using tailwindcss in our code.
|
|
|
47
47
|
|
|
48
48
|
#### HTML Class
|
|
49
49
|
|
|
50
|
-
```tsx ./src/index.tsx
|
|
50
|
+
```tsx title="./src/index.tsx"
|
|
51
51
|
import 'tailwindcss/utilities.css';
|
|
52
52
|
|
|
53
53
|
export default () => {
|
|
@@ -61,9 +61,7 @@ export default () => {
|
|
|
61
61
|
About [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply)。
|
|
62
62
|
:::
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```tsx ./src/index.tsx
|
|
64
|
+
```tsx title="./src/index.tsx"
|
|
67
65
|
import './index.css';
|
|
68
66
|
|
|
69
67
|
export default () => {
|
|
@@ -71,10 +69,8 @@ export default () => {
|
|
|
71
69
|
};
|
|
72
70
|
```
|
|
73
71
|
|
|
74
|
-
```css ./src/index.css
|
|
72
|
+
```css title="./src/index.css"
|
|
75
73
|
.btn-primary {
|
|
76
74
|
@apply bg-primary;
|
|
77
75
|
}
|
|
78
76
|
```
|
|
79
|
-
|
|
80
|
-
</CH.Code>
|
|
@@ -177,7 +177,7 @@ export default defineConfig({
|
|
|
177
177
|
|
|
178
178
|
**We recommend using the `defineConfig` function**, but it is not mandatory to use it. So you can also return an object directly in the config file: the
|
|
179
179
|
|
|
180
|
-
```
|
|
180
|
+
```ts title="modern.config.ts"
|
|
181
181
|
import { moduleTools } from '@modern-js/module-tools';
|
|
182
182
|
|
|
183
183
|
export default {
|
|
@@ -41,7 +41,7 @@ $ npx modern change
|
|
|
41
41
|
|
|
42
42
|
When executed successfully, the resulting Markdown file containing the change log is saved in the project's `.changeset` directory. The contents will look like the following.
|
|
43
43
|
|
|
44
|
-
```markdown .changeset/brave-dryers-agree.md
|
|
44
|
+
```markdown title=".changeset/brave-dryers-agree.md"
|
|
45
45
|
---
|
|
46
46
|
"``module-example'': patch
|
|
47
47
|
---
|
|
@@ -57,7 +57,7 @@ When the project version needs to be updated, execute the following command.
|
|
|
57
57
|
|
|
58
58
|
Executing `modern bump` will modify the version number in `package.json` based on the contents of the Markdown file in the `.changeset/` directory where the changes were recorded, and generate the `CHANGELOG.md` file. **These Markdown files are also deleted when the version update is complete, so they are "consumed "**.
|
|
59
59
|
|
|
60
|
-
```markdown CHANGELOG.md
|
|
60
|
+
```markdown title="CHANGELOG.md"
|
|
61
61
|
# module
|
|
62
62
|
|
|
63
63
|
## 0.1.1
|
|
@@ -93,16 +93,17 @@ When a pre-release is needed before the official release, the following command
|
|
|
93
93
|
|
|
94
94
|
First `modern pre enter <tag>` to enter pre-release mode, `<tag>` can be the same as the `tag` specified with the `modern release --tag` command when releasing the project.
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
```bash
|
|
97
97
|
$ npx modern pre enter next
|
|
98
98
|
🦋 success Entered pre mode with tag next
|
|
99
99
|
🦋 info Run `changeset version` to version packages with prerelease versions
|
|
100
100
|
✨ Done in 5.30s.
|
|
101
|
-
Done in 5.30s.
|
|
101
|
+
Done in 5.30s.
|
|
102
|
+
```
|
|
102
103
|
|
|
103
|
-
Then you can update the specific version number with the `modern bump` command, **which doesn't actually "consume" the Markdown file that records the changes**:
|
|
104
|
+
Then you can update the specific version number with the `modern bump` command, **which doesn't actually "consume" the Markdown file that records the changes**:
|
|
104
105
|
|
|
105
|
-
```
|
|
106
|
+
```bash
|
|
106
107
|
$ npx modern bump
|
|
107
108
|
🦋 warn ===============================IMPORTANT!===============================
|
|
108
109
|
🦋 warn You are in prerelease mode
|
|
@@ -110,7 +111,7 @@ $ npx modern bump
|
|
|
110
111
|
🦋 warn You can then run `changeset version` again to do a normal release
|
|
111
112
|
🦋 warn ----------------------------------------------------------------------
|
|
112
113
|
🦋 All files have been updated. review them and commit at your leisure
|
|
113
|
-
|
|
114
|
+
```
|
|
114
115
|
|
|
115
116
|
Then you can see that the updated version number in `package.json` will look like this: `0.1.2-next.0`.
|
|
116
117
|
|
|
@@ -45,31 +45,17 @@ You can add it in `modern.config.(j|t)s`.
|
|
|
45
45
|
|
|
46
46
|
For common modules, we can use the test function as follows:
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
- First is the code of the module:
|
|
49
49
|
|
|
50
|
-
```ts ./src/index.ts
|
|
50
|
+
```ts title="./src/index.ts"
|
|
51
51
|
export default function () {
|
|
52
52
|
return 'hello world';
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
First is the code of the module.
|
|
59
|
-
|
|
60
|
-
```ts ./src/index.ts
|
|
61
|
-
export default function () {
|
|
62
|
-
return 'hello world';
|
|
63
|
-
}
|
|
64
|
-
```
|
|
56
|
+
- Then in the test file, we can import source code as the following way. Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
|
|
65
57
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Then in the test file, we can do this.
|
|
69
|
-
|
|
70
|
-
Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
|
|
71
|
-
|
|
72
|
-
```ts ./tests/index.test.ts
|
|
58
|
+
```ts title="./tests/index.test.ts"
|
|
73
59
|
import main from '@/index';
|
|
74
60
|
|
|
75
61
|
describe('default cases', () => {
|
|
@@ -81,9 +67,7 @@ describe('default cases', () => {
|
|
|
81
67
|
});
|
|
82
68
|
```
|
|
83
69
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Finally we can execute `modern test`.
|
|
70
|
+
- Finally we can execute `modern test`.
|
|
87
71
|
|
|
88
72
|
```bash
|
|
89
73
|
pnpm test
|
|
@@ -93,8 +77,6 @@ yarn test
|
|
|
93
77
|
npm run test
|
|
94
78
|
```
|
|
95
79
|
|
|
96
|
-
</CH.Spotlight>
|
|
97
|
-
|
|
98
80
|
### Components
|
|
99
81
|
|
|
100
82
|
{/* 链接待补充 */}
|
|
@@ -105,9 +87,9 @@ For components, Modern.js's Runtime API provides functionality for testing UI co
|
|
|
105
87
|
If you need to use the Runtime API, then you can turn it on via [microgenerator](/guide/basic/command-preview).
|
|
106
88
|
:::
|
|
107
89
|
|
|
108
|
-
|
|
90
|
+
- First is the code of the component:
|
|
109
91
|
|
|
110
|
-
```tsx ./src/index.tsx
|
|
92
|
+
```tsx title="./src/index.tsx"
|
|
111
93
|
export const default () {
|
|
112
94
|
return (
|
|
113
95
|
<div>This is a UI Component</div>
|
|
@@ -115,25 +97,10 @@ export const default () {
|
|
|
115
97
|
}
|
|
116
98
|
```
|
|
117
99
|
|
|
118
|
-
---
|
|
119
100
|
|
|
120
|
-
|
|
101
|
+
- Then in the test file, we can import source code as the following way. Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
|
|
121
102
|
|
|
122
|
-
```tsx ./
|
|
123
|
-
export const default () {
|
|
124
|
-
return (
|
|
125
|
-
<div>This is a UI Component</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
Then in the test file, we can do this.
|
|
133
|
-
|
|
134
|
-
Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
|
|
135
|
-
|
|
136
|
-
```tsx ./tests/index.test.tsx
|
|
103
|
+
```tsx title="./tests/index.test.tsx"
|
|
137
104
|
import { render, screen } from '@modern-js/runtime/testing';
|
|
138
105
|
|
|
139
106
|
import Component from '@/index';
|
|
@@ -146,9 +113,7 @@ describe('default cases', () => {
|
|
|
146
113
|
});
|
|
147
114
|
```
|
|
148
115
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
Finally we can execute `modern test`.
|
|
116
|
+
- Finally we can execute `modern test`.
|
|
152
117
|
|
|
153
118
|
```bash
|
|
154
119
|
pnpm test
|
|
@@ -157,5 +122,3 @@ yarn test
|
|
|
157
122
|
## or
|
|
158
123
|
npm run test
|
|
159
124
|
```
|
|
160
|
-
|
|
161
|
-
</CH.Spotlight>
|
|
@@ -21,7 +21,7 @@ When we want to test some modules, we can enable the test feature. When this fea
|
|
|
21
21
|
|
|
22
22
|
:::tip
|
|
23
23
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
24
|
-
```
|
|
24
|
+
```ts
|
|
25
25
|
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
26
26
|
import { testingPlugin } from '@modern-js/plugin-testing';
|
|
27
27
|
|
|
@@ -40,7 +40,7 @@ The **Storybook feature** can be enabled when we want to debug a component or a
|
|
|
40
40
|
|
|
41
41
|
:::tip
|
|
42
42
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
43
|
-
```
|
|
43
|
+
```ts
|
|
44
44
|
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
45
45
|
import { storybookPlugin } from '@modern-js/plugin-storybook';
|
|
46
46
|
|
|
@@ -70,7 +70,7 @@ For more information on how to use Tailwind CSS in your module projects, check o
|
|
|
70
70
|
|
|
71
71
|
:::tip
|
|
72
72
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
73
|
-
```
|
|
73
|
+
```ts
|
|
74
74
|
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
75
75
|
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
|
76
76
|
|
|
@@ -93,7 +93,7 @@ Also, the Storybook debugging tool will determine if the project needs to use th
|
|
|
93
93
|
|
|
94
94
|
:::tip
|
|
95
95
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
96
|
-
```
|
|
96
|
+
```ts
|
|
97
97
|
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
98
98
|
import runtime from '@modern-js/runtime/cli';
|
|
99
99
|
|
|
@@ -34,24 +34,9 @@ Next, we will talk about how to use each of these two methods.
|
|
|
34
34
|
|
|
35
35
|
### Referencing component products
|
|
36
36
|
|
|
37
|
-
If the TypeScript project `foo` exists.
|
|
37
|
+
If the TypeScript project `foo` exists. Make sure the `main` and `types` of `package.json` values are real paths.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```json package.json
|
|
42
|
-
{
|
|
43
|
-
"name": "foo",
|
|
44
|
-
"main": "./dist/index.js",
|
|
45
|
-
"types": "./dist/types/index.d.ts"
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
Make sure the `main` and `types` of `package.json`
|
|
52
|
-
values are real paths.
|
|
53
|
-
|
|
54
|
-
```json package.json
|
|
39
|
+
```json title="package.json"
|
|
55
40
|
{
|
|
56
41
|
"name": "foo",
|
|
57
42
|
"main": "./dist/index.js",
|
|
@@ -59,20 +44,15 @@ values are real paths.
|
|
|
59
44
|
}
|
|
60
45
|
```
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The source code of the `foo` project.
|
|
47
|
+
The source code of the `foo` project:
|
|
65
48
|
|
|
66
|
-
```ts src/index.ts
|
|
49
|
+
```ts title="src/index.ts"
|
|
67
50
|
export const content = 'hello world';
|
|
68
51
|
```
|
|
69
52
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Make sure that the `paths` configuration pointing to the project root is set in `stories/tsconfig.json`.
|
|
73
|
-
The `key` of `paths` is the same as the project name.
|
|
53
|
+
Make sure that the `paths` configuration pointing to the project root is set in `stories/tsconfig.json`. The `key` of `paths` is the same as the project name.
|
|
74
54
|
|
|
75
|
-
```json stories/tsconfig.json
|
|
55
|
+
```json title="stories/tsconfig.json"
|
|
76
56
|
{
|
|
77
57
|
"extends": "../tsconfig.json",
|
|
78
58
|
"include": ["./"],
|
|
@@ -86,11 +66,9 @@ The `key` of `paths` is the same as the project name.
|
|
|
86
66
|
}
|
|
87
67
|
```
|
|
88
68
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Referenced directly in Story code by the project name.
|
|
69
|
+
Referenced directly in Story code by the project name:
|
|
92
70
|
|
|
93
|
-
```tsx stories/index.stories.tsx
|
|
71
|
+
```tsx title="stories/index.stories.tsx"
|
|
94
72
|
import { content } from 'foo';
|
|
95
73
|
|
|
96
74
|
const Component = () => <div>this is a Story Component {content}</div>;
|
|
@@ -102,33 +80,23 @@ export default {
|
|
|
102
80
|
};
|
|
103
81
|
```
|
|
104
82
|
|
|
105
|
-
---
|
|
106
|
-
|
|
107
83
|
Finally, when executing the command, first start the source build in listening mode and then start Storybook debugging.
|
|
108
84
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
``` bash terminal-1
|
|
85
|
+
```bash title="terminal-1"
|
|
112
86
|
## Source Code Build
|
|
113
87
|
modern build --watch
|
|
114
88
|
```
|
|
115
89
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
``` bash terminal-2
|
|
90
|
+
```bash title="terminal-2"
|
|
119
91
|
## Storybook Debug
|
|
120
92
|
modern dev storybook
|
|
121
93
|
```
|
|
122
94
|
|
|
123
|
-
</CH.Code>
|
|
124
|
-
|
|
125
|
-
</CH.Spotlight>
|
|
126
|
-
|
|
127
95
|
If, during development, you encounter a situation where the type definition is not available in real time, at that point.
|
|
128
96
|
|
|
129
97
|
For `pnpm` projects, `package.json` can be modified as follows.
|
|
130
98
|
|
|
131
|
-
```ts
|
|
99
|
+
```ts
|
|
132
100
|
{
|
|
133
101
|
"name": "foo",
|
|
134
102
|
"main": "./dist/index.js",
|
|
@@ -152,7 +120,7 @@ So why is it possible to reference the product directly?
|
|
|
152
120
|
|
|
153
121
|
Referencing component source code can be done by means of relative paths to:
|
|
154
122
|
|
|
155
|
-
```ts ./stories/index.tsx
|
|
123
|
+
```ts title="./stories/index.tsx"
|
|
156
124
|
import { content } from '../src';
|
|
157
125
|
|
|
158
126
|
const Component = () => <div>this is a Story Component {content}</div>;
|