@modern-js/app-tools 2.5.1-alpha.0 → 2.5.1-alpha.1
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.
- package/dist/cjs/analyze/generateCode.js +19 -13
- package/dist/cjs/analyze/getBundleEntry.js +1 -1
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
- package/dist/cjs/builder/builder-webpack/index.js +11 -5
- package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
- package/dist/cjs/commands/dev.js +12 -14
- package/dist/cjs/commands/serve.js +17 -0
- package/dist/cjs/config/legacy/createToolsConfig.js +1 -4
- package/dist/esm/analyze/generateCode.js +37 -26
- package/dist/esm/analyze/getBundleEntry.js +2 -2
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm/builder/builder-webpack/index.js +11 -7
- package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm/commands/dev.js +9 -8
- package/dist/esm/commands/serve.js +6 -1
- package/dist/esm/config/legacy/createToolsConfig.js +1 -4
- package/dist/esm-node/analyze/generateCode.js +20 -14
- package/dist/esm-node/analyze/getBundleEntry.js +2 -3
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm-node/builder/builder-webpack/index.js +12 -6
- package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm-node/commands/dev.js +12 -14
- package/dist/esm-node/commands/serve.js +18 -1
- package/dist/esm-node/config/legacy/createToolsConfig.js +1 -4
- package/dist/js/modern/analyze/constants.js +3 -1
- package/dist/js/modern/analyze/getServerRoutes.js +5 -2
- package/dist/js/modern/analyze/index.js +47 -46
- package/dist/js/modern/analyze/nestedRoutes.js +32 -3
- package/dist/js/modern/analyze/templates.js +4 -10
- package/dist/js/modern/builder/builder-rspack/index.js +8 -0
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/js/modern/builder/builder-webpack/index.js +93 -0
- package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +4 -1
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
- package/dist/js/modern/builder/generator/getBuilderTargets.js +21 -0
- package/dist/js/modern/builder/generator/index.js +53 -0
- package/dist/js/modern/builder/index.js +13 -133
- package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +102 -116
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/js/modern/builder/shared/index.js +3 -0
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/config/default.js +2 -2
- package/dist/js/modern/config/index.js +3 -8
- package/dist/js/modern/config/initialize/index.js +12 -0
- package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/modern/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -0
- package/dist/js/modern/index.js +18 -8
- package/dist/js/modern/initialize/index.js +36 -28
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/getServerRoutes.js +3 -1
- package/dist/js/node/analyze/index.js +48 -47
- package/dist/js/node/analyze/nestedRoutes.js +32 -3
- package/dist/js/node/analyze/templates.js +4 -10
- package/dist/js/node/{config/initial → builder/builder-rspack}/index.js +9 -19
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/node/builder/builder-webpack/index.js +118 -0
- package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +10 -5
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
- package/dist/js/node/builder/generator/getBuilderTargets.js +39 -0
- package/dist/js/node/builder/generator/index.js +82 -0
- package/dist/js/node/builder/index.js +14 -123
- package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +107 -120
- package/dist/js/node/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
- package/dist/js/node/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
- package/dist/js/node/builder/{share.js → shared/createCopyPattern.js} +3 -3
- package/dist/js/node/builder/shared/index.js +19 -0
- package/dist/js/node/builder/shared/types.js +15 -0
- package/dist/js/node/config/default.js +2 -2
- package/dist/js/node/config/index.js +4 -19
- package/dist/js/node/{builder/loaders/routerLoader.js → config/initialize/index.js} +14 -17
- package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/node/config/{initial/transformNormalizedConfig.js → legacy/index.js} +8 -3
- package/dist/js/node/index.js +18 -8
- package/dist/js/node/initialize/index.js +35 -28
- package/dist/js/node/locale/zh.js +1 -1
- package/dist/js/node/types/utils.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +3 -1
- package/dist/js/treeshaking/analyze/generateCode.js +14 -14
- package/dist/js/treeshaking/analyze/getBundleEntry.js +2 -2
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getServerRoutes.js +8 -6
- package/dist/js/treeshaking/analyze/index.js +142 -137
- package/dist/js/treeshaking/analyze/nestedRoutes.js +29 -4
- package/dist/js/treeshaking/analyze/templates.js +10 -13
- package/dist/js/treeshaking/analyze/utils.js +3 -3
- package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +6 -3
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +16 -0
- package/dist/js/treeshaking/builder/generator/index.js +199 -0
- package/dist/js/treeshaking/builder/index.js +29 -228
- package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +138 -142
- package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
- package/dist/js/treeshaking/builder/shared/index.js +3 -0
- package/dist/js/treeshaking/builder/shared/types.js +1 -0
- package/dist/js/treeshaking/commands/dev.js +2 -2
- package/dist/js/treeshaking/commands/serve.js +2 -2
- package/dist/js/treeshaking/config/default.js +2 -2
- package/dist/js/treeshaking/config/index.js +3 -3
- package/dist/js/treeshaking/config/initialize/index.js +10 -0
- package/dist/js/treeshaking/config/{initial → initialize}/inits.js +6 -4
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -1
- package/dist/js/treeshaking/index.js +19 -12
- package/dist/js/treeshaking/initialize/index.js +36 -28
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/js/treeshaking/types/utils.js +1 -0
- package/dist/js/treeshaking/utils/config.js +2 -2
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +2 -2
- package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +7 -1
- package/package.json +6 -6
- package/dist/js/modern/builder/loaders/routerLoader.js +0 -17
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +0 -13
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- /package/dist/js/modern/builder/{share.js → shared/createCopyPattern.js} +0 -0
- /package/dist/js/modern/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
- /package/dist/js/modern/config/{initial → legacy}/createHtmlConfig.js +0 -0
- /package/dist/js/modern/config/{initial → legacy}/createOutputConfig.js +0 -0
- /package/dist/js/modern/config/{initial → legacy}/createSourceConfig.js +0 -0
- /package/dist/js/modern/config/{initial → legacy}/createToolsConfig.js +0 -0
- /package/dist/js/node/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
- /package/dist/js/node/config/{initial → legacy}/createHtmlConfig.js +0 -0
- /package/dist/js/node/config/{initial → legacy}/createOutputConfig.js +0 -0
- /package/dist/js/node/config/{initial → legacy}/createSourceConfig.js +0 -0
- /package/dist/js/node/config/{initial → legacy}/createToolsConfig.js +0 -0
- /package/dist/js/treeshaking/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- /package/dist/js/treeshaking/builder/{share.js → shared/createCopyPattern.js} +0 -0
- /package/dist/js/treeshaking/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
|
@@ -38,25 +38,39 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
mod
|
|
39
39
|
));
|
|
40
40
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
-
var
|
|
42
|
-
__export(
|
|
43
|
-
|
|
41
|
+
var adapterModern_exports = {};
|
|
42
|
+
__export(adapterModern_exports, {
|
|
43
|
+
applyCallbacks: () => applyCallbacks,
|
|
44
|
+
builderPluginAdapterModern: () => builderPluginAdapterModern
|
|
44
45
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
46
|
-
var import_path = require("path");
|
|
46
|
+
module.exports = __toCommonJS(adapterModern_exports);
|
|
47
47
|
var import_builder_shared = require("@modern-js/builder-shared");
|
|
48
|
-
var import_lodash = require("@modern-js/utils/lodash");
|
|
49
|
-
var import_html_webpack_plugin = __toESM(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
|
|
50
48
|
var import_utils = require("@modern-js/utils");
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
const
|
|
56
|
-
|
|
49
|
+
var import_html_webpack_plugin = __toESM(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
|
|
50
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
51
|
+
var import_HtmlAsyncChunkPlugin = require("../bundlerPlugins/HtmlAsyncChunkPlugin");
|
|
52
|
+
var import_HtmlBottomTemplate = require("../bundlerPlugins/HtmlBottomTemplate");
|
|
53
|
+
const isStreamingSSR = (userConfig) => {
|
|
54
|
+
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
55
|
+
const { server } = userConfig;
|
|
56
|
+
if (isStreaming(server.ssr)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
60
|
+
for (const name of Object.keys(server.ssrByEntries)) {
|
|
61
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
const builderPluginAdapterModern = (options) => ({
|
|
69
|
+
name: "builder-plugin-adapter-modern",
|
|
57
70
|
setup(api) {
|
|
71
|
+
const { normalizedConfig, appContext } = options;
|
|
58
72
|
api.modifyBuilderConfig((config) => {
|
|
59
|
-
if (isStreamingSSR(
|
|
73
|
+
if (isStreamingSSR(normalizedConfig)) {
|
|
60
74
|
return (0, import_builder_shared.mergeBuilderConfig)(config, {
|
|
61
75
|
html: {
|
|
62
76
|
inject: "body"
|
|
@@ -65,71 +79,46 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
65
79
|
}
|
|
66
80
|
return config;
|
|
67
81
|
});
|
|
68
|
-
api.
|
|
69
|
-
|
|
70
|
-
const builderNormalizedConfig = api.getNormalizedConfig();
|
|
82
|
+
api.modifyBundlerChain((chain, { target, CHAIN_ID, isProd }) => {
|
|
83
|
+
const builderConfig = api.getNormalizedConfig();
|
|
71
84
|
if (target === "node") {
|
|
72
85
|
chain.name("server");
|
|
86
|
+
} else if (target === "service-worker") {
|
|
87
|
+
chain.name("service-worker");
|
|
88
|
+
} else if (target === "web-worker") {
|
|
89
|
+
chain.name("worker");
|
|
73
90
|
} else if (target === "modern-web") {
|
|
74
91
|
chain.name("modern");
|
|
75
92
|
} else {
|
|
76
93
|
chain.name("client");
|
|
77
94
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
applyNodeCompat(chain, modernConfig, isProd);
|
|
95
|
+
if (target === "node" || target === "service-worker") {
|
|
96
|
+
applyNodeCompat(target, chain, normalizedConfig, isProd);
|
|
81
97
|
}
|
|
82
|
-
if (isHtmlEnabled(
|
|
83
|
-
|
|
98
|
+
if (isHtmlEnabled(builderConfig, target)) {
|
|
99
|
+
applyBottomHtmlPlugin({
|
|
84
100
|
api,
|
|
85
101
|
chain,
|
|
86
|
-
|
|
102
|
+
modernConfig: normalizedConfig,
|
|
87
103
|
appContext,
|
|
88
|
-
|
|
104
|
+
CHAIN_ID
|
|
89
105
|
});
|
|
90
106
|
applyAsyncChunkHtmlPlugin({
|
|
91
107
|
chain,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
97
|
-
const defaultCopyPattern = (0, import_share.createCopyPattern)(
|
|
98
|
-
appContext,
|
|
99
|
-
modernConfig,
|
|
100
|
-
"public",
|
|
101
|
-
chain
|
|
102
|
-
);
|
|
103
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
104
|
-
var _a2;
|
|
105
|
-
return [
|
|
106
|
-
{
|
|
107
|
-
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
108
|
-
}
|
|
109
|
-
];
|
|
108
|
+
modernConfig: normalizedConfig,
|
|
109
|
+
CHAIN_ID
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
const existNestedRoutes = entrypoints.some(
|
|
114
|
-
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
115
|
-
);
|
|
116
|
-
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
117
|
-
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
118
|
-
if (existNestedRoutes || routerManifest) {
|
|
119
|
-
chain.plugin("route-plugin").use(import_routerPlugin.default);
|
|
120
|
-
}
|
|
121
|
-
if (target !== "node") {
|
|
112
|
+
if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
|
|
122
113
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
123
114
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
124
115
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
125
116
|
}
|
|
126
|
-
function isHtmlEnabled(config, target2) {
|
|
127
|
-
var _a2;
|
|
128
|
-
return ((_a2 = config.tools) == null ? void 0 : _a2.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
129
|
-
}
|
|
130
117
|
});
|
|
131
|
-
|
|
132
|
-
|
|
118
|
+
applyCallbacks(api, options);
|
|
119
|
+
function isHtmlEnabled(config, target) {
|
|
120
|
+
var _a;
|
|
121
|
+
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
133
122
|
}
|
|
134
123
|
}
|
|
135
124
|
});
|
|
@@ -143,8 +132,51 @@ function applyCallbacks(api, options) {
|
|
|
143
132
|
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
144
133
|
options.onExit && api.onExit(options.onExit);
|
|
145
134
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
135
|
+
function applyBottomHtmlPlugin({
|
|
136
|
+
api,
|
|
137
|
+
chain,
|
|
138
|
+
modernConfig,
|
|
139
|
+
appContext,
|
|
140
|
+
CHAIN_ID
|
|
141
|
+
}) {
|
|
142
|
+
for (const entryName of Object.keys(api.context.entry)) {
|
|
143
|
+
const baseTemplateParams = __spreadValues({
|
|
144
|
+
entryName,
|
|
145
|
+
title: (0, import_utils.getEntryOptions)(
|
|
146
|
+
entryName,
|
|
147
|
+
modernConfig.html.title,
|
|
148
|
+
modernConfig.html.titleByEntries,
|
|
149
|
+
appContext.packageName
|
|
150
|
+
),
|
|
151
|
+
mountId: modernConfig.html.mountId
|
|
152
|
+
}, (0, import_utils.getEntryOptions)(
|
|
153
|
+
entryName,
|
|
154
|
+
modernConfig.html.templateParameters,
|
|
155
|
+
modernConfig.html.templateParametersByEntries,
|
|
156
|
+
appContext.packageName
|
|
157
|
+
));
|
|
158
|
+
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
159
|
+
__spreadProps(__spreadValues({}, args[0] || {}), {
|
|
160
|
+
__internal__: true,
|
|
161
|
+
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
162
|
+
baseTemplateParams
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_HtmlBottomTemplate.BottomTemplatePlugin, [import_html_webpack_plugin.default]);
|
|
168
|
+
}
|
|
169
|
+
function applyAsyncChunkHtmlPlugin({
|
|
170
|
+
chain,
|
|
171
|
+
modernConfig,
|
|
172
|
+
CHAIN_ID
|
|
173
|
+
}) {
|
|
174
|
+
if (isStreamingSSR(modernConfig)) {
|
|
175
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_HtmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
179
|
+
const nodeExts = [
|
|
148
180
|
".node.js",
|
|
149
181
|
".node.jsx",
|
|
150
182
|
".node.ts",
|
|
@@ -153,9 +185,21 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
153
185
|
".server.ts",
|
|
154
186
|
".server.ts",
|
|
155
187
|
".server.tsx"
|
|
156
|
-
]
|
|
188
|
+
];
|
|
189
|
+
const webWorkerExts = [
|
|
190
|
+
".worker.js",
|
|
191
|
+
".worker.jsx",
|
|
192
|
+
".worker.ts",
|
|
193
|
+
".worker.tsx"
|
|
194
|
+
];
|
|
195
|
+
for (const ext of nodeExts) {
|
|
157
196
|
chain.resolve.extensions.prepend(ext);
|
|
158
197
|
}
|
|
198
|
+
if (target === "service-worker") {
|
|
199
|
+
for (const ext of webWorkerExts) {
|
|
200
|
+
chain.resolve.extensions.prepend(ext);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
159
203
|
filterEntriesBySSRConfig(
|
|
160
204
|
isProd,
|
|
161
205
|
chain,
|
|
@@ -194,65 +238,8 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
194
238
|
});
|
|
195
239
|
}
|
|
196
240
|
}
|
|
197
|
-
function applyBottomHtmlWebpackPlugin({
|
|
198
|
-
api,
|
|
199
|
-
chain,
|
|
200
|
-
modernConfig,
|
|
201
|
-
appContext,
|
|
202
|
-
CHAIN_ID
|
|
203
|
-
}) {
|
|
204
|
-
for (const entryName of Object.keys(api.context.entry)) {
|
|
205
|
-
const baseTemplateParams = __spreadValues({
|
|
206
|
-
entryName,
|
|
207
|
-
title: (0, import_utils.getEntryOptions)(
|
|
208
|
-
entryName,
|
|
209
|
-
modernConfig.html.title,
|
|
210
|
-
modernConfig.html.titleByEntries,
|
|
211
|
-
appContext.packageName
|
|
212
|
-
),
|
|
213
|
-
mountId: modernConfig.html.mountId
|
|
214
|
-
}, (0, import_utils.getEntryOptions)(
|
|
215
|
-
entryName,
|
|
216
|
-
modernConfig.html.templateParameters,
|
|
217
|
-
modernConfig.html.templateParametersByEntries,
|
|
218
|
-
appContext.packageName
|
|
219
|
-
));
|
|
220
|
-
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
221
|
-
__spreadProps(__spreadValues({}, args[0] || {}), {
|
|
222
|
-
__internal__: true,
|
|
223
|
-
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
224
|
-
baseTemplateParams
|
|
225
|
-
)
|
|
226
|
-
})
|
|
227
|
-
]);
|
|
228
|
-
}
|
|
229
|
-
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_htmlBottomTemplate.BottomTemplatePlugin, [import_html_webpack_plugin.default]);
|
|
230
|
-
}
|
|
231
|
-
const isStreamingSSR = (userConfig) => {
|
|
232
|
-
const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
233
|
-
const { server } = userConfig;
|
|
234
|
-
if (isStreaming(server.ssr)) {
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
238
|
-
for (const name of Object.keys(server.ssrByEntries)) {
|
|
239
|
-
if (isStreaming(server.ssrByEntries[name])) {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return false;
|
|
245
|
-
};
|
|
246
|
-
function applyAsyncChunkHtmlPlugin({
|
|
247
|
-
chain,
|
|
248
|
-
modernConfig,
|
|
249
|
-
CHAIN_ID
|
|
250
|
-
}) {
|
|
251
|
-
if (isStreamingSSR(modernConfig)) {
|
|
252
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_htmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
256
242
|
0 && (module.exports = {
|
|
257
|
-
|
|
243
|
+
applyCallbacks,
|
|
244
|
+
builderPluginAdapterModern
|
|
258
245
|
});
|
|
@@ -15,36 +15,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var HtmlAsyncChunkPlugin_exports = {};
|
|
19
|
+
__export(HtmlAsyncChunkPlugin_exports, {
|
|
20
20
|
HtmlAsyncChunkPlugin: () => HtmlAsyncChunkPlugin
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(HtmlAsyncChunkPlugin_exports);
|
|
23
23
|
class HtmlAsyncChunkPlugin {
|
|
24
24
|
constructor(htmlWebpackPlugin) {
|
|
25
25
|
this.name = "HtmlAsyncChunkPlugin";
|
|
26
26
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
27
27
|
}
|
|
28
28
|
apply(compiler) {
|
|
29
|
-
compiler.hooks.compilation.tap(
|
|
30
|
-
this.
|
|
31
|
-
(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
attributes.async = true;
|
|
40
|
-
delete attributes.defer;
|
|
41
|
-
}
|
|
29
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
30
|
+
const hooks = this.htmlWebpackPlugin.getHooks(compilation);
|
|
31
|
+
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
32
|
+
const tags = [...assets.headTags, ...assets.bodyTags];
|
|
33
|
+
for (const tag of tags) {
|
|
34
|
+
if (tag.tagName === "script") {
|
|
35
|
+
const { attributes } = tag;
|
|
36
|
+
if (attributes && attributes.defer === true) {
|
|
37
|
+
attributes.async = true;
|
|
38
|
+
delete attributes.defer;
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
);
|
|
41
|
+
}
|
|
42
|
+
return assets;
|
|
43
|
+
});
|
|
44
|
+
});
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var HtmlBottomTemplate_exports = {};
|
|
19
|
+
__export(HtmlBottomTemplate_exports, {
|
|
20
20
|
BottomTemplatePlugin: () => BottomTemplatePlugin
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(HtmlBottomTemplate_exports);
|
|
23
23
|
class BottomTemplatePlugin {
|
|
24
24
|
constructor(htmlWebpackPlugin) {
|
|
25
25
|
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
|
@@ -28,30 +28,27 @@ class BottomTemplatePlugin {
|
|
|
28
28
|
this.name = "bottom-template";
|
|
29
29
|
}
|
|
30
30
|
apply(compiler) {
|
|
31
|
-
compiler.hooks.compilation.tap(
|
|
32
|
-
this.name,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.bodyRegExp,
|
|
45
|
-
(match) => `
|
|
31
|
+
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
32
|
+
this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!((_a = data.plugin.options) == null ? void 0 : _a.__internal__)) {
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
if (this.bottomTemplateReg.test(data.html)) {
|
|
38
|
+
data.html = data.html.replace(this.bottomTemplateReg, "");
|
|
39
|
+
const { bottomTemplate } = data.plugin.options;
|
|
40
|
+
if (bottomTemplate) {
|
|
41
|
+
data.html = data.html.replace(
|
|
42
|
+
this.bodyRegExp,
|
|
43
|
+
(match) => `
|
|
46
44
|
${bottomTemplate}
|
|
47
45
|
${match}`
|
|
48
|
-
|
|
49
|
-
}
|
|
46
|
+
);
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
);
|
|
48
|
+
}
|
|
49
|
+
return data;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -21,11 +21,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var
|
|
25
|
-
__export(
|
|
24
|
+
var createCopyPattern_exports = {};
|
|
25
|
+
__export(createCopyPattern_exports, {
|
|
26
26
|
createCopyPattern: () => createCopyPattern
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(createCopyPattern_exports);
|
|
29
29
|
var import_path = __toESM(require("path"));
|
|
30
30
|
var import_utils = require("@modern-js/utils");
|
|
31
31
|
function createCopyPattern(appContext, config, patternsType, chain) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var shared_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(shared_exports);
|
|
17
|
+
__reExport(shared_exports, require("./createCopyPattern"), module.exports);
|
|
18
|
+
__reExport(shared_exports, require("./types"), module.exports);
|
|
19
|
+
__reExport(shared_exports, require("./builderPlugins/adapterModern"), module.exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -39,12 +39,11 @@ __export(default_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(default_exports);
|
|
41
41
|
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
|
42
|
-
function createDefaultConfig(appContext) {
|
|
42
|
+
function createDefaultConfig(appContext, bundler) {
|
|
43
43
|
const defaultBuilderConfig = (0, import_builder_webpack_provider.createDefaultConfig)();
|
|
44
44
|
const dev = __spreadProps(__spreadValues({}, defaultBuilderConfig.dev), {
|
|
45
45
|
port: void 0
|
|
46
46
|
});
|
|
47
|
-
const tools = __spreadValues({}, defaultBuilderConfig.tools);
|
|
48
47
|
const output = __spreadProps(__spreadValues({}, defaultBuilderConfig.output), {
|
|
49
48
|
disableNodePolyfill: true
|
|
50
49
|
});
|
|
@@ -82,6 +81,7 @@ function createDefaultConfig(appContext) {
|
|
|
82
81
|
baseUrl: "/",
|
|
83
82
|
port: 8080
|
|
84
83
|
};
|
|
84
|
+
const tools = bundler === "webpack" ? __spreadValues({}, defaultBuilderConfig.tools) : void 0;
|
|
85
85
|
return {
|
|
86
86
|
source,
|
|
87
87
|
output,
|
|
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
5
|
var __copyProps = (to, from, except, desc) => {
|
|
10
6
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
7
|
for (let key of __getOwnPropNames(from))
|
|
@@ -14,21 +10,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
10
|
}
|
|
15
11
|
return to;
|
|
16
12
|
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
15
|
var config_exports = {};
|
|
19
|
-
__export(config_exports, {
|
|
20
|
-
checkIsLegacyConfig: () => import_initial.checkIsLegacyConfig,
|
|
21
|
-
createDefaultConfig: () => import_default.createDefaultConfig,
|
|
22
|
-
createLegacyDefaultConfig: () => import_default.createLegacyDefaultConfig,
|
|
23
|
-
initialNormalizedConfig: () => import_initial.initialNormalizedConfig
|
|
24
|
-
});
|
|
25
16
|
module.exports = __toCommonJS(config_exports);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
0 && (module.exports = {
|
|
30
|
-
checkIsLegacyConfig,
|
|
31
|
-
createDefaultConfig,
|
|
32
|
-
createLegacyDefaultConfig,
|
|
33
|
-
initialNormalizedConfig
|
|
34
|
-
});
|
|
17
|
+
__reExport(config_exports, require("./legacy"), module.exports);
|
|
18
|
+
__reExport(config_exports, require("./initialize"), module.exports);
|
|
19
|
+
__reExport(config_exports, require("./default"), module.exports);
|
|
@@ -15,24 +15,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var initialize_exports = {};
|
|
19
|
+
__export(initialize_exports, {
|
|
20
|
+
initialNormalizedConfig: () => initialNormalizedConfig
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
22
|
+
module.exports = __toCommonJS(initialize_exports);
|
|
23
|
+
var import_inits = require("./inits");
|
|
24
|
+
function initialNormalizedConfig(config, appContext, bundler) {
|
|
25
|
+
(0, import_inits.initHtmlConfig)(config, appContext);
|
|
26
|
+
(0, import_inits.initSourceConfig)(config, appContext, bundler);
|
|
27
|
+
if (bundler === "webpack") {
|
|
28
|
+
(0, import_inits.initToolsConfig)(config);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
const code = `
|
|
32
|
-
export { default } from "${(0, import_utils.slash)(resourcePath)}";
|
|
33
|
-
`;
|
|
34
|
-
return code;
|
|
30
|
+
return config;
|
|
35
31
|
}
|
|
36
|
-
var routerLoader_default = loader;
|
|
37
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
initialNormalizedConfig
|
|
35
|
+
});
|
|
@@ -81,10 +81,12 @@ function initHtmlConfig(config, appContext) {
|
|
|
81
81
|
return favicon || defaultFavicon || void 0;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
function initSourceConfig(config, appContext) {
|
|
84
|
+
function initSourceConfig(config, appContext, bundler) {
|
|
85
85
|
config.source.include = createBuilderInclude(config, appContext);
|
|
86
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
87
86
|
config.source.globalVars = createBuilderGlobalVars(config, appContext);
|
|
87
|
+
if (bundler === "webpack") {
|
|
88
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
89
|
+
}
|
|
88
90
|
function createBuilderGlobalVars(config2, appContext2) {
|
|
89
91
|
const { globalVars = {} } = config2.source;
|
|
90
92
|
const publicEnv = (0, import_env.getAutoInjectEnv)(appContext2);
|
|
@@ -15,11 +15,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var legacy_exports = {};
|
|
19
|
+
__export(legacy_exports, {
|
|
20
|
+
checkIsLegacyConfig: () => checkIsLegacyConfig,
|
|
20
21
|
transformNormalizedConfig: () => transformNormalizedConfig
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(legacy_exports);
|
|
23
24
|
var import_createToolsConfig = require("./createToolsConfig");
|
|
24
25
|
var import_createSourceConfig = require("./createSourceConfig");
|
|
25
26
|
var import_createOutputConfig = require("./createOutputConfig");
|
|
@@ -64,7 +65,11 @@ function transformNormalizedConfig(config) {
|
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
}
|
|
68
|
+
function checkIsLegacyConfig(config) {
|
|
69
|
+
return Boolean(config.legacy);
|
|
70
|
+
}
|
|
67
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
72
|
0 && (module.exports = {
|
|
73
|
+
checkIsLegacyConfig,
|
|
69
74
|
transformNormalizedConfig
|
|
70
75
|
});
|