@rsdoctor/docs 0.0.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.
Files changed (79) hide show
  1. package/docs/en/_meta.json +17 -0
  2. package/docs/en/blog/_meta.json +12 -0
  3. package/docs/en/blog/release/_meta.json +1 -0
  4. package/docs/en/blog/release/release-note-1.mdx +129 -0
  5. package/docs/en/blog/topic/_meta.json +1 -0
  6. package/docs/en/blog/topic/duplicate-pkg-problem.mdx +141 -0
  7. package/docs/en/blog/topic/loader-optimization.mdx +80 -0
  8. package/docs/en/config/_meta.json +7 -0
  9. package/docs/en/config/options/_meta.json +1 -0
  10. package/docs/en/config/options/options.mdx +135 -0
  11. package/docs/en/config/options/term.mdx +10 -0
  12. package/docs/en/guide/_meta.json +17 -0
  13. package/docs/en/guide/more/_meta.json +1 -0
  14. package/docs/en/guide/more/faq.mdx +104 -0
  15. package/docs/en/guide/more/rules.mdx +5 -0
  16. package/docs/en/guide/start/_meta.json +1 -0
  17. package/docs/en/guide/start/cli.mdx +94 -0
  18. package/docs/en/guide/start/features.mdx +36 -0
  19. package/docs/en/guide/start/intro.mdx +115 -0
  20. package/docs/en/guide/start/quick-start.mdx +210 -0
  21. package/docs/en/guide/usage/_meta.json +13 -0
  22. package/docs/en/guide/usage/bundle-alerts.mdx +47 -0
  23. package/docs/en/guide/usage/bundle-overall.mdx +55 -0
  24. package/docs/en/guide/usage/bundle-size.mdx +122 -0
  25. package/docs/en/guide/usage/compile-alerts.mdx +18 -0
  26. package/docs/en/guide/usage/compile-overall.mdx +115 -0
  27. package/docs/en/guide/usage/loaders-analysis.mdx +72 -0
  28. package/docs/en/guide/usage/loaders-timeline.mdx +68 -0
  29. package/docs/en/guide/usage/module-analysis.mdx +58 -0
  30. package/docs/en/guide/usage/plugins-analysis.mdx +43 -0
  31. package/docs/en/guide/usage/project-overall.mdx +51 -0
  32. package/docs/en/guide/usage/resolver.mdx +29 -0
  33. package/docs/en/index.md +38 -0
  34. package/docs/zh/_meta.json +17 -0
  35. package/docs/zh/blog/_meta.json +12 -0
  36. package/docs/zh/blog/release/_meta.json +1 -0
  37. package/docs/zh/blog/release/release-note-1.mdx +128 -0
  38. package/docs/zh/blog/topic/_meta.json +1 -0
  39. package/docs/zh/blog/topic/duplicate-pkg-problem.mdx +138 -0
  40. package/docs/zh/blog/topic/loader-optimization.mdx +80 -0
  41. package/docs/zh/config/_meta.json +7 -0
  42. package/docs/zh/config/options/_meta.json +1 -0
  43. package/docs/zh/config/options/options.mdx +138 -0
  44. package/docs/zh/config/options/term.mdx +10 -0
  45. package/docs/zh/guide/_meta.json +17 -0
  46. package/docs/zh/guide/more/_meta.json +1 -0
  47. package/docs/zh/guide/more/faq.mdx +102 -0
  48. package/docs/zh/guide/more/rules.mdx +5 -0
  49. package/docs/zh/guide/start/_meta.json +1 -0
  50. package/docs/zh/guide/start/cli.mdx +94 -0
  51. package/docs/zh/guide/start/features.mdx +36 -0
  52. package/docs/zh/guide/start/intro.mdx +116 -0
  53. package/docs/zh/guide/start/quick-start.mdx +209 -0
  54. package/docs/zh/guide/usage/_meta.json +13 -0
  55. package/docs/zh/guide/usage/bundle-alerts.mdx +49 -0
  56. package/docs/zh/guide/usage/bundle-overall.mdx +57 -0
  57. package/docs/zh/guide/usage/bundle-size.mdx +122 -0
  58. package/docs/zh/guide/usage/compile-alerts.mdx +18 -0
  59. package/docs/zh/guide/usage/compile-overall.mdx +115 -0
  60. package/docs/zh/guide/usage/loaders-analysis.mdx +73 -0
  61. package/docs/zh/guide/usage/loaders-timeline.mdx +68 -0
  62. package/docs/zh/guide/usage/module-analysis.mdx +59 -0
  63. package/docs/zh/guide/usage/plugins-analysis.mdx +43 -0
  64. package/docs/zh/guide/usage/project-overall.mdx +51 -0
  65. package/docs/zh/guide/usage/resolver.mdx +29 -0
  66. package/docs/zh/index.md +38 -0
  67. package/docs/zh/shared/features-rspack.md +24 -0
  68. package/docs/zh/shared/features.md +29 -0
  69. package/package.json +44 -0
  70. package/src/components/NextSteps.module.scss +6 -0
  71. package/src/components/NextSteps.tsx +7 -0
  72. package/src/components/Overview.module.scss +61 -0
  73. package/src/components/Overview.tsx +40 -0
  74. package/src/components/RuleIndex.module.scss +57 -0
  75. package/src/components/RuleIndex.tsx +75 -0
  76. package/src/components/Step.module.scss +32 -0
  77. package/src/components/Step.tsx +13 -0
  78. package/src/global.d.ts +4 -0
  79. package/src/utils.ts +9 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ pageType: home
