@modern-js/app-tools 2.58.1 → 2.58.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +1 -1
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
- package/dist/cjs/builder/builder-webpack/index.js +1 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
- package/dist/cjs/builder/generator/index.js +2 -2
- package/dist/cjs/builder/index.js +2 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +8 -13
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -5
- package/dist/cjs/commands/build.js +21 -2
- package/dist/cjs/commands/dev.js +15 -5
- package/dist/cjs/commands/index.js +9 -9
- package/dist/cjs/commands/serve.js +4 -3
- package/dist/cjs/config/initialize/inits.js +4 -4
- package/dist/cjs/config/legacy/index.js +3 -3
- package/dist/cjs/esm/esbuild-loader.mjs +20 -0
- package/dist/cjs/esm/register-esm.mjs +66 -0
- package/dist/cjs/esm/ts-node-loader.mjs +21 -0
- package/dist/cjs/esm/utils.mjs +43 -0
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/locale/index.js +1 -1
- package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
- package/dist/cjs/plugins/analyze/index.js +9 -9
- package/dist/cjs/plugins/analyze/utils.js +1 -1
- package/dist/cjs/plugins/deploy/dependencies/index.js +2 -1
- package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -2
- package/dist/cjs/plugins/deploy/index.js +2 -2
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
- package/dist/cjs/plugins/deploy/platforms/netlify.js +15 -6
- package/dist/cjs/plugins/deploy/platforms/node.js +14 -5
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +15 -6
- package/dist/cjs/plugins/serverBuild.js +2 -2
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/loadPlugins.js +1 -1
- package/dist/cjs/utils/register.js +50 -23
- package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +1 -1
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +3 -3
- package/dist/types/builder/index.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -1
- package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -1
- package/dist/types/builder/shared/types.d.ts +1 -1
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +3 -3
- package/dist/types/commands/index.d.ts +3 -3
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
- package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
- package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
- package/dist/types/esm/esbuild-loader.d.mts +6 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-node-loader.d.mts +6 -0
- package/dist/types/esm/utils.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/index.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
- package/dist/types/plugins/deploy/utils.d.ts +1 -1
- package/dist/types/plugins/initialize/index.d.ts +1 -1
- package/dist/types/plugins/serverBuild.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +8 -8
- package/dist/types/types/config/output.d.ts +1 -1
- package/dist/types/types/config/tools.d.ts +3 -3
- package/dist/types/types/hooks.d.ts +3 -3
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/legacyConfig/index.d.ts +3 -3
- package/dist/types/types/legacyConfig/tools.d.ts +1 -1
- package/dist/types/utils/createServer.d.ts +1 -1
- package/dist/types/utils/generateWatchFiles.d.ts +1 -1
- package/dist/types/utils/getSelectedEntries.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +3 -3
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/dist/types/utils/register.d.ts +2 -2
- package/dist/types/utils/restart.d.ts +2 -2
- package/lib/types.d.ts +15 -0
- package/package.json +20 -20
- package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
- package/dist/esm/builder/builder-rspack/index.js +0 -34
- package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
- package/dist/esm/builder/builder-webpack/index.js +0 -52
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
- package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
- package/dist/esm/builder/generator/index.js +0 -94
- package/dist/esm/builder/index.js +0 -45
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
- package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
- package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm/builder/shared/index.js +0 -3
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm/builder/shared/types.js +0 -0
- package/dist/esm/commands/build.js +0 -117
- package/dist/esm/commands/deploy.js +0 -48
- package/dist/esm/commands/dev.js +0 -169
- package/dist/esm/commands/index.js +0 -411
- package/dist/esm/commands/inspect.js +0 -28
- package/dist/esm/commands/serve.js +0 -93
- package/dist/esm/config/default.js +0 -190
- package/dist/esm/config/index.js +0 -3
- package/dist/esm/config/initialize/index.js +0 -9
- package/dist/esm/config/initialize/inits.js +0 -85
- package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm/config/legacy/createSourceConfig.js +0 -46
- package/dist/esm/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm/config/legacy/index.js +0 -43
- package/dist/esm/defineConfig.js +0 -16
- package/dist/esm/exports/server.js +0 -4
- package/dist/esm/hooks.js +0 -34
- package/dist/esm/index.js +0 -239
- package/dist/esm/locale/en.js +0 -43
- package/dist/esm/locale/index.js +0 -12
- package/dist/esm/locale/zh.js +0 -43
- package/dist/esm/plugins/analyze/constants.js +0 -14
- package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
- package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm/plugins/analyze/index.js +0 -380
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
- package/dist/esm/plugins/analyze/templates.js +0 -6
- package/dist/esm/plugins/analyze/utils.js +0 -101
- package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
- package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/plugins/deploy/index.js +0 -135
- package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
- package/dist/esm/plugins/deploy/platforms/node.js +0 -133
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
- package/dist/esm/plugins/deploy/utils.js +0 -47
- package/dist/esm/plugins/initialize/index.js +0 -119
- package/dist/esm/plugins/serverBuild.js +0 -87
- package/dist/esm/types/config/deploy.js +0 -0
- package/dist/esm/types/config/dev.js +0 -0
- package/dist/esm/types/config/experiments.js +0 -0
- package/dist/esm/types/config/html.js +0 -0
- package/dist/esm/types/config/index.js +0 -1
- package/dist/esm/types/config/output.js +0 -0
- package/dist/esm/types/config/performance.js +0 -0
- package/dist/esm/types/config/security.js +0 -0
- package/dist/esm/types/config/source.js +0 -0
- package/dist/esm/types/config/testing.js +0 -0
- package/dist/esm/types/config/tools.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/legacyConfig/deploy.js +0 -0
- package/dist/esm/types/legacyConfig/dev.js +0 -0
- package/dist/esm/types/legacyConfig/index.js +0 -0
- package/dist/esm/types/legacyConfig/output.js +0 -0
- package/dist/esm/types/legacyConfig/source.js +0 -0
- package/dist/esm/types/legacyConfig/testing.js +0 -0
- package/dist/esm/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm/utils/config.js +0 -122
- package/dist/esm/utils/createServer.js +0 -58
- package/dist/esm/utils/env.js +0 -16
- package/dist/esm/utils/generateWatchFiles.js +0 -71
- package/dist/esm/utils/getSelectedEntries.js +0 -67
- package/dist/esm/utils/loadPlugins.js +0 -69
- package/dist/esm/utils/printInstructions.js +0 -32
- package/dist/esm/utils/register.js +0 -129
- package/dist/esm/utils/restart.js +0 -67
- package/dist/esm/utils/routes.js +0 -42
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
- package/dist/esm-node/builder/builder-rspack/index.js +0 -12
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
- package/dist/esm-node/builder/builder-webpack/index.js +0 -20
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
- package/dist/esm-node/builder/generator/index.js +0 -37
- package/dist/esm-node/builder/index.js +0 -11
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
- package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm-node/builder/shared/index.js +0 -3
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +0 -55
- package/dist/esm-node/commands/deploy.js +0 -12
- package/dist/esm-node/commands/dev.js +0 -95
- package/dist/esm-node/commands/index.js +0 -92
- package/dist/esm-node/commands/inspect.js +0 -15
- package/dist/esm-node/commands/serve.js +0 -51
- package/dist/esm-node/config/default.js +0 -197
- package/dist/esm-node/config/index.js +0 -3
- package/dist/esm-node/config/initialize/index.js +0 -9
- package/dist/esm-node/config/initialize/inits.js +0 -79
- package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
- package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm-node/config/legacy/index.js +0 -43
- package/dist/esm-node/defineConfig.js +0 -13
- package/dist/esm-node/exports/server.js +0 -4
- package/dist/esm-node/hooks.js +0 -34
- package/dist/esm-node/index.js +0 -124
- package/dist/esm-node/locale/en.js +0 -43
- package/dist/esm-node/locale/index.js +0 -12
- package/dist/esm-node/locale/zh.js +0 -43
- package/dist/esm-node/plugins/analyze/constants.js +0 -14
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm-node/plugins/analyze/index.js +0 -166
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
- package/dist/esm-node/plugins/analyze/templates.js +0 -24
- package/dist/esm-node/plugins/analyze/utils.js +0 -68
- package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/plugins/deploy/index.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/utils.js +0 -44
- package/dist/esm-node/plugins/initialize/index.js +0 -84
- package/dist/esm-node/plugins/serverBuild.js +0 -58
- package/dist/esm-node/types/config/deploy.js +0 -0
- package/dist/esm-node/types/config/dev.js +0 -0
- package/dist/esm-node/types/config/experiments.js +0 -0
- package/dist/esm-node/types/config/html.js +0 -0
- package/dist/esm-node/types/config/index.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -0
- package/dist/esm-node/types/config/performance.js +0 -0
- package/dist/esm-node/types/config/security.js +0 -0
- package/dist/esm-node/types/config/source.js +0 -0
- package/dist/esm-node/types/config/testing.js +0 -0
- package/dist/esm-node/types/config/tools.js +0 -0
- package/dist/esm-node/types/hooks.js +0 -0
- package/dist/esm-node/types/index.js +0 -3
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
- package/dist/esm-node/types/legacyConfig/dev.js +0 -0
- package/dist/esm-node/types/legacyConfig/index.js +0 -0
- package/dist/esm-node/types/legacyConfig/output.js +0 -0
- package/dist/esm-node/types/legacyConfig/source.js +0 -0
- package/dist/esm-node/types/legacyConfig/testing.js +0 -0
- package/dist/esm-node/types/legacyConfig/tools.js +0 -0
- package/dist/esm-node/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +0 -49
- package/dist/esm-node/utils/createServer.js +0 -26
- package/dist/esm-node/utils/env.js +0 -16
- package/dist/esm-node/utils/generateWatchFiles.js +0 -30
- package/dist/esm-node/utils/getSelectedEntries.js +0 -34
- package/dist/esm-node/utils/loadPlugins.js +0 -22
- package/dist/esm-node/utils/printInstructions.js +0 -11
- package/dist/esm-node/utils/register.js +0 -69
- package/dist/esm-node/utils/restart.js +0 -22
- package/dist/esm-node/utils/routes.js +0 -21
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
- /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
- /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,43 +0,0 @@
|
|
1
|
-
import { createToolsConfig } from "./createToolsConfig";
|
2
|
-
import { createSourceConfig } from "./createSourceConfig";
|
3
|
-
import { createOutputConfig } from "./createOutputConfig";
|
4
|
-
import { createHtmlConfig } from "./createHtmlConfig";
|
5
|
-
function transformNormalizedConfig(config) {
|
6
|
-
const html = createHtmlConfig(config);
|
7
|
-
const output = createOutputConfig(config);
|
8
|
-
const source = createSourceConfig(config);
|
9
|
-
const tools = createToolsConfig(config);
|
10
|
-
const { bff, dev, deploy, runtime, runtimeByEntries, server, cliOptions, plugins, testing, autoLoadPlugins } = config;
|
11
|
-
return {
|
12
|
-
source,
|
13
|
-
html,
|
14
|
-
output,
|
15
|
-
tools,
|
16
|
-
bff,
|
17
|
-
dev,
|
18
|
-
deploy,
|
19
|
-
runtime,
|
20
|
-
runtimeByEntries,
|
21
|
-
server,
|
22
|
-
cliOptions,
|
23
|
-
testing,
|
24
|
-
devtools: {},
|
25
|
-
builderPlugins: [],
|
26
|
-
plugins,
|
27
|
-
security: {},
|
28
|
-
_raw: {},
|
29
|
-
experiments: {},
|
30
|
-
environments: {},
|
31
|
-
autoLoadPlugins,
|
32
|
-
performance: {
|
33
|
-
removeMomentLocale: true
|
34
|
-
}
|
35
|
-
};
|
36
|
-
}
|
37
|
-
function checkIsLegacyConfig(config) {
|
38
|
-
return Boolean(config.legacy);
|
39
|
-
}
|
40
|
-
export {
|
41
|
-
checkIsLegacyConfig,
|
42
|
-
transformNormalizedConfig
|
43
|
-
};
|
@@ -1,13 +0,0 @@
|
|
1
|
-
const defineConfig = (config) => config;
|
2
|
-
const defineLegacyConfig = (config) => {
|
3
|
-
var _config_autoLoadPlugins;
|
4
|
-
return {
|
5
|
-
...config,
|
6
|
-
legacy: true,
|
7
|
-
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
8
|
-
};
|
9
|
-
};
|
10
|
-
export {
|
11
|
-
defineConfig,
|
12
|
-
defineLegacyConfig
|
13
|
-
};
|
package/dist/esm-node/hooks.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from "@modern-js/plugin";
|
2
|
-
const hooks = {
|
3
|
-
_internalRuntimePlugins: createAsyncWaterfall(),
|
4
|
-
modifyFileSystemRoutes: createAsyncWaterfall(),
|
5
|
-
modifyServerRoutes: createAsyncWaterfall(),
|
6
|
-
/** add entry point info to entrypoints array */
|
7
|
-
modifyEntrypoints: createAsyncWaterfall(),
|
8
|
-
/** add entry type */
|
9
|
-
checkEntryPoint: createAsyncWaterfall(),
|
10
|
-
generateEntryCode: createAsyncWorkflow(),
|
11
|
-
htmlPartials: createAsyncWaterfall(),
|
12
|
-
beforeGenerateRoutes: createAsyncWaterfall(),
|
13
|
-
addDefineTypes: createAsyncWaterfall(),
|
14
|
-
collectServerPlugins: createAsyncWaterfall(),
|
15
|
-
_internalServerPlugins: createAsyncWaterfall(),
|
16
|
-
beforeDev: createAsyncWorkflow(),
|
17
|
-
afterDev: createAsyncWorkflow(),
|
18
|
-
beforeCreateCompiler: createAsyncWorkflow(),
|
19
|
-
afterCreateCompiler: createAsyncWorkflow(),
|
20
|
-
beforePrintInstructions: createAsyncWaterfall(),
|
21
|
-
beforeBuild: createAsyncWorkflow(),
|
22
|
-
afterBuild: createAsyncWorkflow(),
|
23
|
-
beforeDeploy: createAsyncWorkflow(),
|
24
|
-
deploy: createAsyncWorkflow(),
|
25
|
-
afterDeploy: createAsyncWorkflow(),
|
26
|
-
beforeRestart: createAsyncWorkflow(),
|
27
|
-
registerDev: createParallelWorkflow(),
|
28
|
-
beforeDevTask: createParallelWorkflow(),
|
29
|
-
registerBuildPlatform: createParallelWorkflow(),
|
30
|
-
beforeBuildPlatform: createParallelWorkflow()
|
31
|
-
};
|
32
|
-
export {
|
33
|
-
hooks
|
34
|
-
};
|
package/dist/esm-node/index.js
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { lintPlugin } from "@modern-js/plugin-lint";
|
3
|
-
import { cleanRequireCache, emptyDir, getCommand, getArgv } from "@modern-js/utils";
|
4
|
-
import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
|
5
|
-
import initializePlugin from "./plugins/initialize";
|
6
|
-
import analyzePlugin from "./plugins/analyze";
|
7
|
-
import serverBuildPlugin from "./plugins/serverBuild";
|
8
|
-
import deployPlugin from "./plugins/deploy";
|
9
|
-
import { hooks } from "./hooks";
|
10
|
-
import { i18n } from "./locale";
|
11
|
-
import { restart } from "./utils/restart";
|
12
|
-
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
13
|
-
import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
|
14
|
-
import { dev } from "./commands/dev";
|
15
|
-
import { mergeConfig } from "@modern-js/core";
|
16
|
-
export * from "./defineConfig";
|
17
|
-
export * from "./types";
|
18
|
-
const appTools = (options = {
|
19
|
-
bundler: "webpack"
|
20
|
-
}) => ({
|
21
|
-
name: "@modern-js/app-tools",
|
22
|
-
post: [
|
23
|
-
"@modern-js/plugin-initialize",
|
24
|
-
"@modern-js/plugin-analyze",
|
25
|
-
"@modern-js/plugin-ssr",
|
26
|
-
"@modern-js/plugin-document",
|
27
|
-
"@modern-js/plugin-state",
|
28
|
-
"@modern-js/plugin-router",
|
29
|
-
"@modern-js/plugin-router-v5",
|
30
|
-
"@modern-js/plugin-polyfill"
|
31
|
-
],
|
32
|
-
registerHook: hooks,
|
33
|
-
usePlugins: [
|
34
|
-
initializePlugin({
|
35
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
36
|
-
}),
|
37
|
-
analyzePlugin({
|
38
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
39
|
-
}),
|
40
|
-
serverBuildPlugin(),
|
41
|
-
lintPlugin(),
|
42
|
-
deployPlugin()
|
43
|
-
],
|
44
|
-
setup: (api) => {
|
45
|
-
const appContext = api.useAppContext();
|
46
|
-
api.setAppContext({
|
47
|
-
...appContext,
|
48
|
-
toolsType: "app-tools"
|
49
|
-
});
|
50
|
-
const locale = getLocaleLanguage();
|
51
|
-
i18n.changeLanguage({
|
52
|
-
locale
|
53
|
-
});
|
54
|
-
return {
|
55
|
-
async beforeConfig() {
|
56
|
-
var _userConfig_output;
|
57
|
-
const userConfig = api.useConfigContext();
|
58
|
-
const appContext2 = api.useAppContext();
|
59
|
-
if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
|
60
|
-
api.setAppContext({
|
61
|
-
...appContext2,
|
62
|
-
internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
|
63
|
-
});
|
64
|
-
}
|
65
|
-
},
|
66
|
-
async commands({ program }) {
|
67
|
-
await devCommand(program, api);
|
68
|
-
await buildCommand(program, api);
|
69
|
-
serverCommand(program, api);
|
70
|
-
deployCommand(program, api);
|
71
|
-
newCommand(program, locale);
|
72
|
-
inspectCommand(program, api);
|
73
|
-
upgradeCommand(program);
|
74
|
-
},
|
75
|
-
async prepare() {
|
76
|
-
const command = getCommand();
|
77
|
-
if (command === "deploy") {
|
78
|
-
const isSkipBuild = [
|
79
|
-
"-s",
|
80
|
-
"--skip-build"
|
81
|
-
].some((tag) => {
|
82
|
-
return getArgv().includes(tag);
|
83
|
-
});
|
84
|
-
if (isSkipBuild) {
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
|
89
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
90
|
-
if (resolvedConfig.output.cleanDistPath) {
|
91
|
-
const appContext2 = api.useAppContext();
|
92
|
-
await emptyDir(appContext2.distDirectory);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
},
|
96
|
-
async watchFiles() {
|
97
|
-
const appContext2 = api.useAppContext();
|
98
|
-
const config = api.useResolvedConfigContext();
|
99
|
-
return await generateWatchFiles(appContext2, config.source.configDir);
|
100
|
-
},
|
101
|
-
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
102
|
-
async fileChange(e) {
|
103
|
-
const { filename, eventType, isPrivate } = e;
|
104
|
-
if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
|
105
|
-
const { closeServer } = await import("./utils/createServer");
|
106
|
-
await closeServer();
|
107
|
-
await restart(api.useHookRunners(), filename);
|
108
|
-
}
|
109
|
-
},
|
110
|
-
async beforeRestart() {
|
111
|
-
cleanRequireCache([
|
112
|
-
require.resolve("./plugins/analyze")
|
113
|
-
]);
|
114
|
-
}
|
115
|
-
};
|
116
|
-
}
|
117
|
-
});
|
118
|
-
var src_default = appTools;
|
119
|
-
export {
|
120
|
-
appTools,
|
121
|
-
src_default as default,
|
122
|
-
dev,
|
123
|
-
mergeConfig
|
124
|
-
};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
const EN_LOCALE = {
|
2
|
-
command: {
|
3
|
-
shared: {
|
4
|
-
analyze: "analyze bundle size",
|
5
|
-
config: "specify the configuration file, which can be a relative or absolute path",
|
6
|
-
skipBuild: "skip the build phase",
|
7
|
-
noNeedInstall: "not run install command"
|
8
|
-
},
|
9
|
-
dev: {
|
10
|
-
describe: "starting the dev server",
|
11
|
-
entry: "compiler by entry",
|
12
|
-
apiOnly: "start api server only",
|
13
|
-
webOnly: "start web server only",
|
14
|
-
selectEntry: "Please select the entry that needs to be built",
|
15
|
-
requireEntry: "You must choose at least one entry"
|
16
|
-
},
|
17
|
-
build: {
|
18
|
-
describe: "build the app for production"
|
19
|
-
},
|
20
|
-
serve: {
|
21
|
-
describe: "preview the production build locally"
|
22
|
-
},
|
23
|
-
deploy: {
|
24
|
-
describe: "deploy the application"
|
25
|
-
},
|
26
|
-
new: {
|
27
|
-
describe: "enable optional features or add a new entry",
|
28
|
-
debug: "using debug mode to log something",
|
29
|
-
config: "set default generator config(json string)",
|
30
|
-
distTag: `use specified tag version for it's generator`,
|
31
|
-
registry: "set npm registry url to run npm command",
|
32
|
-
lang: "set new command language(en or zh)"
|
33
|
-
},
|
34
|
-
inspect: {
|
35
|
-
env: "specify env mode",
|
36
|
-
output: "specify inspect content output path",
|
37
|
-
verbose: "show full function definitions in output"
|
38
|
-
}
|
39
|
-
}
|
40
|
-
};
|
41
|
-
export {
|
42
|
-
EN_LOCALE
|
43
|
-
};
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { I18n } from "@modern-js/plugin-i18n";
|
2
|
-
import { ZH_LOCALE } from "./zh";
|
3
|
-
import { EN_LOCALE } from "./en";
|
4
|
-
const i18n = new I18n();
|
5
|
-
const localeKeys = i18n.init("en", {
|
6
|
-
zh: ZH_LOCALE,
|
7
|
-
en: EN_LOCALE
|
8
|
-
});
|
9
|
-
export {
|
10
|
-
i18n,
|
11
|
-
localeKeys
|
12
|
-
};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
const ZH_LOCALE = {
|
2
|
-
command: {
|
3
|
-
shared: {
|
4
|
-
analyze: "分析构建产物体积,查看各个模块打包后的大小",
|
5
|
-
config: "指定配置文件路径,可以为相对路径或绝对路径",
|
6
|
-
skipBuild: "跳过构建阶段",
|
7
|
-
noNeedInstall: "无需安装依赖"
|
8
|
-
},
|
9
|
-
dev: {
|
10
|
-
describe: "启动开发服务器",
|
11
|
-
entry: "指定入口,编译特定的页面",
|
12
|
-
apiOnly: "仅启动 API 接口服务",
|
13
|
-
webOnly: "仅启动 Web 服务",
|
14
|
-
selectEntry: "请选择需要构建的入口",
|
15
|
-
requireEntry: "请至少选择一个入口"
|
16
|
-
},
|
17
|
-
build: {
|
18
|
-
describe: "构建生产环境产物"
|
19
|
-
},
|
20
|
-
serve: {
|
21
|
-
describe: "启动生产环境服务"
|
22
|
-
},
|
23
|
-
deploy: {
|
24
|
-
describe: "部署应用"
|
25
|
-
},
|
26
|
-
new: {
|
27
|
-
describe: "Web App 项目中执行生成器",
|
28
|
-
debug: "开启 Debug 模式,打印调试日志信息",
|
29
|
-
config: "生成器运行默认配置(JSON 字符串)",
|
30
|
-
distTag: "生成器使用特殊的 npm Tag 版本",
|
31
|
-
registry: "生成器运行过程中定制 npm Registry",
|
32
|
-
lang: "设置 new 命令执行语言(zh 或者 en)"
|
33
|
-
},
|
34
|
-
inspect: {
|
35
|
-
env: "查看指定环境下的配置",
|
36
|
-
output: "指定在 dist 目录下输出的路径",
|
37
|
-
verbose: "在结果中展示函数的完整内容"
|
38
|
-
}
|
39
|
-
}
|
40
|
-
};
|
41
|
-
export {
|
42
|
-
ZH_LOCALE
|
43
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
const INDEX_FILE_NAME = "index";
|
2
|
-
const ENTRY_FILE_NAME = "entry";
|
3
|
-
const HTML_PARTIALS_FOLDER = "html";
|
4
|
-
const HTML_PARTIALS_EXTENSIONS = [
|
5
|
-
".htm",
|
6
|
-
".html",
|
7
|
-
".ejs"
|
8
|
-
];
|
9
|
-
export {
|
10
|
-
ENTRY_FILE_NAME,
|
11
|
-
HTML_PARTIALS_EXTENSIONS,
|
12
|
-
HTML_PARTIALS_FOLDER,
|
13
|
-
INDEX_FILE_NAME
|
14
|
-
};
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, JS_EXTENSIONS } from "@modern-js/utils";
|
3
|
-
import { getFileSystemEntry } from "./getFileSystemEntry";
|
4
|
-
import { isSubDirOrEqual } from "./utils";
|
5
|
-
const ensureExtensions = (file) => {
|
6
|
-
if (!path.extname(file)) {
|
7
|
-
return findExists(JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
|
8
|
-
}
|
9
|
-
return file;
|
10
|
-
};
|
11
|
-
const isDirectory = (file) => !path.extname(file);
|
12
|
-
const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint) => {
|
13
|
-
if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
|
14
|
-
checked.entryName = entrypoint.entryName;
|
15
|
-
return true;
|
16
|
-
}
|
17
|
-
if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
|
18
|
-
throw new Error(`Entry configuration conflicts
|
19
|
-
Your configuration: ${checked.entry}.
|
20
|
-
Default entrypoint: ${entrypoint.entry}
|
21
|
-
Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules.`);
|
22
|
-
}
|
23
|
-
return false;
|
24
|
-
});
|
25
|
-
const getBundleEntry = async (hookRunners, appContext, config) => {
|
26
|
-
const { appDirectory, packageName } = appContext;
|
27
|
-
const { disableDefaultEntries, entries, entriesDir, mainEntryName } = config.source;
|
28
|
-
const defaults = disableDefaultEntries ? [] : await getFileSystemEntry(hookRunners, appContext, config);
|
29
|
-
if (entries) {
|
30
|
-
Object.keys(entries).forEach((name) => {
|
31
|
-
const value = entries[name];
|
32
|
-
const entryName = typeof value === "string" ? value : value.entry;
|
33
|
-
const isAutoMount = typeof value === "string" ? true : !value.disableMount;
|
34
|
-
const entrypoint = {
|
35
|
-
entryName: name,
|
36
|
-
isMainEntry: false,
|
37
|
-
entry: ensureAbsolutePath(appDirectory, entryName),
|
38
|
-
absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, entryName)) ? ensureAbsolutePath(appDirectory, entryName) : path.dirname(ensureAbsolutePath(appDirectory, entryName)),
|
39
|
-
isAutoMount,
|
40
|
-
customBootstrap: typeof value === "string" ? false : value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
|
41
|
-
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0,
|
42
|
-
isCustomSourceEntry: true
|
43
|
-
};
|
44
|
-
if (!ifAlreadyExists(defaults, entrypoint)) {
|
45
|
-
defaults.push(entrypoint);
|
46
|
-
}
|
47
|
-
});
|
48
|
-
}
|
49
|
-
if (!disableDefaultEntries) {
|
50
|
-
const entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir || "");
|
51
|
-
const found = defaults.find(({ entryName, entry, nestedRoutesEntry = "" }) => entryName === packageName || path.dirname(entry) === entriesDirAbs || path.dirname(nestedRoutesEntry) === entriesDirAbs);
|
52
|
-
if (found) {
|
53
|
-
found.entryName = mainEntryName || MAIN_ENTRY_NAME;
|
54
|
-
found.isMainEntry = true;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
return defaults;
|
58
|
-
};
|
59
|
-
export {
|
60
|
-
getBundleEntry
|
61
|
-
};
|
@@ -1,100 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import path from "path";
|
3
|
-
import { findExists, ensureAbsolutePath, JS_EXTENSIONS } from "@modern-js/utils";
|
4
|
-
import { ENTRY_FILE_NAME, INDEX_FILE_NAME } from "./constants";
|
5
|
-
import { isDefaultExportFunction } from "./isDefaultExportFunction";
|
6
|
-
const hasIndex = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${INDEX_FILE_NAME}${ext}`)));
|
7
|
-
const hasEntry = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${ENTRY_FILE_NAME}${ext}`)));
|
8
|
-
const hasServerEntry = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${ENTRY_FILE_NAME}.server${ext}`)));
|
9
|
-
const isBundleEntry = async (hookRunners, dir, enableCustomEntry) => {
|
10
|
-
const { entry } = await hookRunners.checkEntryPoint({
|
11
|
-
path: dir,
|
12
|
-
entry: false
|
13
|
-
});
|
14
|
-
if (entry) {
|
15
|
-
return entry;
|
16
|
-
}
|
17
|
-
const customEntry = hasEntry(dir);
|
18
|
-
if (enableCustomEntry && customEntry) {
|
19
|
-
return customEntry;
|
20
|
-
}
|
21
|
-
return hasIndex(dir);
|
22
|
-
};
|
23
|
-
const scanDir = (hookRunners, dirs, enableCustomEntry) => Promise.all(dirs.map(async (dir) => {
|
24
|
-
const indexFile = hasIndex(dir);
|
25
|
-
const customBootstrap = isDefaultExportFunction(indexFile) ? indexFile : false;
|
26
|
-
const entryName = path.basename(dir);
|
27
|
-
const customEntryFile = hasEntry(dir);
|
28
|
-
const customServerEntry = hasServerEntry(dir);
|
29
|
-
if (indexFile && !customBootstrap) {
|
30
|
-
return {
|
31
|
-
entryName,
|
32
|
-
isMainEntry: false,
|
33
|
-
entry: indexFile,
|
34
|
-
absoluteEntryDir: path.resolve(dir),
|
35
|
-
isAutoMount: false,
|
36
|
-
customBootstrap
|
37
|
-
};
|
38
|
-
}
|
39
|
-
const entryFile = (await hookRunners.checkEntryPoint({
|
40
|
-
path: dir,
|
41
|
-
entry: false
|
42
|
-
})).entry;
|
43
|
-
if (entryFile) {
|
44
|
-
return {
|
45
|
-
entryName,
|
46
|
-
isMainEntry: false,
|
47
|
-
entry: enableCustomEntry ? customEntryFile || entryFile : entryFile,
|
48
|
-
customServerEntry,
|
49
|
-
absoluteEntryDir: path.resolve(dir),
|
50
|
-
isAutoMount: true,
|
51
|
-
customBootstrap,
|
52
|
-
customEntry: enableCustomEntry ? Boolean(customEntryFile) : false
|
53
|
-
};
|
54
|
-
}
|
55
|
-
if (enableCustomEntry && customEntryFile) {
|
56
|
-
return {
|
57
|
-
entryName,
|
58
|
-
isMainEntry: false,
|
59
|
-
entry: customEntryFile,
|
60
|
-
customServerEntry,
|
61
|
-
absoluteEntryDir: path.resolve(dir),
|
62
|
-
isAutoMount: false,
|
63
|
-
customEntry: Boolean(customEntryFile)
|
64
|
-
};
|
65
|
-
}
|
66
|
-
throw Error("There is no valid entry point in the current project!");
|
67
|
-
}));
|
68
|
-
const getFileSystemEntry = async (hookRunners, appContext, config) => {
|
69
|
-
const { appDirectory } = appContext;
|
70
|
-
const { source: { entriesDir, disableEntryDirs, enableCustomEntry } } = config;
|
71
|
-
let disabledDirs = [];
|
72
|
-
if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
|
73
|
-
disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map((dir) => ensureAbsolutePath(appDirectory, dir));
|
74
|
-
}
|
75
|
-
const src = ensureAbsolutePath(appDirectory, entriesDir || "");
|
76
|
-
if (fs.existsSync(src)) {
|
77
|
-
if (fs.statSync(src).isDirectory()) {
|
78
|
-
if (await isBundleEntry(hookRunners, src, enableCustomEntry)) {
|
79
|
-
return scanDir(hookRunners, [
|
80
|
-
src
|
81
|
-
], enableCustomEntry);
|
82
|
-
}
|
83
|
-
const dirs = [];
|
84
|
-
await Promise.all(fs.readdirSync(src).map(async (filename) => {
|
85
|
-
const file = path.join(src, filename);
|
86
|
-
if (fs.statSync(file).isDirectory() && await isBundleEntry(hookRunners, file, enableCustomEntry) && !disabledDirs.includes(file)) {
|
87
|
-
dirs.push(file);
|
88
|
-
}
|
89
|
-
}));
|
90
|
-
return scanDir(hookRunners, dirs, enableCustomEntry);
|
91
|
-
} else {
|
92
|
-
throw Error(`source.entriesDir accept a directory.`);
|
93
|
-
}
|
94
|
-
} else {
|
95
|
-
throw Error(`src dir ${entriesDir} not found.`);
|
96
|
-
}
|
97
|
-
};
|
98
|
-
export {
|
99
|
-
getFileSystemEntry
|
100
|
-
};
|
@@ -1,74 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs, findExists } from "@modern-js/utils";
|
3
|
-
import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants";
|
4
|
-
import * as templates from "./templates";
|
5
|
-
var PartialPosition;
|
6
|
-
(function(PartialPosition2) {
|
7
|
-
PartialPosition2["TOP"] = "top";
|
8
|
-
PartialPosition2["HEAD"] = "head";
|
9
|
-
PartialPosition2["BODY"] = "body";
|
10
|
-
PartialPosition2["BOTTOM"] = "bottom";
|
11
|
-
PartialPosition2["INDEX"] = "index";
|
12
|
-
})(PartialPosition || (PartialPosition = {}));
|
13
|
-
const findPartials = (dir, entryName, position) => {
|
14
|
-
if (fs.existsSync(dir)) {
|
15
|
-
const base = findExists(HTML_PARTIALS_EXTENSIONS.map((ext) => path.resolve(dir, `${position}${ext}`)));
|
16
|
-
const file = entryName ? findExists(HTML_PARTIALS_EXTENSIONS.map((ext) => path.resolve(dir, entryName, `${position}${ext}`))) || base : base;
|
17
|
-
return file ? {
|
18
|
-
file,
|
19
|
-
content: fs.readFileSync(file, "utf8")
|
20
|
-
} : null;
|
21
|
-
}
|
22
|
-
return null;
|
23
|
-
};
|
24
|
-
const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
25
|
-
const { appDirectory, internalDirectory } = appContext;
|
26
|
-
const { source: { configDir } } = config;
|
27
|
-
const htmlDir = path.resolve(appDirectory, configDir || "", HTML_PARTIALS_FOLDER);
|
28
|
-
const htmlTemplates = {};
|
29
|
-
const partialsByEntrypoint = {};
|
30
|
-
for (const entrypoint of entrypoints) {
|
31
|
-
const { entryName, isMainEntry } = entrypoint;
|
32
|
-
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
33
|
-
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
34
|
-
if (customIndexTemplate) {
|
35
|
-
htmlTemplates[entryName] = customIndexTemplate.file;
|
36
|
-
} else {
|
37
|
-
const hookRunners = api.useHookRunners();
|
38
|
-
const { partials } = await hookRunners.htmlPartials({
|
39
|
-
entrypoint,
|
40
|
-
partials: [
|
41
|
-
"top",
|
42
|
-
"head",
|
43
|
-
"body"
|
44
|
-
].reduce((previous, position) => {
|
45
|
-
const found = findPartials(htmlDir, name, position);
|
46
|
-
previous[position] = found ? [
|
47
|
-
found.content
|
48
|
-
] : [];
|
49
|
-
return previous;
|
50
|
-
}, {
|
51
|
-
top: [],
|
52
|
-
head: [],
|
53
|
-
body: []
|
54
|
-
})
|
55
|
-
});
|
56
|
-
const templatePath = path.resolve(internalDirectory, entryName, "index.html");
|
57
|
-
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
58
|
-
htmlTemplates[entryName] = templatePath;
|
59
|
-
partialsByEntrypoint[entryName] = partials;
|
60
|
-
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
61
|
-
if (bottomTemplate) {
|
62
|
-
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
api.setAppContext({
|
67
|
-
...api.useAppContext(),
|
68
|
-
partialsByEntrypoint
|
69
|
-
});
|
70
|
-
return htmlTemplates;
|
71
|
-
};
|
72
|
-
export {
|
73
|
-
getHtmlTemplate
|
74
|
-
};
|