@docusaurus/core 3.7.0-canary-6261 → 3.7.0-canary-6262

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.
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.start = start;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
+ const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
12
12
  const openBrowser_1 = tslib_1.__importDefault(require("../utils/openBrowser/openBrowser"));
13
13
  const watcher_1 = require("./watcher");
14
14
  const webpack_1 = require("./webpack");
15
15
  const utils_1 = require("./utils");
16
- async function start(siteDirParam = '.', cliOptions = {}) {
16
+ async function doStart(siteDirParam = '.', cliOptions = {}) {
17
17
  logger_1.default.info('Starting the development server...');
18
18
  // Temporary workaround to unlock the ability to translate the site config
19
19
  // We'll remove it if a better official API can be designed
@@ -44,3 +44,6 @@ async function start(siteDirParam = '.', cliOptions = {}) {
44
44
  await (0, openBrowser_1.default)(reloadableSite.getOpenUrl());
45
45
  }
46
46
  }
47
+ async function start(siteDirParam = '.', cliOptions = {}) {
48
+ return logger_1.PerfLogger.async('CLI start', () => doStart(siteDirParam, cliOptions));
49
+ }
@@ -16,6 +16,7 @@ const babel_1 = require("@docusaurus/babel");
16
16
  const bundler_1 = require("@docusaurus/bundler");
17
17
  const utils_1 = require("@docusaurus/utils");
18
18
  const aliases_1 = require("./aliases");
19
+ const BundlerCPUProfilerPlugin_1 = require("./plugins/BundlerCPUProfilerPlugin");
19
20
  const CSS_REGEX = /\.css$/i;
20
21
  const CSS_MODULE_REGEX = /\.module\.css$/i;
21
22
  exports.clientDir = path_1.default.join(__dirname, '..', 'client');
@@ -283,6 +284,8 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
283
284
  // for more reasoning
284
285
  ignoreOrder: true,
285
286
  }),
286
- ],
287
+ process.env.DOCUSAURUS_BUNDLER_CPU_PROFILE &&
288
+ new BundlerCPUProfilerPlugin_1.BundlerCPUProfilerPlugin(),
289
+ ].filter(Boolean),
287
290
  };
288
291
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { Compiler } from 'webpack';
8
+ export declare class BundlerCPUProfilerPlugin {
9
+ output: string;
10
+ constructor(output?: string);
11
+ apply(compiler: Compiler): void;
12
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BundlerCPUProfilerPlugin = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const node_inspector_1 = tslib_1.__importDefault(require("node:inspector"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ // Bundle CPU profiling plugin, contributed by the Rspack team
14
+ // Can be opened in https://www.speedscope.app/
15
+ // See also https://github.com/jerrykingxyz/docusaurus/pull/1
16
+ // See also https://github.com/facebook/docusaurus/pull/10985
17
+ class BundlerCPUProfilerPlugin {
18
+ constructor(output) {
19
+ this.output = output ?? './bundler-cpu-profile.json';
20
+ }
21
+ apply(compiler) {
22
+ const session = new node_inspector_1.default.Session();
23
+ session.connect();
24
+ session.post('Profiler.enable');
25
+ session.post('Profiler.start');
26
+ // In dev/watch mode, we restart the profiler before each compilation
27
+ compiler.hooks.watchRun.tapPromise(BundlerCPUProfilerPlugin.name, async () => {
28
+ session.post('Profiler.start');
29
+ });
30
+ compiler.hooks.done.tapPromise(BundlerCPUProfilerPlugin.name, async () => {
31
+ session.post('Profiler.stop', (error, param) => {
32
+ if (error) {
33
+ console.error('Failed to generate JS CPU profile:', error);
34
+ return;
35
+ }
36
+ fs_extra_1.default.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
37
+ });
38
+ });
39
+ }
40
+ }
41
+ exports.BundlerCPUProfilerPlugin = BundlerCPUProfilerPlugin;
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": "3.7.0-canary-6261",
4
+ "version": "3.7.0-canary-6262",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,13 +33,13 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "3.7.0-canary-6261",
37
- "@docusaurus/bundler": "3.7.0-canary-6261",
38
- "@docusaurus/logger": "3.7.0-canary-6261",
39
- "@docusaurus/mdx-loader": "3.7.0-canary-6261",
40
- "@docusaurus/utils": "3.7.0-canary-6261",
41
- "@docusaurus/utils-common": "3.7.0-canary-6261",
42
- "@docusaurus/utils-validation": "3.7.0-canary-6261",
36
+ "@docusaurus/babel": "3.7.0-canary-6262",
37
+ "@docusaurus/bundler": "3.7.0-canary-6262",
38
+ "@docusaurus/logger": "3.7.0-canary-6262",
39
+ "@docusaurus/mdx-loader": "3.7.0-canary-6262",
40
+ "@docusaurus/utils": "3.7.0-canary-6262",
41
+ "@docusaurus/utils-common": "3.7.0-canary-6262",
42
+ "@docusaurus/utils-validation": "3.7.0-canary-6262",
43
43
  "boxen": "^6.2.1",
44
44
  "chalk": "^4.1.2",
45
45
  "chokidar": "^3.5.3",
@@ -78,8 +78,8 @@
78
78
  "webpack-merge": "^6.0.1"
79
79
  },
80
80
  "devDependencies": {
81
- "@docusaurus/module-type-aliases": "3.7.0-canary-6261",
82
- "@docusaurus/types": "3.7.0-canary-6261",
81
+ "@docusaurus/module-type-aliases": "3.7.0-canary-6262",
82
+ "@docusaurus/types": "3.7.0-canary-6262",
83
83
  "@total-typescript/shoehorn": "^0.1.2",
84
84
  "@types/detect-port": "^1.3.3",
85
85
  "@types/react-dom": "^18.2.7",
@@ -99,5 +99,5 @@
99
99
  "engines": {
100
100
  "node": ">=18.0"
101
101
  },
102
- "gitHead": "a93b982c4a8fd345bae11d2d896c5381af5af2b0"
102
+ "gitHead": "dece03f917b38ae183df551a66752d6d482d85a2"
103
103
  }