Skip to content

Commit 05b662f

Browse files
authored
chore: avoid unnecessary config dynamic imports (#447)
1 parent 9325b44 commit 05b662f

3 files changed

Lines changed: 100 additions & 106 deletions

File tree

‎examples/test-inline-projects/rstack.config.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// Configuration guide: https://rstack.rs/config
2+
import { pluginReact } from '@rsbuild/plugin-react';
23
import { define } from 'rstack';
34

4-
define.app(async () => {
5-
const { pluginReact } = await import('@rsbuild/plugin-react');
6-
return {
7-
plugins: [pluginReact()],
8-
};
5+
define.app({
6+
plugins: [pluginReact()],
97
});
108

119
define.test(async () => {

‎packages/rstack/rstack.config.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// Configuration guide: https://rstack.rs/config
2+
import { withRslibConfig } from '@rstest/adapter-rslib';
23
import { define } from 'rstack';
34

4-
define.test(async () => {
5-
const { withRslibConfig } = await import('@rstest/adapter-rslib');
6-
5+
define.test(() => {
76
// Disable color in test
87
process.env.NO_COLOR = '1';
98

‎website/rstack.config.ts‎

Lines changed: 95 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// Configuration guide: https://rstack.rs/config
2+
import { pluginSass } from '@rsbuild/plugin-sass';
3+
import { pluginClientRedirects } from '@rspress/plugin-client-redirects';
4+
import { pluginSitemap } from '@rspress/plugin-sitemap';
5+
import {
6+
transformerNotationDiff,
7+
transformerNotationFocus,
8+
transformerNotationHighlight,
9+
} from '@shikijs/transformers';
210
import path from 'node:path';
311
import { define } from 'rstack';
12+
import { pluginOpenGraph } from 'rsbuild-plugin-open-graph';
13+
import { pluginFontOpenSans } from 'rspress-plugin-font-open-sans';
414

515
const title = 'Rstack CLI';
616
const description =
@@ -9,115 +19,102 @@ const descriptionZh =
919
'Rstack CLI 通过统一的命令行、配置和工作流整合 Rstack 工具链。';
1020
const injectLlmsHint = process.env.RSPRESS_INJECT_LLMS_HINT !== 'false';
1121

12-
define.doc(async () => {
13-
const { pluginSass } = await import('@rsbuild/plugin-sass');
14-
const {
15-
transformerNotationDiff,
16-
transformerNotationFocus,
17-
transformerNotationHighlight,
18-
} = await import('@shikijs/transformers');
19-
const { pluginClientRedirects } =
20-
await import('@rspress/plugin-client-redirects');
21-
const { pluginSitemap } = await import('@rspress/plugin-sitemap');
22-
const { pluginOpenGraph } = await import('rsbuild-plugin-open-graph');
23-
const { pluginFontOpenSans } = await import('rspress-plugin-font-open-sans');
24-
const siteUrl = 'https://rstack.rs';
22+
const siteUrl = 'https://rstack.rs';
2523

26-
return {
27-
root: path.join(import.meta.dirname, 'docs'),
28-
title,
29-
icon: 'https://assets.rspack.rs/rspack/rspack-claw-logo.svg',
30-
logo: '/horizontal-logo.svg',
31-
description,
32-
lang: 'en',
33-
llms: true,
34-
search: {
35-
codeBlocks: true,
24+
define.doc({
25+
root: path.join(import.meta.dirname, 'docs'),
26+
title,
27+
icon: 'https://assets.rspack.rs/rspack/rspack-claw-logo.svg',
28+
logo: '/horizontal-logo.svg',
29+
description,
30+
lang: 'en',
31+
llms: true,
32+
search: {
33+
codeBlocks: true,
34+
},
35+
markdown: {
36+
link: {
37+
checkAnchors: true,
38+
checkDeadLinks: true,
3639
},
37-
markdown: {
38-
link: {
39-
checkAnchors: true,
40-
checkDeadLinks: true,
41-
},
42-
shiki: {
43-
transformers: [
44-
transformerNotationDiff(),
45-
transformerNotationHighlight(),
46-
transformerNotationFocus(),
47-
],
48-
},
40+
shiki: {
41+
transformers: [
42+
transformerNotationDiff(),
43+
transformerNotationHighlight(),
44+
transformerNotationFocus(),
45+
],
4946
},
50-
route: {
51-
cleanUrls: true,
47+
},
48+
route: {
49+
cleanUrls: true,
50+
},
51+
plugins: [
52+
pluginClientRedirects({
53+
redirects: [
54+
{
55+
from: '^/config/?$',
56+
to: '/guide/configuration',
57+
},
58+
],
59+
}),
60+
pluginFontOpenSans(),
61+
pluginSitemap({ siteUrl }),
62+
],
63+
locales: [
64+
{
65+
lang: 'en',
66+
label: 'English',
67+
title,
68+
description,
5269
},
53-
plugins: [
54-
pluginClientRedirects({
55-
redirects: [
56-
{
57-
from: '^/config/?$',
58-
to: '/guide/configuration',
59-
},
60-
],
61-
}),
62-
pluginFontOpenSans(),
63-
pluginSitemap({ siteUrl }),
64-
],
65-
locales: [
70+
{
71+
lang: 'zh',
72+
label: '简体中文',
73+
title,
74+
description: descriptionZh,
75+
},
76+
],
77+
themeConfig: {
78+
llmsUI: {
79+
placement: 'outline',
80+
injectLlmsHint,
81+
},
82+
socialLinks: [
6683
{
67-
lang: 'en',
68-
label: 'English',
69-
title,
70-
description,
84+
icon: 'github',
85+
mode: 'link',
86+
content: 'https://github.com/rstackjs/rstack-cli',
7187
},
7288
{
73-
lang: 'zh',
74-
label: '简体中文',
75-
title,
76-
description: descriptionZh,
89+
icon: 'discord',
90+
mode: 'link',
91+
content: 'https://discord.gg/XsaKEEk4mW',
7792
},
7893
],
79-
themeConfig: {
80-
llmsUI: {
81-
placement: 'outline',
82-
injectLlmsHint,
83-
},
84-
socialLinks: [
85-
{
86-
icon: 'github',
87-
mode: 'link',
88-
content: 'https://github.com/rstackjs/rstack-cli',
89-
},
90-
{
91-
icon: 'discord',
92-
mode: 'link',
93-
content: 'https://discord.gg/XsaKEEk4mW',
94-
},
95-
],
96-
editLink: {
97-
docRepoBaseUrl:
98-
'https://github.com/rstackjs/rstack-cli/tree/main/website/docs',
99-
},
94+
editLink: {
95+
docRepoBaseUrl:
96+
'https://github.com/rstackjs/rstack-cli/tree/main/website/docs',
10097
},
101-
builderConfig: {
102-
plugins: [
103-
pluginSass(),
104-
pluginOpenGraph({
105-
title,
106-
type: 'website',
107-
url: siteUrl,
108-
description,
109-
}),
110-
],
111-
server: {
112-
open: true,
113-
},
114-
tools: {
115-
rspack: {
116-
experiments: {
117-
nativeWatcher: true,
118-
},
98+
},
99+
builderConfig: {
100+
plugins: [
101+
pluginSass(),
102+
pluginOpenGraph({
103+
title,
104+
type: 'website',
105+
url: siteUrl,
106+
description,
107+
}),
108+
],
109+
server: {
110+
open: true,
111+
},
112+
tools: {
113+
rspack: {
114+
experiments: {
115+
nativeWatcher: true,
119116
},
120117
},
121118
},
122-
};
119+
},
123120
});

0 commit comments

Comments
 (0)