@docusaurus/core 0.0.0-5939 → 0.0.0-5940
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.
|
@@ -45,5 +45,6 @@ type GenerateRouteFilesParams = {
|
|
|
45
45
|
routes: PluginRouteConfig[];
|
|
46
46
|
baseUrl: string;
|
|
47
47
|
};
|
|
48
|
+
export declare function generateRoutePropFilename(route: RouteConfig): string;
|
|
48
49
|
export declare function generateRouteFiles({ generatedFilesDir, routes: initialRoutes, }: GenerateRouteFilesParams): Promise<void>;
|
|
49
50
|
export {};
|
|
@@ -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.generateRouteFiles = exports.generateRoutesCode = exports.genChunkName = void 0;
|
|
9
|
+
exports.generateRouteFiles = exports.generateRoutePropFilename = exports.generateRoutesCode = exports.genChunkName = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const querystring_1 = tslib_1.__importDefault(require("querystring"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -180,12 +180,26 @@ ${Object.entries(registry)
|
|
|
180
180
|
`);
|
|
181
181
|
const genRoutesChunkNames = ({ generatedFilesDir, routesChunkNames, }) => (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
|
|
182
182
|
const genRoutes = ({ generatedFilesDir, routesConfig, }) => (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
|
|
183
|
+
// The generated filename per route must be unique to avoid conflicts
|
|
184
|
+
// See also https://github.com/facebook/docusaurus/issues/10125
|
|
185
|
+
function generateRoutePropFilename(route) {
|
|
186
|
+
// TODO if possible, we could try to shorten the filename by removing
|
|
187
|
+
// the plugin routeBasePath prefix from the name
|
|
188
|
+
return `${(0, utils_1.docuHash)(route.path,
|
|
189
|
+
// Note: using hash(route.path + route.component) is not technically
|
|
190
|
+
// as robust as hashing the entire prop content object.
|
|
191
|
+
// But it's faster and should be good enough considering it's very unlikely
|
|
192
|
+
// anyone would have 2 routes on the same path also rendering the exact
|
|
193
|
+
// same component.
|
|
194
|
+
{ hashExtra: route.component })}.json`;
|
|
195
|
+
}
|
|
196
|
+
exports.generateRoutePropFilename = generateRoutePropFilename;
|
|
183
197
|
async function generateRoutePropModule({ generatedFilesDir, route, plugin, }) {
|
|
184
198
|
ensureNoPropsConflict(route);
|
|
185
199
|
const moduleContent = JSON.stringify(route.props);
|
|
186
200
|
// TODO we should aim to reduce this path length
|
|
187
201
|
// This adds bytes to the global module registry
|
|
188
|
-
const relativePath = path_1.default.posix.join(plugin.name, plugin.id, 'p',
|
|
202
|
+
const relativePath = path_1.default.posix.join(plugin.name, plugin.id, 'p', generateRoutePropFilename(route));
|
|
189
203
|
const modulePath = path_1.default.posix.join(generatedFilesDir, relativePath);
|
|
190
204
|
const aliasedPath = path_1.default.posix.join('@generated', relativePath);
|
|
191
205
|
await (0, utils_1.generate)(generatedFilesDir, modulePath, moduleContent);
|
|
@@ -201,14 +215,14 @@ function ensureNoPropsConflict(route) {
|
|
|
201
215
|
}
|
|
202
216
|
}
|
|
203
217
|
async function preprocessRouteProps({ generatedFilesDir, route, plugin, }) {
|
|
204
|
-
const
|
|
218
|
+
const getPropsModulePathPromise = () => route.props
|
|
205
219
|
? generateRoutePropModule({
|
|
206
220
|
generatedFilesDir,
|
|
207
221
|
route,
|
|
208
222
|
plugin,
|
|
209
223
|
})
|
|
210
224
|
: undefined;
|
|
211
|
-
const
|
|
225
|
+
const getSubRoutesPromise = () => route.routes
|
|
212
226
|
? Promise.all(route.routes.map((subRoute) => {
|
|
213
227
|
return preprocessRouteProps({
|
|
214
228
|
generatedFilesDir,
|
|
@@ -218,8 +232,8 @@ async function preprocessRouteProps({ generatedFilesDir, route, plugin, }) {
|
|
|
218
232
|
}))
|
|
219
233
|
: undefined;
|
|
220
234
|
const [propsModulePath, subRoutes] = await Promise.all([
|
|
221
|
-
|
|
222
|
-
|
|
235
|
+
getPropsModulePathPromise(),
|
|
236
|
+
getSubRoutesPromise(),
|
|
223
237
|
]);
|
|
224
238
|
const newRoute = {
|
|
225
239
|
...route,
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5940",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"@babel/runtime": "^7.22.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
45
45
|
"@babel/traverse": "^7.22.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
49
|
-
"@docusaurus/utils": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5940",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5940",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5940",
|
|
49
|
+
"@docusaurus/utils": "0.0.0-5940",
|
|
50
|
+
"@docusaurus/utils-common": "0.0.0-5940",
|
|
51
|
+
"@docusaurus/utils-validation": "0.0.0-5940",
|
|
52
52
|
"autoprefixer": "^10.4.14",
|
|
53
53
|
"babel-loader": "^9.1.3",
|
|
54
54
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
"webpackbar": "^5.0.2"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
107
|
-
"@docusaurus/types": "0.0.0-
|
|
106
|
+
"@docusaurus/module-type-aliases": "0.0.0-5940",
|
|
107
|
+
"@docusaurus/types": "0.0.0-5940",
|
|
108
108
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
109
109
|
"@types/detect-port": "^1.3.3",
|
|
110
110
|
"@types/react-dom": "^18.2.7",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"engines": {
|
|
125
125
|
"node": ">=18.0"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "4cb178f11c58280eef3865a03ffd8acf7b8bd5c7"
|
|
128
128
|
}
|