@bleedingdev/modern-js-create 3.2.0-ultramodern.0 → 3.2.0-ultramodern.10
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/README.md +12 -0
- package/dist/index.js +252 -49
- package/dist/types/locale/index.d.ts +2 -111
- package/package.json +5 -2
- package/template/.agents/skills-lock.json +34 -0
- package/template/AGENTS.md +20 -0
- package/template/README.md +6 -5
- package/template/api/effect/index.ts.handlebars +7 -45
- package/template/api/lambda/hello.ts.handlebars +1 -1
- package/template/modern.config.ts.handlebars +21 -25
- package/template/oxfmt.config.ts +8 -0
- package/template/oxlint.config.ts +12 -0
- package/template/package.json.handlebars +41 -26
- package/template/scripts/bootstrap-agent-skills.mjs +95 -0
- package/template/scripts/validate-ultramodern.mjs.handlebars +81 -17
- package/template/shared/effect/api.ts.handlebars +1 -2
- package/template/src/modern.runtime.ts.handlebars +2 -4
- package/template/src/routes/index.css.handlebars +14 -3
- package/template/src/routes/page.tsx.handlebars +35 -18
- package/template/tsconfig.json +106 -2
- package/template-workspace/.agents/rstackjs-agent-skills-LICENSE +21 -0
- package/template-workspace/.agents/skills/rsbuild-best-practices/SKILL.md +57 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/SKILL.md +96 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/command-map.md +113 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/common-analysis-patterns.md +190 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-common.md +88 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md +138 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md +71 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor.md +39 -0
- package/template-workspace/.agents/skills/rsdoctor-analysis/references/rsdoctor-data-types.md +103 -0
- package/template-workspace/.agents/skills/rslib-best-practices/SKILL.md +58 -0
- package/template-workspace/.agents/skills/rslib-modern-package/SKILL.md +173 -0
- package/template-workspace/.agents/skills/rspack-best-practices/SKILL.md +70 -0
- package/template-workspace/.agents/skills/rspack-tracing/SKILL.md +75 -0
- package/template-workspace/.agents/skills/rspack-tracing/references/bottlenecks.md +47 -0
- package/template-workspace/.agents/skills/rspack-tracing/references/tracing-guide.md +38 -0
- package/template-workspace/.agents/skills/rspack-tracing/scripts/analyze_trace.js +184 -0
- package/template-workspace/.agents/skills/rstest-best-practices/SKILL.md +133 -0
- package/template-workspace/.agents/skills-lock.json +95 -0
- package/template-workspace/AGENTS.md +45 -0
- package/template-workspace/README.md.handlebars +8 -7
- package/template-workspace/oxfmt.config.ts +7 -0
- package/template-workspace/oxlint.config.ts +12 -0
- package/template-workspace/pnpm-workspace.yaml +12 -0
- package/template-workspace/scripts/bootstrap-agent-skills.mjs +106 -0
- package/template-workspace/scripts/validate-ultramodern-workspace.mjs.handlebars +127 -0
- package/template/biome.json +0 -41
|
@@ -2,17 +2,14 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
const configPath = path.resolve(process.cwd(), 'modern.config.ts');
|
|
5
|
-
const templateManifestPath = path.resolve(
|
|
6
|
-
process.cwd(),
|
|
7
|
-
'.modernjs/mv-template-manifest.json',
|
|
8
|
-
);
|
|
5
|
+
const templateManifestPath = path.resolve(process.cwd(), '.modernjs/mv-template-manifest.json');
|
|
9
6
|
|
|
10
7
|
if (!fs.existsSync(configPath)) {
|
|
11
8
|
console.error('modern.config.ts not found');
|
|
12
9
|
process.exit(1);
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
const content = fs.readFileSync(configPath, '
|
|
12
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
16
13
|
const requiredTokens = [
|
|
17
14
|
'presetUltramodern(',
|
|
18
15
|
'appTools()',
|
|
@@ -20,12 +17,10 @@ const requiredTokens = [
|
|
|
20
17
|
'enableBffRequestId',
|
|
21
18
|
'enableTelemetryExporters',
|
|
22
19
|
];
|
|
23
|
-
const missing = requiredTokens.filter(token => !content.includes(token));
|
|
20
|
+
const missing = requiredTokens.filter((token) => !content.includes(token));
|
|
24
21
|
|
|
25
22
|
if (missing.length > 0) {
|
|
26
|
-
console.error(
|
|
27
|
-
`Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`,
|
|
28
|
-
);
|
|
23
|
+
console.error(`Ultramodern contract check failed. Missing tokens: ${missing.join(', ')}`);
|
|
29
24
|
process.exit(1);
|
|
30
25
|
}
|
|
31
26
|
|
|
@@ -34,9 +29,7 @@ if (!fs.existsSync(templateManifestPath)) {
|
|
|
34
29
|
process.exit(1);
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
const templateManifest = JSON.parse(
|
|
38
|
-
fs.readFileSync(templateManifestPath, 'utf8'),
|
|
39
|
-
);
|
|
32
|
+
const templateManifest = JSON.parse(fs.readFileSync(templateManifestPath, 'utf-8'));
|
|
40
33
|
const requiredDeniedPaths = [
|
|
41
34
|
'.git/**',
|
|
42
35
|
'.github/**',
|
|
@@ -52,8 +45,22 @@ const requiredPostMaterialization = [
|
|
|
52
45
|
'dependency-install-with-lifecycle-deny',
|
|
53
46
|
'template-manifest-retained',
|
|
54
47
|
];
|
|
48
|
+
const requiredPaths = [
|
|
49
|
+
'AGENTS.md',
|
|
50
|
+
'.agents/skills-lock.json',
|
|
51
|
+
'oxlint.config.ts',
|
|
52
|
+
'oxfmt.config.ts',
|
|
53
|
+
'scripts/bootstrap-agent-skills.mjs',
|
|
54
|
+
];
|
|
55
55
|
const manifestErrors = [];
|
|
56
56
|
|
|
57
|
+
for (const requiredPath of requiredPaths) {
|
|
58
|
+
if (!fs.existsSync(path.resolve(process.cwd(), requiredPath))) {
|
|
59
|
+
console.error(`${requiredPath} not found`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
if (templateManifest.schemaVersion !== 1) {
|
|
58
65
|
manifestErrors.push('schemaVersion');
|
|
59
66
|
}
|
|
@@ -65,10 +72,10 @@ if (templateManifest.source?.type !== 'builtin') {
|
|
|
65
72
|
if (
|
|
66
73
|
!Array.isArray(templateManifest.integrity?.checksums) ||
|
|
67
74
|
!templateManifest.integrity.checksums.some(
|
|
68
|
-
checksum =>
|
|
75
|
+
(checksum) =>
|
|
69
76
|
checksum.algorithm === 'sha256' &&
|
|
70
77
|
checksum.scope === 'source-tree' &&
|
|
71
|
-
/^[0-9a-f]{64}
|
|
78
|
+
/^[0-9a-f]{64}$/u.test(checksum.value),
|
|
72
79
|
)
|
|
73
80
|
) {
|
|
74
81
|
manifestErrors.push('integrity.checksums[source-tree]');
|
|
@@ -92,11 +99,68 @@ for (const token of requiredPostMaterialization) {
|
|
|
92
99
|
|
|
93
100
|
if (manifestErrors.length > 0) {
|
|
94
101
|
console.error(
|
|
95
|
-
`Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(
|
|
96
|
-
', ',
|
|
97
|
-
)}`,
|
|
102
|
+
`Ultramodern template manifest check failed. Invalid fields: ${manifestErrors.join(', ')}`,
|
|
98
103
|
);
|
|
99
104
|
process.exit(1);
|
|
100
105
|
}
|
|
101
106
|
|
|
107
|
+
const packageJson = JSON.parse(
|
|
108
|
+
fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8'),
|
|
109
|
+
);
|
|
110
|
+
const unresolvedTemplateMarker = String.fromCodePoint(123, 123);
|
|
111
|
+
if (JSON.stringify(packageJson).includes(unresolvedTemplateMarker)) {
|
|
112
|
+
console.error('package.json contains unresolved template markers');
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const skillsLock = JSON.parse(
|
|
116
|
+
fs.readFileSync(path.resolve(process.cwd(), '.agents/skills-lock.json'), 'utf-8'),
|
|
117
|
+
);
|
|
118
|
+
const requiredScripts = {
|
|
119
|
+
format: 'oxfmt .',
|
|
120
|
+
'format:check': 'oxfmt --check .',
|
|
121
|
+
lint: 'oxlint .',
|
|
122
|
+
'lint:fix': 'oxlint . --fix',
|
|
123
|
+
'skills:check': 'node ./scripts/bootstrap-agent-skills.mjs --check',
|
|
124
|
+
'skills:install': 'node ./scripts/bootstrap-agent-skills.mjs',
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
for (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {
|
|
128
|
+
if (packageJson.scripts?.[scriptName] !== scriptCommand) {
|
|
129
|
+
console.error(`Missing or invalid package script: ${scriptName}`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
!packageJson.scripts?.typecheck?.includes('effect-tsgo') ||
|
|
136
|
+
!packageJson.scripts.typecheck.includes('get-exe-path')
|
|
137
|
+
) {
|
|
138
|
+
console.error('typecheck must use effect-tsgo as the TypeScript checker');
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (const dependency of [
|
|
143
|
+
'@effect/tsgo',
|
|
144
|
+
'@typescript/native-preview',
|
|
145
|
+
'oxlint',
|
|
146
|
+
'oxfmt',
|
|
147
|
+
'ultracite',
|
|
148
|
+
]) {
|
|
149
|
+
if (!packageJson.devDependencies?.[dependency]) {
|
|
150
|
+
console.error(`Missing devDependency: ${dependency}`);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const privateSource = skillsLock.sources?.find(
|
|
156
|
+
(source) => source.repository === 'https://github.com/TechsioCZ/skills',
|
|
157
|
+
);
|
|
158
|
+
const privateSkills = new Set(privateSource?.baseline?.map((skill) => skill.name));
|
|
159
|
+
for (const skillName of ['plan-graph', 'dag', 'subagent-graph', 'helm', 'debugger-mode']) {
|
|
160
|
+
if (!privateSkills.has(skillName)) {
|
|
161
|
+
console.error(`Missing private skill allowlist entry: ${skillName}`);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
102
166
|
console.log('Ultramodern contract check passed.');
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
body {
|
|
5
5
|
padding: 0;
|
|
6
6
|
margin: 0;
|
|
7
|
-
font-family:
|
|
7
|
+
font-family:
|
|
8
|
+
PingFang SC,
|
|
9
|
+
Hiragino Sans GB,
|
|
10
|
+
Microsoft YaHei,
|
|
11
|
+
Arial,
|
|
12
|
+
sans-serif;
|
|
8
13
|
background: linear-gradient(to bottom, transparent, #fff) #eceeef;
|
|
9
14
|
}
|
|
10
15
|
|
|
@@ -67,8 +72,14 @@ main {
|
|
|
67
72
|
padding: 0.6rem 0.9rem;
|
|
68
73
|
font-size: 1.05rem;
|
|
69
74
|
font-family:
|
|
70
|
-
Menlo,
|
|
71
|
-
|
|
75
|
+
Menlo,
|
|
76
|
+
Monaco,
|
|
77
|
+
Lucida Console,
|
|
78
|
+
Liberation Mono,
|
|
79
|
+
DejaVu Sans Mono,
|
|
80
|
+
Bitstream Vera Sans Mono,
|
|
81
|
+
Courier New,
|
|
82
|
+
monospace;
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
.container-box .grid {
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { Helmet } from '@modern-js/runtime/head';
|
|
2
2
|
{{#if useEffectBff}}import effectBff from '@api/effect/index';
|
|
3
|
+
import { Effect } from '@modern-js/plugin-bff/effect-client';
|
|
3
4
|
import { useEffect, useState } from 'react';
|
|
4
5
|
{{/if}}
|
|
5
6
|
import './index.css';
|
|
6
7
|
|
|
7
8
|
const Index = () => {
|
|
8
|
-
{{#if useEffectBff}}
|
|
9
|
-
const [effectMessage, setEffectMessage] = useState('loading...');
|
|
9
|
+
{{#if useEffectBff}} const [effectMessage, setEffectMessage] = useState('loading...');
|
|
10
10
|
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
let mounted = true;
|
|
13
|
+
Effect.runFork(
|
|
14
|
+
Effect.promise(() => effectBff.client.greetings.hello({})).pipe(
|
|
15
|
+
Effect.tap((data) =>
|
|
16
|
+
Effect.sync(() => {
|
|
17
|
+
if (mounted) {
|
|
18
|
+
setEffectMessage(data.message);
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
return () => {
|
|
25
|
+
mounted = false;
|
|
26
|
+
};
|
|
15
27
|
}, []);
|
|
16
28
|
{{/if}}
|
|
17
|
-
|
|
18
29
|
return (
|
|
19
30
|
<div className="container-box">
|
|
20
31
|
<Helmet>
|
|
@@ -26,19 +37,20 @@ const Index = () => {
|
|
|
26
37
|
</Helmet>
|
|
27
38
|
<main>
|
|
28
39
|
<div className="title">
|
|
29
|
-
|
|
40
|
+
UltraModern.js 3.0
|
|
30
41
|
<img
|
|
31
42
|
className="logo"
|
|
32
43
|
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"
|
|
33
|
-
alt="
|
|
44
|
+
alt="UltraModern.js Logo"
|
|
34
45
|
/>
|
|
35
46
|
<p className="name">presetUltramodern</p>
|
|
36
47
|
</div>
|
|
37
48
|
<p className="description{{#if enableTailwind}} text-emerald-700 font-semibold{{/if}}">
|
|
38
|
-
This starter ships the public <code className="code">presetUltramodern(...)</code>
|
|
49
|
+
This starter ships the public <code className="code">presetUltramodern(...)</code>{' '}
|
|
50
|
+
profile. Start in
|
|
39
51
|
<code className="code">modern.config.ts</code>, keep
|
|
40
|
-
<code className="code">pnpm run ultramodern:check</code> green, and
|
|
41
|
-
|
|
52
|
+
<code className="code">pnpm run ultramodern:check</code> green, and tune the generated
|
|
53
|
+
preset only where your app needs a softer lane.
|
|
42
54
|
</p>
|
|
43
55
|
{{#if useEffectBff}}
|
|
44
56
|
<p className="description effect-message{{#if enableTailwind}} text-emerald-700 font-semibold{{/if}}">
|
|
@@ -47,13 +59,13 @@ const Index = () => {
|
|
|
47
59
|
{{/if}}
|
|
48
60
|
<div className="grid">
|
|
49
61
|
<a
|
|
50
|
-
href="https://
|
|
62
|
+
href="https://bleedingdev.github.io/ultramodern.js/guides/get-started/ultramodern.html"
|
|
51
63
|
target="_blank"
|
|
52
64
|
rel="noopener noreferrer"
|
|
53
65
|
className="card"
|
|
54
66
|
>
|
|
55
67
|
<h2>
|
|
56
|
-
|
|
68
|
+
UltraModern.js Guide
|
|
57
69
|
<img
|
|
58
70
|
className="arrow-right"
|
|
59
71
|
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
|
|
@@ -63,7 +75,7 @@ const Index = () => {
|
|
|
63
75
|
<p>Review the MV-first, TanStack-ready, Effect-ready public preset.</p>
|
|
64
76
|
</a>
|
|
65
77
|
<a
|
|
66
|
-
href="https://
|
|
78
|
+
href="https://bleedingdev.github.io/ultramodern.js/configure/app/usage.html"
|
|
67
79
|
target="_blank"
|
|
68
80
|
className="card"
|
|
69
81
|
rel="noreferrer"
|
|
@@ -76,10 +88,12 @@ const Index = () => {
|
|
|
76
88
|
alt="Tutorials"
|
|
77
89
|
/>
|
|
78
90
|
</h2>
|
|
79
|
-
<p>
|
|
91
|
+
<p>
|
|
92
|
+
Tune the generated defaults in <code className="code">modern.config.ts</code>.
|
|
93
|
+
</p>
|
|
80
94
|
</a>
|
|
81
95
|
<a
|
|
82
|
-
href="https://github.com/
|
|
96
|
+
href="https://github.com/BleedingDev/ultramodern.js/blob/main-ultramodern/packages/toolkit/create/template/.github/workflows/ultramodern-gates.yml.handlebars"
|
|
83
97
|
target="_blank"
|
|
84
98
|
className="card"
|
|
85
99
|
rel="noreferrer"
|
|
@@ -92,10 +106,13 @@ const Index = () => {
|
|
|
92
106
|
alt="Config"
|
|
93
107
|
/>
|
|
94
108
|
</h2>
|
|
95
|
-
<p>
|
|
109
|
+
<p>
|
|
110
|
+
The starter includes a PR workflow for <code className="code">ultramodern:check</code>{' '}
|
|
111
|
+
and build.
|
|
112
|
+
</p>
|
|
96
113
|
</a>
|
|
97
114
|
<a
|
|
98
|
-
href="https://
|
|
115
|
+
href="https://bleedingdev.github.io/ultramodern.js/configure/app/bff/effect.html"
|
|
99
116
|
target="_blank"
|
|
100
117
|
rel="noopener noreferrer"
|
|
101
118
|
className="card"
|
package/template/tsconfig.json
CHANGED
|
@@ -3,13 +3,117 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"declaration": false,
|
|
5
5
|
"jsx": "preserve",
|
|
6
|
-
"
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
8
|
+
"module": "preserve",
|
|
9
|
+
"moduleResolution": "Bundler",
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUncheckedIndexedAccess": true,
|
|
20
|
+
"exactOptionalPropertyTypes": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
24
|
+
"noImplicitReturns": true,
|
|
7
25
|
"paths": {
|
|
8
26
|
"@/*": ["./src/*"],
|
|
9
27
|
"@api/*": ["./api/*"],
|
|
10
28
|
"@shared/*": ["./shared/*"]
|
|
11
29
|
},
|
|
12
|
-
"rootDir": "
|
|
30
|
+
"rootDir": ".",
|
|
31
|
+
"plugins": [
|
|
32
|
+
{
|
|
33
|
+
"name": "@effect/language-service",
|
|
34
|
+
"diagnostics": true,
|
|
35
|
+
"includeSuggestionsInTsc": true,
|
|
36
|
+
"ignoreEffectSuggestionsInTscExitCode": false,
|
|
37
|
+
"ignoreEffectWarningsInTscExitCode": false,
|
|
38
|
+
"ignoreEffectErrorsInTscExitCode": false,
|
|
39
|
+
"skipDisabledOptimization": true,
|
|
40
|
+
"diagnosticSeverity": {
|
|
41
|
+
"anyUnknownInErrorContext": "error",
|
|
42
|
+
"classSelfMismatch": "error",
|
|
43
|
+
"duplicatePackage": "error",
|
|
44
|
+
"effectFnImplicitAny": "error",
|
|
45
|
+
"floatingEffect": "error",
|
|
46
|
+
"genericEffectServices": "error",
|
|
47
|
+
"missingEffectContext": "error",
|
|
48
|
+
"missingEffectError": "error",
|
|
49
|
+
"missingLayerContext": "error",
|
|
50
|
+
"missingReturnYieldStar": "error",
|
|
51
|
+
"missingStarInYieldEffectGen": "error",
|
|
52
|
+
"nonObjectEffectServiceType": "error",
|
|
53
|
+
"outdatedApi": "error",
|
|
54
|
+
"overriddenSchemaConstructor": "error",
|
|
55
|
+
"catchUnfailableEffect": "error",
|
|
56
|
+
"effectFnIife": "error",
|
|
57
|
+
"effectGenUsesAdapter": "error",
|
|
58
|
+
"effectInFailure": "error",
|
|
59
|
+
"effectInVoidSuccess": "error",
|
|
60
|
+
"globalErrorInEffectCatch": "error",
|
|
61
|
+
"globalErrorInEffectFailure": "error",
|
|
62
|
+
"layerMergeAllWithDependencies": "error",
|
|
63
|
+
"lazyPromiseInEffectSync": "error",
|
|
64
|
+
"leakingRequirements": "error",
|
|
65
|
+
"multipleEffectProvide": "error",
|
|
66
|
+
"returnEffectInGen": "error",
|
|
67
|
+
"runEffectInsideEffect": "error",
|
|
68
|
+
"schemaSyncInEffect": "error",
|
|
69
|
+
"scopeInLayerEffect": "error",
|
|
70
|
+
"strictEffectProvide": "error",
|
|
71
|
+
"tryCatchInEffectGen": "error",
|
|
72
|
+
"unknownInEffectCatch": "error",
|
|
73
|
+
"asyncFunction": "error",
|
|
74
|
+
"cryptoRandomUUID": "error",
|
|
75
|
+
"cryptoRandomUUIDInEffect": "error",
|
|
76
|
+
"extendsNativeError": "error",
|
|
77
|
+
"globalConsole": "error",
|
|
78
|
+
"globalConsoleInEffect": "error",
|
|
79
|
+
"globalDate": "error",
|
|
80
|
+
"globalDateInEffect": "error",
|
|
81
|
+
"globalFetch": "error",
|
|
82
|
+
"globalFetchInEffect": "error",
|
|
83
|
+
"globalRandom": "error",
|
|
84
|
+
"globalRandomInEffect": "error",
|
|
85
|
+
"globalTimers": "error",
|
|
86
|
+
"globalTimersInEffect": "error",
|
|
87
|
+
"instanceOfSchema": "error",
|
|
88
|
+
"newPromise": "error",
|
|
89
|
+
"nodeBuiltinImport": "error",
|
|
90
|
+
"preferSchemaOverJson": "error",
|
|
91
|
+
"processEnv": "error",
|
|
92
|
+
"processEnvInEffect": "error",
|
|
93
|
+
"unsafeEffectTypeAssertion": "error",
|
|
94
|
+
"catchAllToMapError": "error",
|
|
95
|
+
"deterministicKeys": "error",
|
|
96
|
+
"effectDoNotation": "error",
|
|
97
|
+
"effectFnOpportunity": "error",
|
|
98
|
+
"effectMapFlatten": "error",
|
|
99
|
+
"effectMapVoid": "error",
|
|
100
|
+
"effectSucceedWithVoid": "error",
|
|
101
|
+
"missedPipeableOpportunity": "error",
|
|
102
|
+
"missingEffectServiceDependency": "error",
|
|
103
|
+
"nestedEffectGenYield": "error",
|
|
104
|
+
"redundantSchemaTagIdentifier": "error",
|
|
105
|
+
"schemaStructWithTag": "error",
|
|
106
|
+
"schemaUnionOfLiterals": "error",
|
|
107
|
+
"serviceNotAsClass": "error",
|
|
108
|
+
"strictBooleanExpressions": "error",
|
|
109
|
+
"unnecessaryArrowBlock": "error",
|
|
110
|
+
"unnecessaryEffectGen": "error",
|
|
111
|
+
"unnecessaryFailYieldableError": "error",
|
|
112
|
+
"unnecessaryPipe": "error",
|
|
113
|
+
"unnecessaryPipeChain": "error"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
]
|
|
13
117
|
},
|
|
14
118
|
"include": ["src", "api", "shared", "config", "modern.config.ts"],
|
|
15
119
|
"exclude": ["**/node_modules"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RstackJS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rsbuild-best-practices
|
|
3
|
+
description: Rsbuild best practices for config, CLI workflow, type checking, bundle optimization, assets, and debugging. Use when writing, reviewing, or troubleshooting Rsbuild projects.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rsbuild Best Practices
|
|
7
|
+
|
|
8
|
+
Apply these rules when writing or reviewing Rsbuild projects.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
- Use `rsbuild.config.ts` and `defineConfig`
|
|
13
|
+
- Use `tools.rspack` or `tools.bundlerChain` only when no first-class Rsbuild option exists
|
|
14
|
+
- Define explicit `source.entry` values for multi-page applications
|
|
15
|
+
- In TypeScript projects, prefer `tsconfig.json` path aliases first
|
|
16
|
+
|
|
17
|
+
## CLI
|
|
18
|
+
|
|
19
|
+
- Use `rsbuild` for local development
|
|
20
|
+
- Use `rsbuild build` for production build
|
|
21
|
+
- Use `rsbuild preview` only for local production preview
|
|
22
|
+
- Use `rsbuild inspect` to inspect final Rsbuild/Rspack configs
|
|
23
|
+
|
|
24
|
+
## Type checking
|
|
25
|
+
|
|
26
|
+
- Use `@rsbuild/plugin-type-check` for integrated dev/build type checks
|
|
27
|
+
- Or run `tsc --noEmit`/`vue-tsc --noEmit` as an explicit script step
|
|
28
|
+
|
|
29
|
+
## Bundle size optimization
|
|
30
|
+
|
|
31
|
+
- Prefer dynamic `import()` for non-critical code paths
|
|
32
|
+
- Prefer lightweight libraries where possible
|
|
33
|
+
- Keep browserslist aligned with real compatibility requirements
|
|
34
|
+
|
|
35
|
+
## Asset management
|
|
36
|
+
|
|
37
|
+
- Import source-managed assets from project source directories, not from `public`
|
|
38
|
+
- Reference `public` files by absolute URL path
|
|
39
|
+
|
|
40
|
+
## Security
|
|
41
|
+
|
|
42
|
+
- Do not publish `.map` files to public servers/CDNs when production source maps are enabled
|
|
43
|
+
|
|
44
|
+
## Debugging
|
|
45
|
+
|
|
46
|
+
- Run with `DEBUG=rsbuild` when diagnosing config resolution or plugin behavior
|
|
47
|
+
- Read generated files in `dist/.rsbuild` to confirm final config, not assumed config
|
|
48
|
+
|
|
49
|
+
## Profiling
|
|
50
|
+
|
|
51
|
+
- Use Node CPU profiling (`--cpu-prof`) when JavaScript-side overhead is suspected
|
|
52
|
+
- Use `RSPACK_PROFILE=OVERVIEW` and analyze trace output for compiler-phase bottlenecks
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
- For the latest (v2) docs, read http://rsbuild.rs/llms.txt
|
|
57
|
+
- For Rsbuild v1 docs, read http://v1.rsbuild.rs/llms.txt
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rsdoctor-analysis
|
|
3
|
+
description: Use when analyzing Rspack/Webpack bundles from local `rsdoctor-data.json` and producing evidence-based optimization recommendations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rsdoctor Analysis Assistant Skill
|
|
7
|
+
|
|
8
|
+
Use the globally installed `rsdoctor-agent` CLI from `@rsdoctor/agent-cli` only after a real `rsdoctor-data.json` path exists. Keep analysis read-only unless the user explicitly asks for install/config setup.
|
|
9
|
+
|
|
10
|
+
Response order (required): High-Priority Issues -> Proposed Solutions -> Optional Reference-Chain Follow-up Choices -> Next Deep-Dive Issue Categories (Not commands).
|
|
11
|
+
|
|
12
|
+
## Core Workflow
|
|
13
|
+
|
|
14
|
+
1. Reuse current-session results and valid `.rsdoctor-analysis-cache.json` entries before doing new work.
|
|
15
|
+
2. Locate `rsdoctor-data.json` fast: user-provided path, then `dist/rsdoctor-data.json`, `output/rsdoctor-data.json`, `static/rsdoctor-data.json`, `.rsdoctor/rsdoctor-data.json`, then one bounded `rg --files` search excluding `node_modules` and `.git`. Treat `manifest.json` only as an index.
|
|
16
|
+
3. If data exists, skip all plugin version/config/build generation logic. Update cache when useful.
|
|
17
|
+
4. If data is missing, stop analysis: do not run `rsdoctor-agent` analysis commands, do not run the Analysis Gate, and either ask for the data path or run the Generation Gate below only when setup/generation is required.
|
|
18
|
+
5. After a real data file exists, run Analysis Gate at most once before the first `rsdoctor-agent` data-fetch command: verify global `@rsdoctor/agent-cli` with `npm view @rsdoctor/agent-cli version` and `rsdoctor-agent --version`; install latest only if missing/outdated, a version-related error occurs, or the user asks to refresh.
|
|
19
|
+
6. Fetch only the Default Evidence Set first; run independent fetches in parallel when possible; synthesize findings in the required response order.
|
|
20
|
+
|
|
21
|
+
Performance rules: parallelize independent checks, cache only derived facts (`dataFile`, `dataFileMtime`, `pluginName`, `pluginVersion`, dependency/config/plugin modification times), and invalidate cache when paths disappear, modification times change, the user asks to refresh, or cached values fail. Speculative plugin checks must not trigger generation; use them only after confirming the data file is missing.
|
|
22
|
+
|
|
23
|
+
## Generation Gate
|
|
24
|
+
|
|
25
|
+
Identify `pluginName` (`@rsdoctor/rspack-plugin` or `@rsdoctor/webpack-plugin`) and determine `pluginVersion` from local files first: `package.json`, lockfile, then `node_modules/<plugin>/package.json`; use `pnpm why` / `npm ls` only as fallback.
|
|
26
|
+
|
|
27
|
+
Use this exact if/else decision tree; do not merge branches:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
if pluginName is missing:
|
|
31
|
+
install/register the matching Rsdoctor plugin, then configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
|
|
32
|
+
else if pluginVersion is unknown:
|
|
33
|
+
resolve pluginVersion first; if still unknown, configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
|
|
34
|
+
else if pluginVersion >= 1.5.11:
|
|
35
|
+
do not edit plugin config just for JSON; build with RSDOCTOR_OUTPUT=json and RSDOCTOR=true if needed
|
|
36
|
+
else: # pluginVersion < 1.5.11
|
|
37
|
+
MUST configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Preflight every build command: `RSDOCTOR_OUTPUT=json` is allowed only in the `pluginVersion >= 1.5.11` branch. For missing, unknown, or `< 1.5.11`, it is forbidden. For `< 1.5.11`, generating `rsdoctor-data.json` requires the plugin config below:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
output: {
|
|
44
|
+
mode: 'brief',
|
|
45
|
+
options: {
|
|
46
|
+
type: ['json'],
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Evidence and Command Bounds
|
|
52
|
+
|
|
53
|
+
Default Evidence Set:
|
|
54
|
+
|
|
55
|
+
| Summary key | Evidence source | Bounds |
|
|
56
|
+
| -------------------- | ------------------------------------------ | --------------------------------------------- |
|
|
57
|
+
| `buildCost` | `build summary` | filtered fields only |
|
|
58
|
+
| `assetsTop` | top assets by raw/gzip size | fixed Top-N |
|
|
59
|
+
| `packagesTop` | top packages by gzip size | fixed Top-N; avoid full `packages list` pages |
|
|
60
|
+
| `duplicatePackages` | E1001 duplicate package summary | first-pass summary only |
|
|
61
|
+
| `crossChunkPackages` | E1002 cross-chunk duplication summary | first-pass summary only |
|
|
62
|
+
| `retainedModulesTop` | `tree-shaking retained-modules --limit 10` | filtered fields only; no `--compact` |
|
|
63
|
+
|
|
64
|
+
Scope rules:
|
|
65
|
+
|
|
66
|
+
- Use `rsdoctor-agent` for bundle data access only after `rsdoctor-data.json` exists; prefer parallel independent fetches; bound output with `--filter`, pagination, and `--limit`.
|
|
67
|
+
- Default analysis stays within the Default Evidence Set. For non-default analysis, choose minimal fields from [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md) and patterns from [references/common-analysis-patterns.md](references/common-analysis-patterns.md).
|
|
68
|
+
- Treat chain tracing, broad commands, optimization edits, splitChunks experiments, and build re-runs as opt-in follow-ups that require user confirmation.
|
|
69
|
+
- For duplicate packages and tree-shaking issues, identify issues first; trace reference/import chains only after user confirmation.
|
|
70
|
+
- Prefer `tree-shaking retained-modules --emitted-only --category side-effects --limit 10` with narrow `--filter` for side-effects investigations.
|
|
71
|
+
- For retained emitted modules, use `tree-shaking retained-modules` with `--emitted-only`, bounded `--category`, `--sort gzipSize`, `--limit`, and narrow `--filter`; do not pass `--compact`.
|
|
72
|
+
- Use `tree-shaking summary` only as fallback for missing fields or aggregate context. Treat `tree-shaking bailout-reasons` as high-volume; run it only when explicitly requested and pass target `--modules` (max 100).
|
|
73
|
+
- If any command exceeds `5k` tokens, `500 KB` raw output, or a few hundred transcript lines, stop broad fetching and switch to targeted compact queries.
|
|
74
|
+
|
|
75
|
+
## Output and Recovery
|
|
76
|
+
|
|
77
|
+
Output format:
|
|
78
|
+
|
|
79
|
+
1. Issues found in the current build and recommended fixes:
|
|
80
|
+
- Group each issue with its fix recommendation.
|
|
81
|
+
- Include concrete evidence (size/time/count/path/rule code) and priority.
|
|
82
|
+
- For duplicate packages and tree-shaking issues, include a short "continue tracing vs stop here" choice.
|
|
83
|
+
2. Whether deeper analysis is still needed:
|
|
84
|
+
- List remaining issue categories only, not commands.
|
|
85
|
+
|
|
86
|
+
For Top-N insights, prefer a table: `Name | Volume/Time | Count | Recommendation`.
|
|
87
|
+
|
|
88
|
+
Recovery rules:
|
|
89
|
+
|
|
90
|
+
- `rsdoctor-data.json` missing: do not run `rsdoctor-agent`; ask for the data path or run Generation Gate, then use the matching install reference if setup is needed.
|
|
91
|
+
- Command not found: run Analysis Gate, then retry with `rsdoctor-agent`.
|
|
92
|
+
- `query` reports unknown tool: run `list` and use a catalog tool name, or switch to direct `<group> <subcommand>` mode.
|
|
93
|
+
- JSON read error: verify file path, JSON validity, and permissions.
|
|
94
|
+
- In Codex, do not run `install`, `build`, global CLI installation, version checks, or `rsdoctor-agent...` inside sandbox. Run Rsdoctor CLI setup and data-fetch commands outside sandbox so they can access project files and dependencies normally.
|
|
95
|
+
|
|
96
|
+
References: commands/options [references/command-map.md](references/command-map.md); install/config/data location [references/install-rsdoctor.md](references/install-rsdoctor.md), [references/install-rsdoctor-rspack.md](references/install-rsdoctor-rspack.md), [references/install-rsdoctor-webpack.md](references/install-rsdoctor-webpack.md), [references/install-rsdoctor-common.md](references/install-rsdoctor-common.md); raw data fields [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md); common patterns [references/common-analysis-patterns.md](references/common-analysis-patterns.md).
|