|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -import addonVerify from './addon-verify/index.mjs'; |
4 | | -import apiLinks from './api-links/index.mjs'; |
5 | | -import ast from './ast/index.mjs'; |
6 | | -import astJs from './ast-js/index.mjs'; |
7 | | -import jsonSimple from './json-simple/index.mjs'; |
8 | | -import jsxAst from './jsx-ast/index.mjs'; |
9 | | -import legacyHtml from './legacy-html/index.mjs'; |
10 | | -import legacyHtmlAll from './legacy-html-all/index.mjs'; |
11 | | -import legacyJson from './legacy-json/index.mjs'; |
12 | | -import legacyJsonAll from './legacy-json-all/index.mjs'; |
13 | | -import llmsTxt from './llms-txt/index.mjs'; |
14 | | -import manPage from './man-page/index.mjs'; |
15 | | -import metadata from './metadata/index.mjs'; |
16 | | -import oramaDb from './orama-db/index.mjs'; |
17 | | -import sitemap from './sitemap/index.mjs'; |
18 | | -import web from './web/index.mjs'; |
| 3 | +/** |
| 4 | + * Wraps a dynamic import into a lazy loader that resolves to the default export. |
| 5 | + * |
| 6 | + * @template T |
| 7 | + * @param {() => Promise<{default: T}>} loader |
| 8 | + * @returns {() => Promise<T>} |
| 9 | + */ |
| 10 | +const lazyDefault = loader => () => loader().then(m => m.default); |
19 | 11 |
|
20 | 12 | export const publicGenerators = { |
21 | | - 'json-simple': jsonSimple, |
22 | | - 'legacy-html': legacyHtml, |
23 | | - 'legacy-html-all': legacyHtmlAll, |
24 | | - 'man-page': manPage, |
25 | | - 'legacy-json': legacyJson, |
26 | | - 'legacy-json-all': legacyJsonAll, |
27 | | - 'addon-verify': addonVerify, |
28 | | - 'api-links': apiLinks, |
29 | | - 'orama-db': oramaDb, |
30 | | - 'llms-txt': llmsTxt, |
31 | | - sitemap, |
32 | | - web, |
| 13 | + 'json-simple': lazyDefault(() => import('./json-simple/index.mjs')), |
| 14 | + 'legacy-html': lazyDefault(() => import('./legacy-html/index.mjs')), |
| 15 | + 'legacy-html-all': lazyDefault(() => import('./legacy-html-all/index.mjs')), |
| 16 | + 'man-page': lazyDefault(() => import('./man-page/index.mjs')), |
| 17 | + 'legacy-json': lazyDefault(() => import('./legacy-json/index.mjs')), |
| 18 | + 'legacy-json-all': lazyDefault(() => import('./legacy-json-all/index.mjs')), |
| 19 | + 'addon-verify': lazyDefault(() => import('./addon-verify/index.mjs')), |
| 20 | + 'api-links': lazyDefault(() => import('./api-links/index.mjs')), |
| 21 | + 'orama-db': lazyDefault(() => import('./orama-db/index.mjs')), |
| 22 | + 'llms-txt': lazyDefault(() => import('./llms-txt/index.mjs')), |
| 23 | + sitemap: lazyDefault(() => import('./sitemap/index.mjs')), |
| 24 | + web: lazyDefault(() => import('./web/index.mjs')), |
33 | 25 | }; |
34 | 26 |
|
35 | 27 | // These ones are special since they don't produce standard output, |
36 | 28 | // and hence, we don't expose them to the CLI. |
37 | 29 | const internalGenerators = { |
38 | | - ast, |
39 | | - metadata, |
40 | | - 'jsx-ast': jsxAst, |
41 | | - 'ast-js': astJs, |
| 30 | + ast: lazyDefault(() => import('./ast/index.mjs')), |
| 31 | + metadata: lazyDefault(() => import('./metadata/index.mjs')), |
| 32 | + 'jsx-ast': lazyDefault(() => import('./jsx-ast/index.mjs')), |
| 33 | + 'ast-js': lazyDefault(() => import('./ast-js/index.mjs')), |
42 | 34 | }; |
43 | 35 |
|
44 | 36 | export const allGenerators = { |
|
0 commit comments