@docusaurus/core 2.0.0-beta.1b0acc554 → 2.0.0-beta.2
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/lib/.tsbuildinfo +1 -1
- package/lib/client/.tsbuildinfo +1 -1
- package/lib/commands/build.js +5 -5
- package/lib/commands/deploy.js +8 -0
- package/lib/commands/start.js +2 -2
- package/lib/server/configValidation.js +1 -1
- package/lib/server/html-tags/index.d.ts +2 -2
- package/lib/server/html-tags/index.js +1 -1
- package/lib/server/index.js +1 -13
- package/lib/server/plugins/applyRouteTrailingSlash.d.ts +1 -1
- package/lib/server/plugins/index.d.ts +2 -3
- package/lib/server/plugins/index.js +19 -15
- package/lib/server/plugins/init.d.ts +2 -6
- package/lib/server/plugins/pluginIds.d.ts +2 -2
- package/lib/server/themes/alias.d.ts +2 -2
- package/lib/server/themes/alias.js +1 -0
- package/lib/server/themes/index.d.ts +6 -2
- package/lib/server/themes/index.js +15 -3
- package/lib/server/translations/translations.d.ts +4 -5
- package/lib/server/translations/translationsExtractor.d.ts +2 -3
- package/lib/webpack/base.js +18 -8
- package/lib/webpack/utils.d.ts +2 -1
- package/lib/webpack/utils.js +3 -2
- package/package.json +14 -14
|
@@ -4,5 +4,9 @@
|
|
|
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 {
|
|
8
|
-
export
|
|
7
|
+
import { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
+
export declare function loadThemeAliases(themePaths: string[], userThemePaths?: string[]): ThemeAliases;
|
|
9
|
+
export declare function loadPluginsThemeAliases({ siteDir, plugins, }: {
|
|
10
|
+
siteDir: string;
|
|
11
|
+
plugins: LoadedPlugin[];
|
|
12
|
+
}): ThemeAliases;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
10
13
|
const alias_1 = tslib_1.__importDefault(require("./alias"));
|
|
14
|
+
const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
|
|
11
15
|
function buildThemeAliases(themeAliases, aliases = {}) {
|
|
12
16
|
Object.keys(themeAliases).forEach((aliasKey) => {
|
|
13
17
|
if (aliasKey in aliases) {
|
|
@@ -20,8 +24,8 @@ function buildThemeAliases(themeAliases, aliases = {}) {
|
|
|
20
24
|
});
|
|
21
25
|
return aliases;
|
|
22
26
|
}
|
|
23
|
-
function
|
|
24
|
-
let aliases = {};
|
|
27
|
+
function loadThemeAliases(themePaths, userThemePaths = []) {
|
|
28
|
+
let aliases = {}; // TODO refactor, inelegant side-effect
|
|
25
29
|
themePaths.forEach((themePath) => {
|
|
26
30
|
const themeAliases = alias_1.default(themePath, true);
|
|
27
31
|
aliases = { ...aliases, ...buildThemeAliases(themeAliases, aliases) };
|
|
@@ -32,4 +36,12 @@ function loadThemeAlias(themePaths, userThemePaths = []) {
|
|
|
32
36
|
});
|
|
33
37
|
return aliases;
|
|
34
38
|
}
|
|
35
|
-
exports.
|
|
39
|
+
exports.loadThemeAliases = loadThemeAliases;
|
|
40
|
+
function loadPluginsThemeAliases({ siteDir, plugins, }) {
|
|
41
|
+
const pluginThemes = plugins
|
|
42
|
+
.map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
|
|
43
|
+
.filter((x) => Boolean(x));
|
|
44
|
+
const userTheme = path_1.default.resolve(siteDir, constants_1.THEME_PATH);
|
|
45
|
+
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
46
|
+
}
|
|
47
|
+
exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TranslationFileContent, TranslationFile, TranslationMessage } from '@docusaurus/types';
|
|
1
|
+
import { TranslationFileContent, TranslationFile, TranslationMessage, InitializedPlugin } from '@docusaurus/types';
|
|
3
2
|
export declare type WriteTranslationsOptions = {
|
|
4
3
|
override?: boolean;
|
|
5
4
|
messagePrefix?: string;
|
|
@@ -21,15 +20,15 @@ export declare function getCodeTranslationsFilePath(context: TranslationContext)
|
|
|
21
20
|
export declare function readCodeTranslationFileContent(context: TranslationContext): Promise<TranslationFileContent | undefined>;
|
|
22
21
|
export declare function writeCodeTranslations(context: TranslationContext, content: TranslationFileContent, options: WriteTranslationsOptions): Promise<void>;
|
|
23
22
|
export declare function writePluginTranslations({ siteDir, plugin, locale, translationFile, options, }: TranslationContext & {
|
|
24
|
-
plugin:
|
|
23
|
+
plugin: InitializedPlugin;
|
|
25
24
|
translationFile: TranslationFile;
|
|
26
25
|
options?: WriteTranslationsOptions;
|
|
27
26
|
}): Promise<void>;
|
|
28
27
|
export declare function localizePluginTranslationFile({ siteDir, plugin, locale, translationFile, }: TranslationContext & {
|
|
29
|
-
plugin:
|
|
28
|
+
plugin: InitializedPlugin;
|
|
30
29
|
translationFile: TranslationFile;
|
|
31
30
|
}): Promise<TranslationFile>;
|
|
32
|
-
export declare function getPluginsDefaultCodeTranslationMessages(plugins:
|
|
31
|
+
export declare function getPluginsDefaultCodeTranslationMessages(plugins: InitializedPlugin[]): Promise<Record<string, string>>;
|
|
33
32
|
export declare function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }: {
|
|
34
33
|
extractedCodeTranslations: Record<string, TranslationMessage>;
|
|
35
34
|
defaultCodeMessages: Record<string, string>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TransformOptions } from '@babel/core';
|
|
2
|
-
import { TranslationFileContent, TranslationMessage } from '@docusaurus/types';
|
|
3
|
-
import { InitPlugin } from '../plugins/init';
|
|
2
|
+
import { InitializedPlugin, TranslationFileContent, TranslationMessage } from '@docusaurus/types';
|
|
4
3
|
export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
|
|
5
|
-
export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins:
|
|
4
|
+
export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitializedPlugin[], babelOptions: TransformOptions): Promise<TranslationFileContent>;
|
|
6
5
|
declare type SourceCodeFileTranslations = {
|
|
7
6
|
sourceCodeFilePath: string;
|
|
8
7
|
translations: Record<string, TranslationMessage>;
|
package/lib/webpack/base.js
CHANGED
|
@@ -14,6 +14,8 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
16
|
const sharedModuleAliases_1 = tslib_1.__importDefault(require("./sharedModuleAliases"));
|
|
17
|
+
const themes_1 = require("../server/themes");
|
|
18
|
+
const utils_2 = require("@docusaurus/utils");
|
|
17
19
|
const CSS_REGEX = /\.css$/;
|
|
18
20
|
const CSS_MODULE_REGEX = /\.module\.css$/;
|
|
19
21
|
exports.clientDir = path_1.default.join(__dirname, '..', 'client');
|
|
@@ -48,7 +50,7 @@ function getDocusaurusAliases() {
|
|
|
48
50
|
exports.getDocusaurusAliases = getDocusaurusAliases;
|
|
49
51
|
function createBaseConfig(props, isServer, minify = true) {
|
|
50
52
|
var _a;
|
|
51
|
-
const { outDir, siteDir, siteConfig, baseUrl, generatedFilesDir, routesPaths, siteMetadata, } = props;
|
|
53
|
+
const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
|
|
52
54
|
const totalPages = routesPaths.length;
|
|
53
55
|
const isProd = process.env.NODE_ENV === 'production';
|
|
54
56
|
const minimizeEnabled = minify && isProd && !isServer;
|
|
@@ -56,24 +58,31 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
56
58
|
const fileLoaderUtils = utils_1.getFileLoaderUtils();
|
|
57
59
|
const name = isServer ? 'server' : 'client';
|
|
58
60
|
const mode = isProd ? 'production' : 'development';
|
|
61
|
+
const themeAliases = themes_1.loadPluginsThemeAliases({ siteDir, plugins });
|
|
59
62
|
return {
|
|
60
63
|
mode,
|
|
61
64
|
name,
|
|
62
65
|
cache: {
|
|
63
|
-
|
|
64
|
-
// maybe expose an official api, once this is solved? https://github.com/webpack/webpack/issues/13034
|
|
65
|
-
type: process.env.DOCUSAURUS_WEBPACK_CACHE_TYPE ||
|
|
66
|
-
'filesystem',
|
|
66
|
+
type: 'filesystem',
|
|
67
67
|
// Can we share the same cache across locales?
|
|
68
68
|
// Exploring that question at https://github.com/webpack/webpack/issues/13034
|
|
69
69
|
// name: `${name}-${mode}`,
|
|
70
70
|
name: `${name}-${mode}-${props.i18n.currentLocale}`,
|
|
71
|
-
version
|
|
71
|
+
// When version string changes, cache is evicted
|
|
72
|
+
version: [
|
|
73
|
+
siteMetadata.docusaurusVersion,
|
|
74
|
+
// Webpack does not evict the cache correctly on alias/swizzle change, so we force eviction.
|
|
75
|
+
// See https://github.com/webpack/webpack/issues/13627
|
|
76
|
+
utils_2.md5Hash(JSON.stringify(themeAliases)),
|
|
77
|
+
].join('-'),
|
|
78
|
+
// When one of those modules/dependencies change (including transitive deps), cache is invalidated
|
|
72
79
|
buildDependencies: {
|
|
73
|
-
// When one of dependencies change, cache is invalidated
|
|
74
80
|
config: [
|
|
75
81
|
__filename,
|
|
76
82
|
path_1.default.join(__dirname, isServer ? 'server.js' : 'client.js'),
|
|
83
|
+
// Docusaurus config changes can affect MDX/JSX compilation, so we'd rather evict the cache.
|
|
84
|
+
// See https://github.com/questdb/questdb.io/issues/493
|
|
85
|
+
siteConfigPath,
|
|
77
86
|
],
|
|
78
87
|
},
|
|
79
88
|
},
|
|
@@ -111,6 +120,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
111
120
|
// so we use fine-grained aliases instead
|
|
112
121
|
// '@docusaurus': path.resolve(__dirname, '../client/exports'),
|
|
113
122
|
...getDocusaurusAliases(),
|
|
123
|
+
...themeAliases,
|
|
114
124
|
},
|
|
115
125
|
// This allows you to set a fallback for where Webpack should look for modules.
|
|
116
126
|
// We want `@docusaurus/core` own dependencies/`node_modules` to "win" if there is conflict
|
|
@@ -192,7 +202,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
192
202
|
modules: {
|
|
193
203
|
localIdentName: isProd
|
|
194
204
|
? `[local]_[contenthash:base64:4]`
|
|
195
|
-
: `[local]_[path]`,
|
|
205
|
+
: `[local]_[path][name]`,
|
|
196
206
|
exportOnlyLocals: isServer,
|
|
197
207
|
},
|
|
198
208
|
importLoaders: 1,
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -26,9 +26,10 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
26
26
|
* @param config initial webpack config
|
|
27
27
|
* @param isServer indicates if this is a server webpack configuration
|
|
28
28
|
* @param jsLoader custom js loader config
|
|
29
|
+
* @param content content loaded by the plugin
|
|
29
30
|
* @returns final/ modified webpack config
|
|
30
31
|
*/
|
|
31
|
-
export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader
|
|
32
|
+
export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
32
33
|
export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
|
|
33
34
|
export declare function compile(config: Configuration[]): Promise<void>;
|
|
34
35
|
declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
|
package/lib/webpack/utils.js
CHANGED
|
@@ -133,9 +133,10 @@ function getCacheLoaderDeprecated() {
|
|
|
133
133
|
* @param config initial webpack config
|
|
134
134
|
* @param isServer indicates if this is a server webpack configuration
|
|
135
135
|
* @param jsLoader custom js loader config
|
|
136
|
+
* @param content content loaded by the plugin
|
|
136
137
|
* @returns final/ modified webpack config
|
|
137
138
|
*/
|
|
138
|
-
function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader) {
|
|
139
|
+
function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, content) {
|
|
139
140
|
// Export some utility functions
|
|
140
141
|
const utils = {
|
|
141
142
|
getStyleLoaders,
|
|
@@ -144,7 +145,7 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader) {
|
|
|
144
145
|
getCacheLoader: getCacheLoaderDeprecated,
|
|
145
146
|
};
|
|
146
147
|
if (typeof configureWebpack === 'function') {
|
|
147
|
-
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils);
|
|
148
|
+
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content);
|
|
148
149
|
if (res && typeof res === 'object') {
|
|
149
150
|
// @ts-expect-error: annoying error due to enums: https://github.com/survivejs/webpack-merge/issues/179
|
|
150
151
|
const customizeRules = mergeStrategy !== null && mergeStrategy !== void 0 ? mergeStrategy : {};
|
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.2",
|
|
35
35
|
"@types/detect-port": "^1.3.0",
|
|
36
36
|
"@types/nprogress": "^0.2.0",
|
|
37
37
|
"tmp-promise": "^3.0.2"
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"@babel/runtime": "^7.12.5",
|
|
48
48
|
"@babel/runtime-corejs3": "^7.12.13",
|
|
49
49
|
"@babel/traverse": "^7.12.13",
|
|
50
|
-
"@docusaurus/cssnano-preset": "2.0.0-beta.
|
|
50
|
+
"@docusaurus/cssnano-preset": "2.0.0-beta.2",
|
|
51
51
|
"@docusaurus/react-loadable": "5.5.0",
|
|
52
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
53
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
54
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
55
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
52
|
+
"@docusaurus/types": "2.0.0-beta.2",
|
|
53
|
+
"@docusaurus/utils": "2.0.0-beta.2",
|
|
54
|
+
"@docusaurus/utils-common": "2.0.0-beta.2",
|
|
55
|
+
"@docusaurus/utils-validation": "2.0.0-beta.2",
|
|
56
56
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
57
57
|
"@svgr/webpack": "^5.5.0",
|
|
58
58
|
"autoprefixer": "^10.2.5",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"chokidar": "^3.5.1",
|
|
64
64
|
"clean-css": "^5.1.2",
|
|
65
65
|
"commander": "^5.1.0",
|
|
66
|
-
"copy-webpack-plugin": "^
|
|
66
|
+
"copy-webpack-plugin": "^9.0.0",
|
|
67
67
|
"core-js": "^3.9.1",
|
|
68
68
|
"css-loader": "^5.1.1",
|
|
69
|
-
"css-minimizer-webpack-plugin": "^
|
|
69
|
+
"css-minimizer-webpack-plugin": "^3.0.1",
|
|
70
70
|
"cssnano": "^5.0.4",
|
|
71
71
|
"del": "^6.0.0",
|
|
72
72
|
"detect-port": "^1.3.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"globby": "^11.0.2",
|
|
80
80
|
"html-minifier-terser": "^5.1.1",
|
|
81
81
|
"html-tags": "^3.1.0",
|
|
82
|
-
"html-webpack-plugin": "^5.3.
|
|
82
|
+
"html-webpack-plugin": "^5.3.2",
|
|
83
83
|
"import-fresh": "^3.3.0",
|
|
84
84
|
"is-root": "^2.1.0",
|
|
85
85
|
"leven": "^3.1.0",
|
|
@@ -105,15 +105,15 @@
|
|
|
105
105
|
"shelljs": "^0.8.4",
|
|
106
106
|
"std-env": "^2.2.1",
|
|
107
107
|
"strip-ansi": "^6.0.0",
|
|
108
|
-
"terser-webpack-plugin": "^5.1.
|
|
108
|
+
"terser-webpack-plugin": "^5.1.3",
|
|
109
109
|
"tslib": "^2.2.0",
|
|
110
110
|
"update-notifier": "^5.1.0",
|
|
111
111
|
"url-loader": "^4.1.1",
|
|
112
112
|
"wait-on": "^5.3.0",
|
|
113
|
-
"webpack": "^5.
|
|
113
|
+
"webpack": "^5.40.0",
|
|
114
114
|
"webpack-bundle-analyzer": "^4.4.2",
|
|
115
115
|
"webpack-dev-server": "^3.11.2",
|
|
116
|
-
"webpack-merge": "^5.
|
|
116
|
+
"webpack-merge": "^5.8.0",
|
|
117
117
|
"webpackbar": "^5.0.0-3"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"engines": {
|
|
124
124
|
"node": ">=12.13.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "883f07fddffaf1657407c8e202e370cc436e25f7"
|
|
127
127
|
}
|