2024-03-13 20:39:45 +00:00
|
|
|
import { verifyTranslationImports } from "./services/I18NextService";
|
|
|
|
import { verifyDateFnsImports } from "@utils/app/setup-date-fns";
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
import { verifyHighlighjsImports } from "./lazy-highlightjs";
|
2024-03-13 20:39:45 +00:00
|
|
|
|
|
|
|
export class ImportReport {
|
|
|
|
error: Array<{ id: string; error: Error | string | undefined }> = [];
|
|
|
|
success: string[] = [];
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
message?: string;
|
2024-03-13 20:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type ImportReportCollection = {
|
|
|
|
translation?: ImportReport;
|
|
|
|
"date-fns"?: ImportReport;
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
"highlight.js"?: ImportReport;
|
2024-03-13 20:39:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function collect(
|
|
|
|
verbose: boolean,
|
|
|
|
kind: keyof ImportReportCollection,
|
|
|
|
collection: ImportReportCollection,
|
|
|
|
report: ImportReport,
|
|
|
|
) {
|
|
|
|
collection[kind] = report;
|
|
|
|
if (verbose) {
|
|
|
|
for (const { id, error } of report.error) {
|
|
|
|
console.warn(`${kind} "${id}" failed: ${error}`);
|
|
|
|
}
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
const message = report.message ? ` (${report.message})` : "";
|
2024-03-13 20:39:45 +00:00
|
|
|
const good = report.success.length;
|
|
|
|
const bad = report.error.length;
|
|
|
|
if (bad) {
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
console.error(
|
|
|
|
`${bad} out of ${bad + good} ${kind} imports failed.` + message,
|
|
|
|
);
|
2024-03-13 20:39:45 +00:00
|
|
|
} else {
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
console.log(`${good} ${kind} imports verified.` + message);
|
2024-03-13 20:39:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This verifies that the parameters used for parameterized imports are
|
|
|
|
// correct, that the respective chunks are reachable or bundled, and that the
|
|
|
|
// returned objects match expectations.
|
|
|
|
export async function verifyDynamicImports(
|
|
|
|
verbose: boolean,
|
|
|
|
): Promise<ImportReportCollection> {
|
|
|
|
const collection: ImportReportCollection = {};
|
|
|
|
await verifyTranslationImports().then(report =>
|
|
|
|
collect(verbose, "translation", collection, report),
|
|
|
|
);
|
|
|
|
await verifyDateFnsImports().then(report =>
|
|
|
|
collect(verbose, "date-fns", collection, report),
|
|
|
|
);
|
Lazy loading less common languages for syntax highlighting (#2388)
* Use fewer syntax highlighter languages.
Reduces client.js size by about 250kB (800kB uncompressed)
Common languages:
bash, c, cpp, csharp, css, diff, go, graphql, ini, java, javascript,
json, kotlin, less, lua, makefile, markdown, objectivec, perl,
php-template, php, plaintext, python-repl, python, r, ruby, rust, scss,
shell, sql, swift, typescript, vbnet, wasm, xml, yaml
Additionally enabled languages:
dockerfile, pgsql
* Configurable syntax highlighter languages
Allows to individually enable languages.
* Lazy load syntax highlighter languages
Allows to enable additional languages that will not be autodetected.
* Include highlight.js in dynamic import check
2024-03-14 12:31:07 +00:00
|
|
|
await verifyHighlighjsImports().then(report =>
|
|
|
|
collect(verbose, "highlight.js", collection, report),
|
|
|
|
);
|
2024-03-13 20:39:45 +00:00
|
|
|
return collection;
|
|
|
|
}
|