@docusaurus/core 0.0.0-6102 → 0.0.0-6105

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.
Files changed (3) hide show
  1. package/lib/ssg.d.ts +4 -0
  2. package/lib/ssg.js +57 -5
  3. package/package.json +12 -12
package/lib/ssg.d.ts CHANGED
@@ -23,6 +23,10 @@ export type SSGParams = {
23
23
  export declare function loadAppRenderer({ serverBundlePath, }: {
24
24
  serverBundlePath: string;
25
25
  }): Promise<AppRenderer>;
26
+ export declare function printSSGWarnings(results: {
27
+ pathname: string;
28
+ warnings: string[];
29
+ }[]): void;
26
30
  export declare function generateStaticFiles({ pathnames, renderer, params, htmlMinifier, }: {
27
31
  pathnames: string[];
28
32
  renderer: AppRenderer;
package/lib/ssg.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadAppRenderer = loadAppRenderer;
10
+ exports.printSSGWarnings = printSSGWarnings;
10
11
  exports.generateStaticFiles = generateStaticFiles;
11
12
  exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
12
13
  const tslib_1 = require("tslib");
@@ -66,6 +67,42 @@ function pathnameToFilename({ pathname, trailingSlash, }) {
66
67
  }
67
68
  return `${outputFileName}.html`;
68
69
  }
70
+ function printSSGWarnings(results) {
71
+ // Escape hatch because SWC is quite aggressive to report errors
72
+ // See https://github.com/facebook/docusaurus/pull/10554
73
+ // See https://github.com/swc-project/swc/discussions/9616#discussioncomment-10846201
74
+ if (process.env.DOCUSAURUS_IGNORE_SSG_WARNINGS === 'true') {
75
+ return;
76
+ }
77
+ const ignoredWarnings = [
78
+ // TODO React/Docusaurus emit NULL chars, and minifier detects it
79
+ // see https://github.com/facebook/docusaurus/issues/9985
80
+ 'Unexpected null character',
81
+ ];
82
+ const keepWarning = (warning) => {
83
+ return !ignoredWarnings.some((iw) => warning.includes(iw));
84
+ };
85
+ const resultsWithWarnings = results
86
+ .map((result) => {
87
+ return {
88
+ ...result,
89
+ warnings: result.warnings.filter(keepWarning),
90
+ };
91
+ })
92
+ .filter((result) => result.warnings.length > 0);
93
+ if (resultsWithWarnings.length) {
94
+ const message = `Docusaurus static site generation process emitted warnings for ${resultsWithWarnings.length} path${resultsWithWarnings.length ? 's' : ''}
95
+ This is non-critical and can be disabled with DOCUSAURUS_IGNORE_SSG_WARNINGS=true
96
+ Troubleshooting guide: https://github.com/facebook/docusaurus/discussions/10580
97
+
98
+ - ${resultsWithWarnings
99
+ .map((result) => `${logger_1.default.path(result.pathname)}:
100
+ - ${result.warnings.join('\n - ')}
101
+ `)
102
+ .join('\n- ')}`;
103
+ logger_1.default.warn(message);
104
+ }
105
+ }
69
106
  async function generateStaticFiles({ pathnames, renderer, params, htmlMinifier, }) {
70
107
  // Note that we catch all async errors on purpose
71
108
  // Docusaurus presents all the SSG errors to the user, not just the first one
@@ -74,8 +111,19 @@ async function generateStaticFiles({ pathnames, renderer, params, htmlMinifier,
74
111
  renderer,
75
112
  params,
76
113
  htmlMinifier,
77
- }).then((result) => ({ pathname, result, error: null }), (error) => ({ pathname, result: null, error: error })), { concurrency: Concurrency });
78
- const [allSSGErrors, allSSGSuccesses] = lodash_1.default.partition(results, (r) => !!r.error);
114
+ }).then((result) => ({
115
+ pathname,
116
+ result,
117
+ error: null,
118
+ warnings: result.warnings,
119
+ }), (error) => ({
120
+ pathname,
121
+ result: null,
122
+ error: error,
123
+ warnings: [],
124
+ })), { concurrency: Concurrency });
125
+ printSSGWarnings(results);
126
+ const [allSSGErrors, allSSGSuccesses] = lodash_1.default.partition(results, (result) => !!result.error);
79
127
  if (allSSGErrors.length > 0) {
80
128
  const message = `Docusaurus static site generation failed for ${allSSGErrors.length} path${allSSGErrors.length ? 's' : ''}:\n- ${allSSGErrors
81
129
  .map((ssgError) => logger_1.default.path(ssgError.pathname))
@@ -103,13 +151,17 @@ async function generateStaticFile({ pathname, renderer, params, htmlMinifier, })
103
151
  params,
104
152
  result,
105
153
  });
106
- const content = await htmlMinifier.minify(fullPageHtml);
154
+ const minifierResult = await htmlMinifier.minify(fullPageHtml);
107
155
  await writeStaticFile({
108
156
  pathname,
109
- content,
157
+ content: minifierResult.code,
110
158
  params,
111
159
  });
112
- return result;
160
+ return {
161
+ ...result,
162
+ // As of today, only the html minifier can emit SSG warnings
163
+ warnings: minifierResult.warnings,
164
+ };
113
165
  }
114
166
  catch (errorUnknown) {
115
167
  const error = errorUnknown;
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-6102",
4
+ "version": "0.0.0-6105",
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": "0.0.0-6102",
37
- "@docusaurus/bundler": "0.0.0-6102",
38
- "@docusaurus/logger": "0.0.0-6102",
39
- "@docusaurus/mdx-loader": "0.0.0-6102",
40
- "@docusaurus/utils": "0.0.0-6102",
41
- "@docusaurus/utils-common": "0.0.0-6102",
42
- "@docusaurus/utils-validation": "0.0.0-6102",
36
+ "@docusaurus/babel": "0.0.0-6105",
37
+ "@docusaurus/bundler": "0.0.0-6105",
38
+ "@docusaurus/logger": "0.0.0-6105",
39
+ "@docusaurus/mdx-loader": "0.0.0-6105",
40
+ "@docusaurus/utils": "0.0.0-6105",
41
+ "@docusaurus/utils-common": "0.0.0-6105",
42
+ "@docusaurus/utils-validation": "0.0.0-6105",
43
43
  "boxen": "^6.2.1",
44
44
  "chalk": "^4.1.2",
45
45
  "chokidar": "^3.5.3",
@@ -68,7 +68,7 @@
68
68
  "react-router-dom": "^5.3.4",
69
69
  "rtl-detect": "^1.0.4",
70
70
  "semver": "^7.5.4",
71
- "serve-handler": "npm:@docusaurus/serve-handler@6.2.0",
71
+ "serve-handler": "^6.1.6",
72
72
  "shelljs": "^0.8.5",
73
73
  "tslib": "^2.6.0",
74
74
  "update-notifier": "^6.0.2",
@@ -78,8 +78,8 @@
78
78
  "webpack-merge": "^6.0.1"
79
79
  },
80
80
  "devDependencies": {
81
- "@docusaurus/module-type-aliases": "0.0.0-6102",
82
- "@docusaurus/types": "0.0.0-6102",
81
+ "@docusaurus/module-type-aliases": "0.0.0-6105",
82
+ "@docusaurus/types": "0.0.0-6105",
83
83
  "@total-typescript/shoehorn": "^0.1.2",
84
84
  "@types/detect-port": "^1.3.3",
85
85
  "@types/react-dom": "^18.2.7",
@@ -100,5 +100,5 @@
100
100
  "engines": {
101
101
  "node": ">=18.0"
102
102
  },
103
- "gitHead": "6544279597d408981d878dbfe723411787c5525b"
103
+ "gitHead": "b46becffec32979bc2fcdb4d1be8e77100c06a21"
104
104
  }