@modern-js/app-tools 2.8.1-alpha.0 → 2.8.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 +1 -3
- package/dist/cjs/analyze/index.js +0 -8
- package/dist/cjs/analyze/templates.js +14 -31
- package/dist/cjs/builder/index.js +2 -0
- package/dist/esm/analyze/generateCode.js +2 -3
- package/dist/esm/analyze/index.js +0 -8
- package/dist/esm/analyze/templates.js +16 -30
- package/dist/esm/builder/index.js +2 -0
- package/dist/esm-node/analyze/generateCode.js +1 -3
- package/dist/esm-node/analyze/index.js +0 -8
- package/dist/esm-node/analyze/templates.js +14 -31
- package/dist/esm-node/builder/index.js +2 -0
- 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/analyze/templates.d.ts +1 -3
- package/dist/types/types/config/output.d.ts +0 -1
- package/package.json +12 -12
- 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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var getBuilderTargets_exports = {};
|
|
19
|
+
__export(getBuilderTargets_exports, {
|
|
20
|
+
getBuilderTargets: () => getBuilderTargets
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(getBuilderTargets_exports);
|
|
23
|
+
var import_utils = require("@modern-js/utils");
|
|
24
|
+
function getBuilderTargets(normalizedConfig) {
|
|
25
|
+
const targets = ["web"];
|
|
26
|
+
const useNodeTarget = (0, import_utils.isProd)() ? (0, import_utils.isUseSSRBundle)(normalizedConfig) : (0, import_utils.isSSR)(normalizedConfig);
|
|
27
|
+
if (useNodeTarget) {
|
|
28
|
+
targets.push("node");
|
|
29
|
+
}
|
|
30
|
+
const useWorkerTarget = (0, import_utils.isProd)() ? (0, import_utils.isServiceWorker)(normalizedConfig) : false;
|
|
31
|
+
if (useWorkerTarget) {
|
|
32
|
+
targets.push("service-worker");
|
|
33
|
+
}
|
|
34
|
+
return targets;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
getBuilderTargets
|
|
39
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var generator_exports = {};
|
|
45
|
+
__export(generator_exports, {
|
|
46
|
+
generateBuilder: () => generateBuilder
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(generator_exports);
|
|
49
|
+
var import_builder = require("@modern-js/builder");
|
|
50
|
+
var import_createBuilderProviderConfig = require("./createBuilderProviderConfig");
|
|
51
|
+
var import_getBuilderTargets = require("./getBuilderTargets");
|
|
52
|
+
var import_createBuilderOptions = require("./createBuilderOptions");
|
|
53
|
+
function generateBuilder(options, generateProvider, utils) {
|
|
54
|
+
return __async(this, null, function* () {
|
|
55
|
+
const { normalizedConfig, appContext } = options;
|
|
56
|
+
const { modifyBuilderConfig, modifyBuilderInstance } = utils || {};
|
|
57
|
+
const builderConfig = (0, import_createBuilderProviderConfig.createBuilderProviderConfig)(
|
|
58
|
+
normalizedConfig,
|
|
59
|
+
appContext,
|
|
60
|
+
modifyBuilderConfig
|
|
61
|
+
);
|
|
62
|
+
const provider = generateProvider({
|
|
63
|
+
builderConfig
|
|
64
|
+
});
|
|
65
|
+
const target = (0, import_getBuilderTargets.getBuilderTargets)(normalizedConfig);
|
|
66
|
+
const builderOptions = (0, import_createBuilderOptions.createBuilderOptions)(target, appContext);
|
|
67
|
+
const builder = yield (0, import_builder.createBuilder)(provider, builderOptions);
|
|
68
|
+
yield applyBuilderPlugins(builder, options);
|
|
69
|
+
yield modifyBuilderInstance == null ? void 0 : modifyBuilderInstance(builder);
|
|
70
|
+
return builder;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function applyBuilderPlugins(builder, options) {
|
|
74
|
+
return __async(this, null, function* () {
|
|
75
|
+
const { builderPluginAdapterModern } = yield Promise.resolve().then(() => __toESM(require("../shared/builderPlugins/adapterModern")));
|
|
76
|
+
builder.addPlugins([builderPluginAdapterModern(options)]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
generateBuilder
|
|
82
|
+
});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -60,118 +43,26 @@ var __async = (__this, __arguments, generator) => {
|
|
|
60
43
|
};
|
|
61
44
|
var builder_exports = {};
|
|
62
45
|
__export(builder_exports, {
|
|
63
|
-
|
|
64
|
-
createBuilderOptions: () => createBuilderOptions,
|
|
65
|
-
createBuilderProviderConfig: () => createBuilderProviderConfig
|
|
46
|
+
createBuilderGenerator: () => createBuilderGenerator
|
|
66
47
|
});
|
|
67
48
|
module.exports = __toCommonJS(builder_exports);
|
|
68
|
-
|
|
69
|
-
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
|
70
|
-
var import_utils = require("@modern-js/utils");
|
|
71
|
-
var import_compatModern = require("./builderPlugins/compatModern");
|
|
72
|
-
var import_share = require("./share");
|
|
73
|
-
function getBuilderTargets(normalizedConfig) {
|
|
74
|
-
const targets = ["web"];
|
|
75
|
-
const useNodeTarget = (0, import_utils.isProd)() ? (0, import_utils.isUseSSRBundle)(normalizedConfig) : (0, import_utils.isSSR)(normalizedConfig);
|
|
76
|
-
if (useNodeTarget) {
|
|
77
|
-
targets.push("node");
|
|
78
|
-
}
|
|
79
|
-
return targets;
|
|
80
|
-
}
|
|
81
|
-
function createBuilderForModern(_0) {
|
|
82
|
-
return __async(this, arguments, function* ({
|
|
83
|
-
normalizedConfig,
|
|
84
|
-
appContext,
|
|
85
|
-
compatPluginConfig
|
|
86
|
-
}) {
|
|
87
|
-
const builderConfig = createBuilderProviderConfig(
|
|
88
|
-
normalizedConfig,
|
|
89
|
-
appContext
|
|
90
|
-
);
|
|
91
|
-
const webpackProvider = (0, import_builder_webpack_provider.builderWebpackProvider)({
|
|
92
|
-
builderConfig
|
|
93
|
-
});
|
|
94
|
-
const target = getBuilderTargets(normalizedConfig);
|
|
95
|
-
const builderOptions = createBuilderOptions(target, appContext);
|
|
96
|
-
const builder = yield (0, import_builder.createBuilder)(webpackProvider, builderOptions);
|
|
97
|
-
yield applyBuilderPlugins(
|
|
98
|
-
builder,
|
|
99
|
-
normalizedConfig,
|
|
100
|
-
appContext,
|
|
101
|
-
compatPluginConfig
|
|
102
|
-
);
|
|
103
|
-
return builder;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
107
|
-
const output = createOutputConfig(normalizedConfig, appContext);
|
|
108
|
-
const htmlConfig = __spreadValues({}, normalizedConfig.html);
|
|
109
|
-
if (!htmlConfig.template) {
|
|
110
|
-
htmlConfig.templateByEntries = __spreadValues(__spreadValues({}, htmlConfig.templateByEntries), appContext.htmlTemplates);
|
|
111
|
-
}
|
|
112
|
-
return __spreadProps(__spreadValues({}, normalizedConfig), {
|
|
113
|
-
output,
|
|
114
|
-
dev: __spreadProps(__spreadValues({}, normalizedConfig.dev), {
|
|
115
|
-
port: appContext.port
|
|
116
|
-
}),
|
|
117
|
-
html: htmlConfig
|
|
118
|
-
});
|
|
119
|
-
function createOutputConfig(config, appContext2) {
|
|
120
|
-
const defaultCopyPattern = (0, import_share.createCopyPattern)(appContext2, config, "upload");
|
|
121
|
-
const { copy } = config.output;
|
|
122
|
-
const copyOptions = Array.isArray(copy) ? copy : copy == null ? void 0 : copy.patterns;
|
|
123
|
-
const builderCopy = [...copyOptions || [], defaultCopyPattern];
|
|
124
|
-
return __spreadProps(__spreadValues({}, config.output), {
|
|
125
|
-
copy: builderCopy,
|
|
126
|
-
cleanDistPath: false
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function createBuilderOptions(target, appContext) {
|
|
131
|
-
const entries = {};
|
|
132
|
-
const { entrypoints = [], checkedEntries } = appContext;
|
|
133
|
-
for (const { entryName, entry } of entrypoints) {
|
|
134
|
-
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (entryName in entries) {
|
|
138
|
-
entries[entryName].push(entry);
|
|
139
|
-
} else {
|
|
140
|
-
entries[entryName] = [entry];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
cwd: appContext.appDirectory,
|
|
145
|
-
target,
|
|
146
|
-
configPath: appContext.configFile || void 0,
|
|
147
|
-
entry: entries,
|
|
148
|
-
framework: appContext.metaName
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function applyBuilderPlugins(builder, normalizedConfig, appContext, compatPluginConfig) {
|
|
49
|
+
function createBuilderGenerator(bundler) {
|
|
152
50
|
return __async(this, null, function* () {
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
loader: false,
|
|
163
|
-
minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
|
|
164
|
-
})
|
|
165
|
-
]);
|
|
51
|
+
if (bundler === "rspack") {
|
|
52
|
+
try {
|
|
53
|
+
const { createRspackBuilderForModern } = yield Promise.resolve().then(() => __toESM(require("./builder-rspack")));
|
|
54
|
+
return createRspackBuilderForModern;
|
|
55
|
+
} catch (_) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Failed to use rspack, please check if you have `@modern-js/builder-rspack-provider` installed"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
166
60
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
]);
|
|
61
|
+
const { createWebpackBuilderForModern } = yield Promise.resolve().then(() => __toESM(require("./builder-webpack")));
|
|
62
|
+
return createWebpackBuilderForModern;
|
|
170
63
|
});
|
|
171
64
|
}
|
|
172
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
173
66
|
0 && (module.exports = {
|
|
174
|
-
|
|
175
|
-
createBuilderOptions,
|
|
176
|
-
createBuilderProviderConfig
|
|
67
|
+
createBuilderGenerator
|
|
177
68
|
});
|
|
@@ -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:
|