@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,270 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import * as path from "path";
|
4
|
-
import { mergeRsbuildConfig } from "@rsbuild/core";
|
5
|
-
import { fs, isUseSSRBundle } from "@modern-js/utils";
|
6
|
-
import { isHtmlDisabled, SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
|
7
|
-
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
|
8
|
-
import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
|
9
|
-
var builderPluginAdapterSSR = function(options) {
|
10
|
-
return {
|
11
|
-
name: "builder-plugin-adapter-modern-ssr",
|
12
|
-
setup: function setup(api) {
|
13
|
-
var normalizedConfig = options.normalizedConfig;
|
14
|
-
api.modifyRsbuildConfig(function(config) {
|
15
|
-
return mergeRsbuildConfig(config, {
|
16
|
-
html: {
|
17
|
-
inject: isStreamingSSR(normalizedConfig) ? "body" : void 0
|
18
|
-
},
|
19
|
-
server: {
|
20
|
-
// the http-compression can't handler stream http.
|
21
|
-
// so we disable compress when user use stream ssr temporarily.
|
22
|
-
compress: isStreamingSSR(normalizedConfig) || isSSRPreload(normalizedConfig) ? false : void 0
|
23
|
-
}
|
24
|
-
});
|
25
|
-
});
|
26
|
-
api.modifyBundlerChain(function() {
|
27
|
-
var _ref = _async_to_generator(function(chain, param) {
|
28
|
-
var target, isProd, HtmlBundlerPlugin, isServer, environment, builderConfig, normalizedConfig2, isServiceWorker;
|
29
|
-
return _ts_generator(this, function(_state) {
|
30
|
-
switch (_state.label) {
|
31
|
-
case 0:
|
32
|
-
target = param.target, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer, environment = param.environment;
|
33
|
-
builderConfig = environment.config;
|
34
|
-
normalizedConfig2 = options.normalizedConfig;
|
35
|
-
applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
|
36
|
-
if (!isUseSSRBundle(normalizedConfig2))
|
37
|
-
return [
|
38
|
-
3,
|
39
|
-
2
|
40
|
-
];
|
41
|
-
return [
|
42
|
-
4,
|
43
|
-
applySSRLoaderEntry(chain, options, isServer)
|
44
|
-
];
|
45
|
-
case 1:
|
46
|
-
_state.sent();
|
47
|
-
applySSRDataLoader(chain, options);
|
48
|
-
_state.label = 2;
|
49
|
-
case 2:
|
50
|
-
isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
|
51
|
-
if (target === "node" || isServiceWorker) {
|
52
|
-
applyFilterEntriesBySSRConfig({
|
53
|
-
isProd,
|
54
|
-
chain,
|
55
|
-
appNormalizedConfig: normalizedConfig2
|
56
|
-
});
|
57
|
-
}
|
58
|
-
if (!isHtmlDisabled(builderConfig, target)) {
|
59
|
-
applyAsyncChunkHtmlPlugin({
|
60
|
-
chain,
|
61
|
-
modernConfig: options.normalizedConfig,
|
62
|
-
HtmlBundlerPlugin
|
63
|
-
});
|
64
|
-
}
|
65
|
-
return [
|
66
|
-
2
|
67
|
-
];
|
68
|
-
}
|
69
|
-
});
|
70
|
-
});
|
71
|
-
return function(chain, _) {
|
72
|
-
return _ref.apply(this, arguments);
|
73
|
-
};
|
74
|
-
}());
|
75
|
-
}
|
76
|
-
};
|
77
|
-
};
|
78
|
-
var isSSRPreload = function(userConfig) {
|
79
|
-
var _userConfig_server = userConfig.server, ssr = _userConfig_server.ssr, ssrByEntries = _userConfig_server.ssrByEntries;
|
80
|
-
var checkUsePreload = function(ssr2) {
|
81
|
-
return typeof ssr2 === "object" && Boolean(ssr2.preload);
|
82
|
-
};
|
83
|
-
return checkUsePreload(ssr) || Object.values(ssrByEntries || {}).some(function(ssr2) {
|
84
|
-
return checkUsePreload(ssr2);
|
85
|
-
});
|
86
|
-
};
|
87
|
-
var isStreamingSSR = function(userConfig) {
|
88
|
-
var isStreaming = function(ssr) {
|
89
|
-
return ssr && typeof ssr === "object" && ssr.mode === "stream";
|
90
|
-
};
|
91
|
-
var server = userConfig.server;
|
92
|
-
if (isStreaming(server.ssr)) {
|
93
|
-
return true;
|
94
|
-
}
|
95
|
-
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
96
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
97
|
-
try {
|
98
|
-
for (var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
99
|
-
var name = _step.value;
|
100
|
-
if (isStreaming(server.ssrByEntries[name])) {
|
101
|
-
return true;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
} catch (err) {
|
105
|
-
_didIteratorError = true;
|
106
|
-
_iteratorError = err;
|
107
|
-
} finally {
|
108
|
-
try {
|
109
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
110
|
-
_iterator.return();
|
111
|
-
}
|
112
|
-
} finally {
|
113
|
-
if (_didIteratorError) {
|
114
|
-
throw _iteratorError;
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
}
|
119
|
-
return false;
|
120
|
-
};
|
121
|
-
function applyAsyncChunkHtmlPlugin(param) {
|
122
|
-
var chain = param.chain, modernConfig = param.modernConfig, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
|
123
|
-
if (isStreamingSSR(modernConfig)) {
|
124
|
-
chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
|
125
|
-
HtmlBundlerPlugin
|
126
|
-
]);
|
127
|
-
}
|
128
|
-
}
|
129
|
-
function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
|
130
|
-
var _normalizedConfig_runtime, _normalizedConfig_deploy_worker;
|
131
|
-
var appContext = options.appContext, normalizedConfig = options.normalizedConfig;
|
132
|
-
var entrypoints = appContext.entrypoints;
|
133
|
-
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
134
|
-
return entrypoint.nestedRoutesEntry;
|
135
|
-
});
|
136
|
-
var routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
|
137
|
-
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
138
|
-
var workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
|
139
|
-
var _normalizedConfig_output = normalizedConfig.output, enableInlineRouteManifests = _normalizedConfig_output.enableInlineRouteManifests, disableInlineRouteManifests = _normalizedConfig_output.disableInlineRouteManifests;
|
140
|
-
var inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
|
141
|
-
if (existNestedRoutes || routerManifest || workerSSR) {
|
142
|
-
var _normalizedConfig_output_distPath, _normalizedConfig_output1, _normalizedConfig_output2, _normalizedConfig_html, _normalizedConfig_security;
|
143
|
-
chain.plugin(pluginName).use(RouterPlugin, [
|
144
|
-
{
|
145
|
-
HtmlBundlerPlugin,
|
146
|
-
enableInlineRouteManifests: inlineRouteManifests,
|
147
|
-
staticJsDir: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output1.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
|
148
|
-
disableFilenameHash: (_normalizedConfig_output2 = normalizedConfig.output) === null || _normalizedConfig_output2 === void 0 ? void 0 : _normalizedConfig_output2.disableFilenameHash,
|
149
|
-
scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
|
150
|
-
nonce: (_normalizedConfig_security = normalizedConfig.security) === null || _normalizedConfig_security === void 0 ? void 0 : _normalizedConfig_security.nonce
|
151
|
-
}
|
152
|
-
]);
|
153
|
-
}
|
154
|
-
}
|
155
|
-
function applyFilterEntriesBySSRConfig(param) {
|
156
|
-
var isProd = param.isProd, chain = param.chain, appNormalizedConfig = param.appNormalizedConfig;
|
157
|
-
var _this;
|
158
|
-
var serverConfig = appNormalizedConfig.server, outputConfig = appNormalizedConfig.output;
|
159
|
-
var entries = chain.entryPoints.entries();
|
160
|
-
if (isProd && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof ((_this = outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === null || _this === void 0 ? void 0 : _this[0]) === "function")) {
|
161
|
-
return;
|
162
|
-
}
|
163
|
-
if (typeof entries === "undefined") {
|
164
|
-
throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
|
165
|
-
}
|
166
|
-
var entryNames = Object.keys(entries);
|
167
|
-
if (isProd && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
168
|
-
return;
|
169
|
-
}
|
170
|
-
var ssgEntries = [];
|
171
|
-
if (isProd && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
172
|
-
var ssg = outputConfig.ssg;
|
173
|
-
entryNames.forEach(function(name) {
|
174
|
-
if (ssg[name]) {
|
175
|
-
ssgEntries.push(name);
|
176
|
-
}
|
177
|
-
});
|
178
|
-
}
|
179
|
-
var _ref = serverConfig || {}, ssr = _ref.ssr, ssrByEntries = _ref.ssrByEntries;
|
180
|
-
entryNames.forEach(function(name) {
|
181
|
-
if (!ssgEntries.includes(name) && !name.includes("server-loaders") && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
182
|
-
chain.entryPoints.delete(name);
|
183
|
-
}
|
184
|
-
});
|
185
|
-
}
|
186
|
-
function applySSRLoaderEntry(chain, optinos, isServer) {
|
187
|
-
return _applySSRLoaderEntry.apply(this, arguments);
|
188
|
-
}
|
189
|
-
function _applySSRLoaderEntry() {
|
190
|
-
_applySSRLoaderEntry = _async_to_generator(function(chain, optinos, isServer) {
|
191
|
-
var appContext, internalDirectory, entrypoints;
|
192
|
-
return _ts_generator(this, function(_state) {
|
193
|
-
switch (_state.label) {
|
194
|
-
case 0:
|
195
|
-
appContext = optinos.appContext;
|
196
|
-
internalDirectory = appContext.internalDirectory;
|
197
|
-
entrypoints = appContext.entrypoints;
|
198
|
-
return [
|
199
|
-
4,
|
200
|
-
Promise.all(entrypoints.map(function() {
|
201
|
-
var _ref = _async_to_generator(function(entrypoint) {
|
202
|
-
var entryName, serverLoadersFile, err;
|
203
|
-
return _ts_generator(this, function(_state2) {
|
204
|
-
switch (_state2.label) {
|
205
|
-
case 0:
|
206
|
-
entryName = entrypoint.entryName;
|
207
|
-
serverLoadersFile = getServerCombinedModueFile(internalDirectory, entryName);
|
208
|
-
if (!isServer)
|
209
|
-
return [
|
210
|
-
3,
|
211
|
-
4
|
212
|
-
];
|
213
|
-
_state2.label = 1;
|
214
|
-
case 1:
|
215
|
-
_state2.trys.push([
|
216
|
-
1,
|
217
|
-
3,
|
218
|
-
,
|
219
|
-
4
|
220
|
-
]);
|
221
|
-
return [
|
222
|
-
4,
|
223
|
-
fs.access(serverLoadersFile, fs.constants.F_OK)
|
224
|
-
];
|
225
|
-
case 2:
|
226
|
-
_state2.sent();
|
227
|
-
chain.entry("".concat(entryName, "-server-loaders")).add(serverLoadersFile);
|
228
|
-
return [
|
229
|
-
3,
|
230
|
-
4
|
231
|
-
];
|
232
|
-
case 3:
|
233
|
-
err = _state2.sent();
|
234
|
-
return [
|
235
|
-
3,
|
236
|
-
4
|
237
|
-
];
|
238
|
-
case 4:
|
239
|
-
return [
|
240
|
-
2
|
241
|
-
];
|
242
|
-
}
|
243
|
-
});
|
244
|
-
});
|
245
|
-
return function(entrypoint) {
|
246
|
-
return _ref.apply(this, arguments);
|
247
|
-
};
|
248
|
-
}()))
|
249
|
-
];
|
250
|
-
case 1:
|
251
|
-
_state.sent();
|
252
|
-
return [
|
253
|
-
2
|
254
|
-
];
|
255
|
-
}
|
256
|
-
});
|
257
|
-
});
|
258
|
-
return _applySSRLoaderEntry.apply(this, arguments);
|
259
|
-
}
|
260
|
-
function applySSRDataLoader(chain, options) {
|
261
|
-
var normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
262
|
-
var appDirectory = appContext.appDirectory;
|
263
|
-
var _normalizedConfig_source = normalizedConfig.source, _normalizedConfig_source_entriesDir = _normalizedConfig_source.entriesDir, entriesDir = _normalizedConfig_source_entriesDir === void 0 ? "./src" : _normalizedConfig_source_entriesDir;
|
264
|
-
var absolutePath = path.resolve(appDirectory, entriesDir).split(path.sep).join("(\\\\|/)");
|
265
|
-
var reg = new RegExp("".concat(absolutePath, ".*\\.(loader|data|data.client)\\.[t|j]sx?$"));
|
266
|
-
chain.module.rule("ssr-data-loader").test(reg).use("data-loader").loader(require.resolve("@modern-js/plugin-data-loader/loader")).end();
|
267
|
-
}
|
268
|
-
export {
|
269
|
-
builderPluginAdapterSSR
|
270
|
-
};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { posix } from "path";
|
4
|
-
import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
|
5
|
-
var getDistPath = function(outputConfig, type) {
|
6
|
-
var distPath = outputConfig.distPath;
|
7
|
-
var ret = distPath[type];
|
8
|
-
if (typeof ret !== "string") {
|
9
|
-
throw new Error("unknown key ".concat(type, ' in "output.distPath"'));
|
10
|
-
}
|
11
|
-
return ret;
|
12
|
-
};
|
13
|
-
var builderPluginAdapterWorker = function() {
|
14
|
-
return {
|
15
|
-
name: "builder-plugin-adapter-worker",
|
16
|
-
setup: function setup(api) {
|
17
|
-
api.modifyBundlerChain(function() {
|
18
|
-
var _ref = _async_to_generator(function(chain, param) {
|
19
|
-
var environment, config, name, isServiceWorker, workerPath, filename;
|
20
|
-
return _ts_generator(this, function(_state) {
|
21
|
-
environment = param.environment;
|
22
|
-
config = environment.config, name = environment.name;
|
23
|
-
isServiceWorker = name === SERVICE_WORKER_ENVIRONMENT_NAME;
|
24
|
-
if (isServiceWorker) {
|
25
|
-
workerPath = getDistPath(config.output, "root");
|
26
|
-
filename = posix.join(workerPath, "[name].js");
|
27
|
-
chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
|
28
|
-
}
|
29
|
-
return [
|
30
|
-
2
|
31
|
-
];
|
32
|
-
});
|
33
|
-
});
|
34
|
-
return function(chain, _) {
|
35
|
-
return _ref.apply(this, arguments);
|
36
|
-
};
|
37
|
-
}());
|
38
|
-
}
|
39
|
-
};
|
40
|
-
};
|
41
|
-
export {
|
42
|
-
builderPluginAdapterWorker
|
43
|
-
};
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
2
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
3
|
-
var HtmlAsyncChunkPlugin = /* @__PURE__ */ function() {
|
4
|
-
"use strict";
|
5
|
-
function HtmlAsyncChunkPlugin2(htmlWebpackPlugin) {
|
6
|
-
_class_call_check(this, HtmlAsyncChunkPlugin2);
|
7
|
-
this.name = "HtmlAsyncChunkPlugin";
|
8
|
-
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
9
|
-
}
|
10
|
-
var _proto = HtmlAsyncChunkPlugin2.prototype;
|
11
|
-
_proto.apply = function apply(compiler) {
|
12
|
-
var _this = this;
|
13
|
-
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
14
|
-
var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
|
15
|
-
hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
|
16
|
-
var tags = _to_consumable_array(assets.headTags).concat(_to_consumable_array(assets.bodyTags));
|
17
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
18
|
-
try {
|
19
|
-
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
20
|
-
var tag = _step.value;
|
21
|
-
if (tag.tagName === "script") {
|
22
|
-
var attributes = tag.attributes;
|
23
|
-
if (attributes && attributes.defer === true) {
|
24
|
-
attributes.async = true;
|
25
|
-
delete attributes.defer;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
} catch (err) {
|
30
|
-
_didIteratorError = true;
|
31
|
-
_iteratorError = err;
|
32
|
-
} finally {
|
33
|
-
try {
|
34
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
35
|
-
_iterator.return();
|
36
|
-
}
|
37
|
-
} finally {
|
38
|
-
if (_didIteratorError) {
|
39
|
-
throw _iteratorError;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
return assets;
|
44
|
-
});
|
45
|
-
});
|
46
|
-
};
|
47
|
-
return HtmlAsyncChunkPlugin2;
|
48
|
-
}();
|
49
|
-
export {
|
50
|
-
HtmlAsyncChunkPlugin
|
51
|
-
};
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
2
|
-
var BottomTemplatePlugin = /* @__PURE__ */ function() {
|
3
|
-
"use strict";
|
4
|
-
function BottomTemplatePlugin2(htmlWebpackPlugin) {
|
5
|
-
_class_call_check(this, BottomTemplatePlugin2);
|
6
|
-
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
7
|
-
this.bodyRegExp = /(<\/\s*body\s*>)/i;
|
8
|
-
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
9
|
-
this.name = "bottom-template";
|
10
|
-
}
|
11
|
-
var _proto = BottomTemplatePlugin2.prototype;
|
12
|
-
_proto.apply = function apply(compiler) {
|
13
|
-
var _this = this;
|
14
|
-
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
15
|
-
_this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
|
16
|
-
var _data_plugin_options;
|
17
|
-
if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
|
18
|
-
return data;
|
19
|
-
}
|
20
|
-
if (_this.bottomTemplateReg.test(data.html)) {
|
21
|
-
data.html = data.html.replace(_this.bottomTemplateReg, "");
|
22
|
-
var bottomTemplate = data.plugin.options.bottomTemplate;
|
23
|
-
if (bottomTemplate) {
|
24
|
-
data.html = data.html.replace(_this.bodyRegExp, function(match) {
|
25
|
-
return "\n".concat(bottomTemplate, "\n").concat(match);
|
26
|
-
});
|
27
|
-
}
|
28
|
-
}
|
29
|
-
return data;
|
30
|
-
});
|
31
|
-
});
|
32
|
-
};
|
33
|
-
return BottomTemplatePlugin2;
|
34
|
-
}();
|
35
|
-
export {
|
36
|
-
BottomTemplatePlugin
|
37
|
-
};
|