@docusaurus/core 4.0.0-canary-6905 → 4.0.0-canary-6909
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.
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import { RspackDevServer } from '@docusaurus/bundler';
|
|
7
8
|
import WebpackDevServer from 'webpack-dev-server';
|
|
8
9
|
import type { StartCLIOptions } from './start';
|
|
9
10
|
import type { Props } from '@docusaurus/types';
|
|
@@ -12,4 +13,4 @@ export declare function createWebpackDevServer({ props, cliOptions, openUrlConte
|
|
|
12
13
|
props: Props;
|
|
13
14
|
cliOptions: StartCLIOptions;
|
|
14
15
|
openUrlContext: OpenUrlContext;
|
|
15
|
-
}): Promise<WebpackDevServer>;
|
|
16
|
+
}): Promise<WebpackDevServer | RspackDevServer>;
|
|
@@ -147,9 +147,6 @@ async function createDevServer({ devServerConfig, compiler, currentBundler, }) {
|
|
|
147
147
|
if (currentBundler.name === 'webpack') {
|
|
148
148
|
return new webpack_dev_server_1.default(devServerConfig, compiler);
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// @ts-expect-error: different types
|
|
153
|
-
return new RspackDevServer(devServerConfig, compiler);
|
|
154
|
-
}
|
|
150
|
+
// Docusaurus bundler configs are typed with Webpack types
|
|
151
|
+
return new bundler_1.RspackDevServer(devServerConfig, compiler);
|
|
155
152
|
}
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { Joi } from '@docusaurus/utils-validation';
|
|
8
|
-
import type { DocusaurusConfig,
|
|
8
|
+
import type { DocusaurusConfig, FutureConfig, FutureV4Config, I18nConfig, StorageConfig } from '@docusaurus/types';
|
|
9
9
|
export declare const DEFAULT_I18N_CONFIG: I18nConfig;
|
|
10
10
|
export declare const DEFAULT_STORAGE_CONFIG: StorageConfig;
|
|
11
|
-
export declare const DEFAULT_FASTER_CONFIG: FasterConfig;
|
|
12
|
-
export declare const DEFAULT_FASTER_CONFIG_TRUE: FasterConfig;
|
|
13
11
|
export declare const DEFAULT_FUTURE_V4_CONFIG: FutureV4Config;
|
|
14
12
|
export declare const DEFAULT_FUTURE_V4_CONFIG_TRUE: FutureV4Config;
|
|
15
13
|
export declare const DEFAULT_FUTURE_CONFIG: FutureConfig;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_FUTURE_CONFIG = exports.DEFAULT_FUTURE_V4_CONFIG_TRUE = exports.DEFAULT_FUTURE_V4_CONFIG = exports.
|
|
9
|
+
exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_FUTURE_CONFIG = exports.DEFAULT_FUTURE_V4_CONFIG_TRUE = exports.DEFAULT_FUTURE_V4_CONFIG = exports.DEFAULT_STORAGE_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
|
|
10
10
|
exports.validateConfig = validateConfig;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -43,29 +43,17 @@ exports.DEFAULT_I18N_CONFIG = {
|
|
|
43
43
|
};
|
|
44
44
|
exports.DEFAULT_STORAGE_CONFIG = {
|
|
45
45
|
type: 'localStorage',
|
|
46
|
-
namespace:
|
|
47
|
-
};
|
|
48
|
-
exports.DEFAULT_FASTER_CONFIG = {
|
|
49
|
-
rspackBundler: false,
|
|
50
|
-
};
|
|
51
|
-
// When using the "faster: true" shortcut
|
|
52
|
-
exports.DEFAULT_FASTER_CONFIG_TRUE = {
|
|
53
|
-
rspackBundler: true,
|
|
46
|
+
namespace: true,
|
|
54
47
|
};
|
|
55
48
|
exports.DEFAULT_FUTURE_V4_CONFIG = {
|
|
56
49
|
useCssCascadeLayers: false,
|
|
57
|
-
siteStorageNamespacing: false,
|
|
58
|
-
fasterByDefault: false,
|
|
59
50
|
};
|
|
60
51
|
// When using the "v4: true" shortcut
|
|
61
52
|
exports.DEFAULT_FUTURE_V4_CONFIG_TRUE = {
|
|
62
53
|
useCssCascadeLayers: true,
|
|
63
|
-
siteStorageNamespacing: true,
|
|
64
|
-
fasterByDefault: true,
|
|
65
54
|
};
|
|
66
55
|
exports.DEFAULT_FUTURE_CONFIG = {
|
|
67
56
|
v4: exports.DEFAULT_FUTURE_V4_CONFIG,
|
|
68
|
-
faster: exports.DEFAULT_FASTER_CONFIG,
|
|
69
57
|
experimental_router: 'browser',
|
|
70
58
|
};
|
|
71
59
|
const DEFAULT_MARKDOWN_HOOKS = {
|
|
@@ -185,26 +173,9 @@ const I18N_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
|
185
173
|
})
|
|
186
174
|
.optional()
|
|
187
175
|
.default(exports.DEFAULT_I18N_CONFIG);
|
|
188
|
-
// Individual boolean defaults are not set here on purpose
|
|
189
|
-
// They are resolved in postProcessDocusaurusConfig based on
|
|
190
|
-
// the future.v4.fasterByDefault flag
|
|
191
|
-
const FASTER_CONFIG_SCHEMA = utils_validation_1.Joi.alternatives()
|
|
192
|
-
.try(utils_validation_1.Joi.object({
|
|
193
|
-
rspackBundler: utils_validation_1.Joi.boolean(),
|
|
194
|
-
swcJsLoader: utils_validation_1.Joi.any()
|
|
195
|
-
.forbidden()
|
|
196
|
-
.messages({
|
|
197
|
-
'any.unknown': `The Docusaurus config ${logger_1.default.code('future.faster.swcJsLoader')} has been removed. Rspack always uses its built-in SWC loader. Webpack uses Babel by default, and you can provide a custom JS loader with ${logger_1.default.code('siteConfig.webpack.jsLoader')}.`,
|
|
198
|
-
}),
|
|
199
|
-
}), utils_validation_1.Joi.boolean()
|
|
200
|
-
.required()
|
|
201
|
-
.custom((bool) => bool ? exports.DEFAULT_FASTER_CONFIG_TRUE : exports.DEFAULT_FASTER_CONFIG))
|
|
202
|
-
.optional();
|
|
203
176
|
const FUTURE_V4_SCHEMA = utils_validation_1.Joi.alternatives()
|
|
204
177
|
.try(utils_validation_1.Joi.object({
|
|
205
178
|
useCssCascadeLayers: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FUTURE_V4_CONFIG.useCssCascadeLayers),
|
|
206
|
-
siteStorageNamespacing: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FUTURE_V4_CONFIG.siteStorageNamespacing),
|
|
207
|
-
fasterByDefault: utils_validation_1.Joi.boolean().default(exports.DEFAULT_FUTURE_V4_CONFIG.fasterByDefault),
|
|
208
179
|
}), utils_validation_1.Joi.boolean()
|
|
209
180
|
.required()
|
|
210
181
|
.custom((bool) => bool ? exports.DEFAULT_FUTURE_V4_CONFIG_TRUE : exports.DEFAULT_FUTURE_V4_CONFIG))
|
|
@@ -214,13 +185,12 @@ const STORAGE_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
|
214
185
|
type: utils_validation_1.Joi.string()
|
|
215
186
|
.equal('localStorage', 'sessionStorage')
|
|
216
187
|
.default(exports.DEFAULT_STORAGE_CONFIG.type),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
namespace: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.boolean()),
|
|
188
|
+
namespace: utils_validation_1.Joi.alternatives()
|
|
189
|
+
.try(utils_validation_1.Joi.string(), utils_validation_1.Joi.boolean())
|
|
190
|
+
.default(exports.DEFAULT_STORAGE_CONFIG.namespace),
|
|
221
191
|
})
|
|
222
192
|
.optional()
|
|
223
|
-
.default(
|
|
193
|
+
.default(exports.DEFAULT_STORAGE_CONFIG);
|
|
224
194
|
const VCS_CONFIG_OBJECT_SCHEMA = utils_validation_1.Joi.object({
|
|
225
195
|
// All the fields are required on purpose
|
|
226
196
|
// You either provide a full VCS config or nothing
|
|
@@ -247,7 +217,11 @@ const VCS_CONFIG_SCHEMA = utils_validation_1.Joi.custom((input) => {
|
|
|
247
217
|
}).default(() => exports.DEFAULT_CONFIG.vcs);
|
|
248
218
|
const FUTURE_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
249
219
|
v4: FUTURE_V4_SCHEMA,
|
|
250
|
-
faster:
|
|
220
|
+
faster: utils_validation_1.Joi.any()
|
|
221
|
+
.forbidden()
|
|
222
|
+
.messages({
|
|
223
|
+
'any.unknown': `The Docusaurus config ${logger_1.default.code('future.faster')} has been removed. Docusaurus now uses Rspack by default. To keep using Webpack and Babel (deprecated), use ${logger_1.default.code('siteConfig.webpack: true')}.`,
|
|
224
|
+
}),
|
|
251
225
|
experimental_router: utils_validation_1.Joi.string()
|
|
252
226
|
.equal('browser', 'hash')
|
|
253
227
|
.default(exports.DEFAULT_FUTURE_CONFIG.experimental_router),
|
|
@@ -259,7 +233,7 @@ const FUTURE_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
|
259
233
|
experimental_faster: utils_validation_1.Joi.any()
|
|
260
234
|
.forbidden()
|
|
261
235
|
.messages({
|
|
262
|
-
'any.unknown': `The Docusaurus config ${logger_1.default.code('future.experimental_faster')} has been
|
|
236
|
+
'any.unknown': `The Docusaurus config ${logger_1.default.code('future.experimental_faster')} has been removed. Docusaurus now uses Rspack by default. To keep using Webpack and Babel (deprecated), use ${logger_1.default.code('siteConfig.webpack: true')}.`,
|
|
263
237
|
}),
|
|
264
238
|
})
|
|
265
239
|
.optional()
|
|
@@ -347,11 +321,14 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
347
321
|
tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
|
|
348
322
|
titleDelimiter: utils_validation_1.Joi.string().default(exports.DEFAULT_CONFIG.titleDelimiter),
|
|
349
323
|
noIndex: utils_validation_1.Joi.bool().default(exports.DEFAULT_CONFIG.noIndex),
|
|
350
|
-
|
|
324
|
+
// Normalized in postProcessDocusaurusConfig
|
|
325
|
+
webpack: utils_validation_1.Joi.alternatives()
|
|
326
|
+
.try(utils_validation_1.Joi.boolean(), utils_validation_1.Joi.object({
|
|
351
327
|
jsLoader: utils_validation_1.Joi.alternatives()
|
|
352
328
|
.try(utils_validation_1.Joi.string().equal('babel'), utils_validation_1.Joi.function())
|
|
353
329
|
.optional(),
|
|
354
|
-
})
|
|
330
|
+
}))
|
|
331
|
+
.optional(),
|
|
355
332
|
markdown: utils_validation_1.Joi.object({
|
|
356
333
|
format: utils_validation_1.Joi.string()
|
|
357
334
|
.equal('mdx', 'md', 'detect')
|
|
@@ -394,22 +371,13 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
394
371
|
// Expressing this kind of logic in Joi is a pain
|
|
395
372
|
// We also want to decouple logic from Joi: easier to remove it later!
|
|
396
373
|
function postProcessDocusaurusConfig(config) {
|
|
397
|
-
// Resolve
|
|
398
|
-
|
|
399
|
-
if (
|
|
400
|
-
config.
|
|
401
|
-
}
|
|
402
|
-
// Resolve faster config based on the v4.fasterByDefault flag
|
|
403
|
-
// undefined means "not explicitly set by user"
|
|
404
|
-
if (config.future.faster === undefined) {
|
|
405
|
-
config.future.faster = {};
|
|
374
|
+
// Resolve webpack config: true => {}, false => undefined (Rspack)
|
|
375
|
+
const webpack = config.webpack;
|
|
376
|
+
if (webpack === true) {
|
|
377
|
+
config.webpack = {};
|
|
406
378
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
for (const key of fasterKeys) {
|
|
410
|
-
if (config.future.faster[key] === undefined) {
|
|
411
|
-
config.future.faster[key] = fasterDefault;
|
|
412
|
-
}
|
|
379
|
+
else if (webpack === false) {
|
|
380
|
+
delete config.webpack;
|
|
413
381
|
}
|
|
414
382
|
}
|
|
415
383
|
// TODO move to @docusaurus/utils-validation
|
|
@@ -15,7 +15,8 @@ const babel_1 = require("@docusaurus/babel");
|
|
|
15
15
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
16
16
|
const uselessBabelConfigMessages = async ({ site }) => {
|
|
17
17
|
const { props: { siteDir, siteConfig }, } = site;
|
|
18
|
-
|
|
18
|
+
// Babel is only used with Webpack
|
|
19
|
+
if (!siteConfig.webpack) {
|
|
19
20
|
const babelConfigFilePath = await (0, babel_1.getCustomBabelConfigFilePath)(siteDir);
|
|
20
21
|
if (babelConfigFilePath) {
|
|
21
22
|
return [
|
|
@@ -28,8 +29,22 @@ const uselessBabelConfigMessages = async ({ site }) => {
|
|
|
28
29
|
}
|
|
29
30
|
return [];
|
|
30
31
|
};
|
|
32
|
+
const webpackDeprecationMessages = async ({ site }) => {
|
|
33
|
+
if (site.props.siteConfig.webpack) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
type: 'warning',
|
|
37
|
+
message: `Your site uses Webpack and Babel through ${logger_1.default.code('siteConfig.webpack')}. This is deprecated: Docusaurus now uses Rspack by default, and Webpack/Babel support will be removed in Docusaurus v5. Please remove ${logger_1.default.code('siteConfig.webpack')} to use Rspack.`,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
};
|
|
31
43
|
async function collectAllSiteMessages(params) {
|
|
32
|
-
const messageCreators = [
|
|
44
|
+
const messageCreators = [
|
|
45
|
+
uselessBabelConfigMessages,
|
|
46
|
+
webpackDeprecationMessages,
|
|
47
|
+
];
|
|
33
48
|
return (await Promise.all(messageCreators.map((createMessages) => createMessages(params)))).flat();
|
|
34
49
|
}
|
|
35
50
|
function printSiteMessages(siteMessages) {
|
package/lib/webpack/base.js
CHANGED
|
@@ -86,7 +86,7 @@ async function createBaseConfig({ props, isServer, minify, configureWebpackUtils
|
|
|
86
86
|
return disabledPersistentCacheValue;
|
|
87
87
|
}
|
|
88
88
|
if (props.currentBundler.name === 'rspack') {
|
|
89
|
-
|
|
89
|
+
const rspackCache = {
|
|
90
90
|
type: 'persistent',
|
|
91
91
|
// Rspack doesn't have "cache.name" like Webpack
|
|
92
92
|
// This is not ideal but work around is to merge name/version
|
|
@@ -94,6 +94,8 @@ async function createBaseConfig({ props, isServer, minify, configureWebpackUtils
|
|
|
94
94
|
version: `${getCacheName()}-${getCacheVersion()}`,
|
|
95
95
|
buildDependencies: getCacheBuildDependencies(),
|
|
96
96
|
};
|
|
97
|
+
// Docusaurus bundler configs are typed with Webpack types
|
|
98
|
+
return rspackCache;
|
|
97
99
|
}
|
|
98
100
|
return {
|
|
99
101
|
type: 'filesystem',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "4.0.0-canary-
|
|
4
|
+
"version": "4.0.0-canary-6909",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,15 +33,17 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
37
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/fs": "4.0.0-canary-
|
|
39
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
40
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
41
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
42
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
43
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
44
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
36
|
+
"@docusaurus/babel": "4.0.0-canary-6909",
|
|
37
|
+
"@docusaurus/bundler": "4.0.0-canary-6909",
|
|
38
|
+
"@docusaurus/fs": "4.0.0-canary-6909",
|
|
39
|
+
"@docusaurus/glob": "4.0.0-canary-6909",
|
|
40
|
+
"@docusaurus/logger": "4.0.0-canary-6909",
|
|
41
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6909",
|
|
42
|
+
"@docusaurus/utils": "4.0.0-canary-6909",
|
|
43
|
+
"@docusaurus/utils-common": "4.0.0-canary-6909",
|
|
44
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6909",
|
|
45
|
+
"@rspack/core": "^2.2.3",
|
|
46
|
+
"@rspack/dev-server": "^2.2.1",
|
|
45
47
|
"boxen": "^9.0.0",
|
|
46
48
|
"cli-table3": "^0.6.5",
|
|
47
49
|
"combine-promises": "^1.2.0",
|
|
@@ -72,8 +74,8 @@
|
|
|
72
74
|
"webpack-merge": "^6.0.1"
|
|
73
75
|
},
|
|
74
76
|
"devDependencies": {
|
|
75
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
76
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
77
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6909",
|
|
78
|
+
"@docusaurus/types": "4.0.0-canary-6909",
|
|
77
79
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
78
80
|
"@types/escape-html": "^1.0.4",
|
|
79
81
|
"@types/history": "^4.7.11",
|
|
@@ -94,5 +96,5 @@
|
|
|
94
96
|
"engines": {
|
|
95
97
|
"node": ">=24.21"
|
|
96
98
|
},
|
|
97
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "5e2a504d84cc304af27b526febd9f9bdb997b290"
|
|
98
100
|
}
|