3
+
4
+ hero:
5
+ name: Rsdoctor
6
+ text: Rspack & Webpack 构建分析工具
7
+ tagline: 让构建过程可视化
8
+ actions:
9
+ - theme: brand
10
+ text: 介绍
11
+ link: /zh/guide/start/intro
12
+ - theme: alt
13
+ text: 快速开始
14
+ link: /zh/guide/start/quick-start
15
+ image:
16
+ src: https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/logo/rsdoctor.png
17
+ alt: Rsdoctor Logo
18
+
19
+ features:
20
+ - title: 框架无关
21
+ details: Rsdoctor 支持分析用 Webpack 和 Rspack 构建的项目。
22
+ icon: 🛠️
23
+ - title: 构建时分析
24
+ details: 以时序图的形式显示编译执行时间和过程。
25
+ icon: 🚀
26
+ - title: 构建行为分析
27
+ details: 可视化的查看每个 loader 对每个文件的编译更改。
28
+ icon: 🦄
29
+ - title: 构建产物分析
30
+ details: 直观地详细查看 Bundle 和模块关系、模块引用关系和重复包等产物详情。
31
+ icon: 🎯
32
+ - title: 产物对比
33
+ details: 通过对比发现产物劣化及变动。
34
+ icon: 🎨
35
+ - title: 构建扫描
36
+ details: 内置构建规则扫描,同时支持自定义规则。
37
+ icon: 🔍
38
+ ---
@@ -0,0 +1,24 @@
1
+ ```ts
2
+ interface RsdoctorRspackPluginFeatures {
3
+ /**
4
+ * turn off it if you need not to analyze the executions of webpack loaders.
5
+ * @default true
6
+ */
7
+ loader?: boolean;
8
+ /**
9
+ * turn off it if you need not to analyze the executions of webpack plugins.
10
+ * @default true
11
+ */
12
+ plugins?: boolean;
13
+ /**
14
+ * turn off it if you need not to analyze the output bundle.
15
+ * @default true
16
+ */
17
+ bundle?: boolean;
18
+ /**
19
+ * turn on it if you just use lite mode. This mode do not have source codes.
20
+ * @default false
21
+ */
22
+ lite?: boolean;
23
+ }
24
+ ```
@@ -0,0 +1,29 @@
1
+ ```ts
2
+ interface RsdoctorWebpackPluginFeatures {
3
+ /**
4
+ * turn off it if you need not to analyze the executions of webpack loaders.
5
+ * @default true
6
+ */
7
+ loader?: boolean;
8
+ /**
9
+ * turn off it if you need not to analyze the executions of webpack plugins.
10
+ * @default true
11
+ */
12
+ plugins?: boolean;
13
+ /**
14
+ * turn off it if you need not to analyze the executions of resolver.
15
+ * @default false
16
+ */
17
+ resolver?: boolean;
18
+ /**
19
+ * turn off it if you need not to analyze the output bundle.
20
+ * @default true
21
+ */
22
+ bundle?: boolean;
23
+ /**
24
+ * turn on it if you just use lite mode. This mode do not have source codes.
25
+ * @default false
26
+ */
27
+ lite?: boolean;
28
+ }
29
+ ```
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@rsdoctor/docs",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "dev": "rspress dev",
6
+ "build": "rspress build",
7
+ "preview": "rspress preview"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/web-infra-dev/rsdoctor",
12
+ "directory": "packages/document"
13
+ },
14
+ "license": "MIT",
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "docs",
19
+ "src"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "provenance": false,
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "devDependencies": {
27
+ "@rsdoctor/types": "workspace:*",
28
+ "@types/node": "^16",
29
+ "@types/react": "^18",
30
+ "@types/react-dom": "^18",
31
+ "react": "18.2.0",
32
+ "react-dom": "18.2.0",
33
+ "rspress-plugin-font-open-sans": "^1.0.0",
34
+ "ts-node": "^10.9.2",
35
+ "typescript": "^5.2.2"
36
+ },
37
+ "dependencies": {
38
+ "framer-motion": "^10.17.6",
39
+ "react-markdown": "^9.0.1",
40
+ "rsfamily-nav-icon": "^1.0.2",
41
+ "rspress": "^1.15.1",
42
+ "tailwindcss": "^3.4.0"
43
+ }
44
+ }
@@ -0,0 +1,6 @@
1
+ .next-steps {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ justify-content: space-between;
5
+ margin-top: 3rem;
6
+ }
@@ -0,0 +1,7 @@
1
+ import styles from './NextSteps.module.scss';
2
+
3
+ const NextSteps = (props: { children?: React.ReactNode }) => {
4
+ return <div className={styles.nextSteps}>{props.children}</div>;
5
+ };
6
+
7
+ export default NextSteps;
@@ -0,0 +1,61 @@
1
+ .root {
2
+ margin-top: 64px;
3
+
4
+ h2 {
5
+ font-size: 23px;
6
+ font-weight: 600;
7
+ line-height: 1;
8
+ margin: 0 0 20px;
9
+ color: var(--rp-c-text-1);
10
+ transition: color 0.5s;
11
+ }
12
+
13
+ a {
14
+ letter-spacing: -0.01em;
15
+ margin-bottom: 1em;
16
+ transition: color 0.5s;
17
+ margin: 0;
18
+ font-size: 15px;
19
+ font-weight: 500;
20
+ line-height: 2.2;
21
+ margin-top: 8px;
22
+ color: var(--rp-c-text-code);
23
+ opacity: 0.9;
24
+ transition: color 0.5s;
25
+ word-break: break-all;
26
+ }
27
+
28
+ a:hover {
29
+ transition: color 0.5s;
30
+ color: var(--rp-c-brand-dark);
31
+ }
32
+ }
33
+
34
+ .group {
35
+ break-inside: avoid;
36
+ margin-bottom: 28px;
37
+ background-color: var(--rp-c-bg-soft);
38
+ border-radius: 12px;
39
+ padding: 28px 32px;
40
+ transition: background-color 0.5s;
41
+ }
42
+
43
+ @media (max-width: 768px) {
44
+ .root a {
45
+ font-size: 14px;
46
+ }
47
+ }
48
+
49
+ @media (min-width: 768px) {
50
+ .root {
51
+ columns: 2;
52
+ min-width: 648px;
53
+ }
54
+ }
55
+
56
+ @media (min-width: 1024px) {
57
+ .root {
58
+ columns: 3;
59
+ min-width: 904px;
60
+ }
61
+ }
@@ -0,0 +1,40 @@
1
+ import { NoSSR } from 'rspress/runtime';
2
+ import { useUrl } from '../utils';
3
+ import styles from './Overview.module.scss';
4
+
5
+ export interface GroupItem {
6
+ text: string;
7
+ link: string;
8
+ }
9
+
10
+ export interface Group {
11
+ name: string;
12
+ items: GroupItem[];
13
+ }
14
+
15
+ declare const OVERVIEW_GROUPS: Group[];
16
+
17
+ export default function Overview() {
18
+ const Nodes = OVERVIEW_GROUPS.map((group) => (
19
+ <>
20
+ <div className={styles.overviewGroups}>
21
+ <div className={styles.group}>
22
+ <h2>{group.name}</h2>
23
+ <ul>
24
+ {group.items.map((item) => (
25
+ <li key={item.text}>
26
+ <a href={useUrl(item.link)}>{item.text}</a>
27
+ </li>
28
+ ))}
29
+ </ul>
30
+ </div>
31
+ </div>
32
+ </>
33
+ ));
34
+
35
+ return (
36
+ <NoSSR>
37
+ <div className={styles.root}>{Nodes}</div>
38
+ </NoSSR>
39
+ );
40
+ }
@@ -0,0 +1,57 @@
1
+ .container {
2
+ display: flex;
3
+ justify-content: center;
4
+ align-items: flex-start;
5
+ }
6
+
7
+ .card {
8
+ box-sizing: border-box;
9
+ margin: 0;
10
+ padding: 0;
11
+ position: relative;
12
+ border-radius: 8px;
13
+ border: 1px solid var(--rp-c-divider-light);
14
+ margin-right: 24px;
15
+ font-size: 14px;
16
+ }
17
+
18
+ .card-header {
19
+ display: flex;
20
+ justify-content: space-between;
21
+ align-items: center;
22
+ padding: 24px;
23
+ border-bottom: 1px solid var(--rp-c-divider-light);
24
+ height: 55.5px;
25
+ overflow: hidden;
26
+ font-weight: bold;
27
+ }
28
+
29
+ .card-body {
30
+ padding: 24px;
31
+ }
32
+
33
+ .list {
34
+ width: 320px;
35
+ }
36
+
37
+ .item {
38
+ margin-bottom: 12px;
39
+ font-size: 14px;
40
+ cursor: pointer;
41
+ }
42
+
43
+ .content {
44
+ margin-right: 0;
45
+ min-width: 500px;
46
+ }
47
+
48
+ .tag {
49
+ margin: 0 0.2em;
50
+ padding-inline: 0.4em;
51
+ padding-block: 0.2em 0.1em;
52
+ font-size: 85%;
53
+ background: rgba(150, 150, 150, 0.1);
54
+ border: 1px solid rgba(100, 100, 100, 0.2);
55
+ border-radius: 3px;
56
+ font-weight: bold;
57
+ }
@@ -0,0 +1,75 @@
1
+ import { useState } from 'react';
2
+ import ReactMarkdown from 'react-markdown';
3
+ import { Rule } from '@rsdoctor/types';
4
+ import styles from './RuleIndex.module.scss';
5
+ const themeDefault = require('@rspress/core/theme');
6
+
7
+ const RuleIndex = () => {
8
+ const rules = Object.values(Rule.RuleErrorMap);
9
+ const [ruleMessage, setRuleMessage] = useState(rules[0] as Rule.RuleMessage);
10
+
11
+ const selectRuleMessage = (message: Rule.RuleMessage) => {
12
+ setRuleMessage(message);
13
+ };
14
+
15
+ return (
16
+ <div className={styles.container}>
17
+ <div className={`${styles.card} ${styles.list}`}>
18
+ <div className={styles['card-header']}>List of the error codes</div>
19
+ <div className={styles['card-body']}>
20
+ {rules.map((item) => (
21
+ <div
22
+ className={styles.item}
23
+ key={item.code}
24
+ onClick={() => selectRuleMessage(item)}
25
+ style={{
26
+ color:
27
+ ruleMessage && item.code === ruleMessage.code
28
+ ? 'rgb(24, 144, 255)'
29
+ : undefined,
30
+ }}
31
+ >
32
+ <span className={styles.tag}>
33
+ <a>{item.code}</a>
34
+ </span>
35
+ <span>{item.title}</span>
36
+ </div>
37
+ ))}
38
+ </div>
39
+ </div>
40
+
41
+ {ruleMessage ? (
42
+ <div className={`${styles.card} ${styles.content}`}>
43
+ <div className={styles['card-header']}>
44
+ <div>
45
+ <span className={styles.tag}>{ruleMessage.code}</span>
46
+ <span>{ruleMessage.title}</span>
47
+ </div>
48
+ <span className={styles.tag}>{ruleMessage.category}</span>
49
+ </div>
50
+ <div className={styles['card-body']} style={{ paddingTop: 0 }}>
51
+ <ReactMarkdown
52
+ components={{
53
+ ...themeDefault.getCustomMDXComponent(),
54
+ code: (props) => <code {...props} />,
55
+ }}
56
+ >
57
+ {ruleMessage.description}
58
+ </ReactMarkdown>
59
+ </div>
60
+ </div>
61
+ ) : (
62
+ <div className={`${styles.card} ${styles.content}`}>
63
+ <div className={styles['card-header']}>
64
+ This page lists all the error codes emitted by the Rsdoctor.
65
+ </div>
66
+ <div className={styles['card-body']}>
67
+ click the error code in left bar to show more details.
68
+ </div>
69
+ </div>
70
+ )}
71
+ </div>
72
+ );
73
+ };
74
+
75
+ export default RuleIndex;
@@ -0,0 +1,32 @@
1
+ .step {
2
+ border: 1px solid var(--rp-c-bg-soft);
3
+ background-color: var(--rp-c-bg-soft);
4
+ transition:
5
+ color 0.5s,
6
+ background-color 0.5s;
7
+ padding: 28px 36px;
8
+ border-radius: 8px;
9
+ flex: 0 32%;
10
+ font-size: 14px;
11
+ font-weight: 500;
12
+
13
+ &:hover {
14
+ border-color: var(--rp-c-brand);
15
+ transition: border-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
16
+ }
17
+ }
18
+
19
+ .title {
20
+ font-size: 20px;
21
+ line-height: 1.4;
22
+ letter-spacing: -0.02em;
23
+ margin: 0 0 0.75em !important;
24
+ display: block;
25
+ }
26
+
27
+ .description {
28
+ margin: 0 !important;
29
+ line-height: 1.7 !important;
30
+ color: var(--rp-c-text-2);
31
+ transition: color 0.5s;
32
+ }
@@ -0,0 +1,13 @@
1
+ import { useUrl } from '../utils';
2
+ import styles from './Step.module.scss';
3
+
4
+ const Step = (props: { href: string; title: string; description: string }) => {
5
+ return (
6
+ <a className={styles.step} href={useUrl(props.href)}>
7
+ <p className={styles.title}>{props.title}</p>
8
+ <p className={styles.description}>{props.description}</p>
9
+ </a>
10
+ );
11
+ };
12
+
13
+ export default Step;
@@ -0,0 +1,4 @@
1
+ declare module '*.module.scss' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { useLang, withBase, usePageData } from 'rspress/runtime';
2
+
3
+ export function useUrl(url: string) {
4
+ const lang = useLang();
5
+ const {
6
+ siteData: { lang: defaultLang },
7
+ } = usePageData();
8
+ return withBase(lang === defaultLang ? url : `/${lang}${url}`);
9
+ }