@modern-js/app-tools 2.5.0-alpha.1 → 2.5.1-alpha.0
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 +15 -23
- package/dist/cjs/analyze/getBundleEntry.js +1 -1
- package/dist/cjs/analyze/index.js +0 -4
- package/dist/cjs/analyze/templates.js +1 -6
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
- package/dist/cjs/builder/builder-webpack/index.js +5 -11
- package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
- package/dist/cjs/commands/dev.js +14 -6
- package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm/analyze/generateCode.js +28 -40
- package/dist/esm/analyze/getBundleEntry.js +2 -2
- package/dist/esm/analyze/index.js +0 -1
- package/dist/esm/analyze/templates.js +2 -3
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm/builder/builder-webpack/index.js +7 -11
- package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm/commands/dev.js +8 -3
- package/dist/esm/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/analyze/generateCode.js +16 -24
- package/dist/esm-node/analyze/getBundleEntry.js +3 -2
- package/dist/esm-node/analyze/index.js +0 -4
- package/dist/esm-node/analyze/templates.js +1 -6
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm-node/builder/builder-webpack/index.js +6 -12
- package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm-node/commands/dev.js +14 -6
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/js/modern/analyze/constants.js +1 -3
- package/dist/js/modern/analyze/index.js +48 -45
- package/dist/js/modern/analyze/nestedRoutes.js +2 -22
- package/dist/js/modern/analyze/templates.js +9 -2
- package/dist/js/modern/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +111 -81
- package/dist/js/modern/builder/index.js +133 -13
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/modern/builder/{shared/createCopyPattern.js → share.js} +0 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
- package/dist/js/modern/config/default.js +2 -2
- package/dist/js/modern/config/index.js +8 -3
- package/dist/js/modern/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/modern/config/{legacy/index.js → initial/transformNormalizedConfig.js} +0 -4
- package/dist/js/modern/index.js +8 -18
- package/dist/js/modern/initialize/index.js +28 -36
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/node/analyze/constants.js +1 -3
- package/dist/js/node/analyze/index.js +49 -46
- package/dist/js/node/analyze/nestedRoutes.js +2 -22
- package/dist/js/node/analyze/templates.js +9 -2
- package/dist/js/node/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +115 -86
- package/dist/js/node/builder/index.js +123 -14
- package/dist/js/node/builder/{generator/getBuilderTargets.js → loaders/routerLoader.js} +16 -13
- package/dist/js/node/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/node/builder/{shared/createCopyPattern.js → share.js} +3 -3
- package/dist/js/node/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +20 -17
- package/dist/js/node/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +24 -21
- package/dist/js/node/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +5 -7
- package/dist/js/node/config/default.js +2 -2
- package/dist/js/node/config/index.js +19 -4
- package/dist/js/node/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/node/config/{initialize → initial}/index.js +16 -10
- package/dist/js/node/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/node/config/{legacy/index.js → initial/transformNormalizedConfig.js} +3 -8
- package/dist/js/node/index.js +8 -18
- package/dist/js/node/initialize/index.js +28 -35
- package/dist/js/node/locale/zh.js +1 -1
- package/dist/js/treeshaking/analyze/constants.js +1 -3
- package/dist/js/treeshaking/analyze/index.js +130 -135
- package/dist/js/treeshaking/analyze/nestedRoutes.js +1 -17
- package/dist/js/treeshaking/analyze/templates.js +7 -3
- package/dist/js/treeshaking/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +156 -103
- package/dist/js/treeshaking/builder/index.js +228 -29
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/treeshaking/builder/{shared/createCopyPattern.js → share.js} +0 -0
- package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +0 -0
- package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +0 -0
- package/dist/js/treeshaking/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
- package/dist/js/treeshaking/config/default.js +2 -2
- package/dist/js/treeshaking/config/index.js +3 -3
- package/dist/js/treeshaking/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/treeshaking/config/{legacy/index.js → initial/transformNormalizedConfig.js} +1 -4
- package/dist/js/treeshaking/index.js +12 -19
- package/dist/js/treeshaking/initialize/index.js +26 -34
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/types/analyze/templates.d.ts +1 -3
- package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
- package/package.json +14 -14
- package/dist/js/modern/builder/builder-rspack/index.js +0 -8
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -12
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
- package/dist/js/modern/builder/shared/index.js +0 -3
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/config/initialize/index.js +0 -12
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/node/builder/builder-rspack/index.js +0 -31
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/node/builder/builder-webpack/index.js +0 -118
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
- package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/builder/shared/index.js +0 -19
- package/dist/js/node/builder/shared/types.js +0 -15
- package/dist/js/node/types/utils.js +0 -15
- package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -12
- package/dist/js/treeshaking/builder/generator/index.js +0 -199
- package/dist/js/treeshaking/builder/shared/index.js +0 -3
- package/dist/js/treeshaking/builder/shared/types.js +0 -1
- package/dist/js/treeshaking/config/initialize/index.js +0 -10
- package/dist/js/treeshaking/types/utils.js +0 -1
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
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));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -43,26 +60,118 @@ var __async = (__this, __arguments, generator) => {
|
|
|
43
60
|
};
|
|
44
61
|
var builder_exports = {};
|
|
45
62
|
__export(builder_exports, {
|
|
46
|
-
|
|
63
|
+
createBuilderForModern: () => createBuilderForModern,
|
|
64
|
+
createBuilderOptions: () => createBuilderOptions,
|
|
65
|
+
createBuilderProviderConfig: () => createBuilderProviderConfig
|
|
47
66
|
});
|
|
48
67
|
module.exports = __toCommonJS(builder_exports);
|
|
49
|
-
|
|
68
|
+
var import_builder = require("@modern-js/builder");
|
|
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) {
|
|
50
152
|
return __async(this, null, function* () {
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
153
|
+
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
154
|
+
const { builderPluginNodePolyfill } = yield Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
|
155
|
+
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
156
|
+
}
|
|
157
|
+
if (normalizedConfig.tools.esbuild) {
|
|
158
|
+
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
159
|
+
const { builderPluginEsbuild } = yield Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
|
|
160
|
+
builder.addPlugins([
|
|
161
|
+
builderPluginEsbuild({
|
|
162
|
+
loader: false,
|
|
163
|
+
minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
|
|
164
|
+
})
|
|
165
|
+
]);
|
|
60
166
|
}
|
|
61
|
-
|
|
62
|
-
|
|
167
|
+
builder.addPlugins([
|
|
168
|
+
(0, import_compatModern.PluginCompatModern)(appContext, normalizedConfig, compatPluginConfig)
|
|
169
|
+
]);
|
|
63
170
|
});
|
|
64
171
|
}
|
|
65
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
173
|
0 && (module.exports = {
|
|
67
|
-
|
|
174
|
+
createBuilderForModern,
|
|
175
|
+
createBuilderOptions,
|
|
176
|
+
createBuilderProviderConfig
|
|
68
177
|
});
|
|
@@ -15,21 +15,24 @@ 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 routerLoader_exports = {};
|
|
19
|
+
__export(routerLoader_exports, {
|
|
20
|
+
default: () => routerLoader_default
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(routerLoader_exports);
|
|
23
23
|
var import_utils = require("@modern-js/utils");
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
24
|
+
function loader(source) {
|
|
25
|
+
this.cacheable();
|
|
26
|
+
const { target } = this._compiler.options;
|
|
27
|
+
if (target === "node" || Array.isArray(target) && target.includes("node")) {
|
|
28
|
+
return source;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const { resourcePath } = this;
|
|
31
|
+
const code = `
|
|
32
|
+
export { default } from "${(0, import_utils.slash)(resourcePath)}";
|
|
33
|
+
`;
|
|
34
|
+
return code;
|
|
31
35
|
}
|
|
36
|
+
var routerLoader_default = loader;
|
|
32
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
getBuilderTargets
|
|
35
|
-
});
|
|
38
|
+
0 && (module.exports = {});
|
|
File without changes
|
|
@@ -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 share_exports = {};
|
|
25
|
+
__export(share_exports, {
|
|
26
26
|
createCopyPattern: () => createCopyPattern
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(share_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) {
|
|
@@ -15,33 +15,36 @@ 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
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
attributes
|
|
38
|
-
|
|
29
|
+
compiler.hooks.compilation.tap(
|
|
30
|
+
this.name,
|
|
31
|
+
(compilation) => {
|
|
32
|
+
const hooks = this.htmlWebpackPlugin.getHooks(compilation);
|
|
33
|
+
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
34
|
+
const tags = [...assets.headTags, ...assets.bodyTags];
|
|
35
|
+
for (const tag of tags) {
|
|
36
|
+
if (tag.tagName === "script") {
|
|
37
|
+
const { attributes } = tag;
|
|
38
|
+
if (attributes && attributes.defer === true) {
|
|
39
|
+
attributes.async = true;
|
|
40
|
+
delete attributes.defer;
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
44
|
+
return assets;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
// 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,27 +28,30 @@ class BottomTemplatePlugin {
|
|
|
28
28
|
this.name = "bottom-template";
|
|
29
29
|
}
|
|
30
30
|
apply(compiler) {
|
|
31
|
-
compiler.hooks.compilation.tap(
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
compiler.hooks.compilation.tap(
|
|
32
|
+
this.name,
|
|
33
|
+
(compilation) => {
|
|
34
|
+
this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
|
|
35
|
+
var _a;
|
|
36
|
+
if (!((_a = data.plugin.options) == null ? void 0 : _a.__internal__)) {
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
if (this.bottomTemplateReg.test(data.html)) {
|
|
40
|
+
data.html = data.html.replace(this.bottomTemplateReg, "");
|
|
41
|
+
const { bottomTemplate } = data.plugin.options;
|
|
42
|
+
if (bottomTemplate) {
|
|
43
|
+
data.html = data.html.replace(
|
|
44
|
+
this.bodyRegExp,
|
|
45
|
+
(match) => `
|
|
44
46
|
${bottomTemplate}
|
|
45
47
|
${match}`
|
|
46
|
-
|
|
48
|
+
);
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
51
|
+
return data;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -41,11 +41,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
-
var
|
|
45
|
-
__export(
|
|
46
|
-
|
|
44
|
+
var routerPlugin_exports = {};
|
|
45
|
+
__export(routerPlugin_exports, {
|
|
46
|
+
default: () => RouterPlugin
|
|
47
47
|
});
|
|
48
|
-
module.exports = __toCommonJS(
|
|
48
|
+
module.exports = __toCommonJS(routerPlugin_exports);
|
|
49
49
|
var import_path = __toESM(require("path"));
|
|
50
50
|
var import_utils = require("@modern-js/utils");
|
|
51
51
|
const PLUGIN_NAME = "ModernjsRoutePlugin";
|
|
@@ -132,6 +132,4 @@ class RouterPlugin {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
-
0 && (module.exports = {
|
|
136
|
-
RouterPlugin
|
|
137
|
-
});
|
|
135
|
+
0 && (module.exports = {});
|
|
@@ -39,11 +39,12 @@ __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) {
|
|
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);
|
|
47
48
|
const output = __spreadProps(__spreadValues({}, defaultBuilderConfig.output), {
|
|
48
49
|
disableNodePolyfill: true
|
|
49
50
|
});
|
|
@@ -81,7 +82,6 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
81
82
|
baseUrl: "/",
|
|
82
83
|
port: 8080
|
|
83
84
|
};
|
|
84
|
-
const tools = bundler === "webpack" ? __spreadValues({}, defaultBuilderConfig.tools) : void 0;
|
|
85
85
|
return {
|
|
86
86
|
source,
|
|
87
87
|
output,
|
|
@@ -2,6 +2,10 @@ 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
|
+
};
|
|
5
9
|
var __copyProps = (to, from, except, desc) => {
|
|
6
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -10,10 +14,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
10
14
|
}
|
|
11
15
|
return to;
|
|
12
16
|
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
18
|
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
|
+
});
|
|
16
25
|
module.exports = __toCommonJS(config_exports);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
var import_default = require("./default");
|
|
27
|
+
var import_initial = require("./initial");
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
checkIsLegacyConfig,
|
|
31
|
+
createDefaultConfig,
|
|
32
|
+
createLegacyDefaultConfig,
|
|
33
|
+
initialNormalizedConfig
|
|
34
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -15,21 +15,27 @@ 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 initial_exports = {};
|
|
19
|
+
__export(initial_exports, {
|
|
20
|
+
checkIsLegacyConfig: () => checkIsLegacyConfig,
|
|
21
|
+
initialNormalizedConfig: () => initialNormalizedConfig,
|
|
22
|
+
transformNormalizedConfig: () => import_transformNormalizedConfig.transformNormalizedConfig
|
|
21
23
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(initial_exports);
|
|
23
25
|
var import_inits = require("./inits");
|
|
24
|
-
|
|
26
|
+
var import_transformNormalizedConfig = require("./transformNormalizedConfig");
|
|
27
|
+
function checkIsLegacyConfig(config) {
|
|
28
|
+
return Boolean(config.legacy);
|
|
29
|
+
}
|
|
30
|
+
function initialNormalizedConfig(config, appContext) {
|
|
25
31
|
(0, import_inits.initHtmlConfig)(config, appContext);
|
|
26
|
-
(0, import_inits.initSourceConfig)(config, appContext
|
|
27
|
-
|
|
28
|
-
(0, import_inits.initToolsConfig)(config);
|
|
29
|
-
}
|
|
32
|
+
(0, import_inits.initSourceConfig)(config, appContext);
|
|
33
|
+
(0, import_inits.initToolsConfig)(config);
|
|
30
34
|
return config;
|
|
31
35
|
}
|
|
32
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
37
|
0 && (module.exports = {
|
|
34
|
-
|
|
38
|
+
checkIsLegacyConfig,
|
|
39
|
+
initialNormalizedConfig,
|
|
40
|
+
transformNormalizedConfig
|
|
35
41
|
});
|
|
@@ -81,12 +81,10 @@ 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) {
|
|
85
85
|
config.source.include = createBuilderInclude(config, appContext);
|
|
86
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
86
87
|
config.source.globalVars = createBuilderGlobalVars(config, appContext);
|
|
87
|
-
if (bundler === "webpack") {
|
|
88
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
89
|
-
}
|
|
90
88
|
function createBuilderGlobalVars(config2, appContext2) {
|
|
91
89
|
const { globalVars = {} } = config2.source;
|
|
92
90
|
const publicEnv = (0, import_env.getAutoInjectEnv)(appContext2);
|
|
@@ -15,12 +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(
|
|
20
|
-
checkIsLegacyConfig: () => checkIsLegacyConfig,
|
|
18
|
+
var transformNormalizedConfig_exports = {};
|
|
19
|
+
__export(transformNormalizedConfig_exports, {
|
|
21
20
|
transformNormalizedConfig: () => transformNormalizedConfig
|
|
22
21
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(transformNormalizedConfig_exports);
|
|
24
23
|
var import_createToolsConfig = require("./createToolsConfig");
|
|
25
24
|
var import_createSourceConfig = require("./createSourceConfig");
|
|
26
25
|
var import_createOutputConfig = require("./createOutputConfig");
|
|
@@ -65,11 +64,7 @@ function transformNormalizedConfig(config) {
|
|
|
65
64
|
}
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
function checkIsLegacyConfig(config) {
|
|
69
|
-
return Boolean(config.legacy);
|
|
70
|
-
}
|
|
71
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
68
|
0 && (module.exports = {
|
|
73
|
-
checkIsLegacyConfig,
|
|
74
69
|
transformNormalizedConfig
|
|
75
70
|
});
|
package/dist/js/node/index.js
CHANGED
|
@@ -127,9 +127,7 @@ const buildCommand = (program, api) => __async(void 0, null, function* () {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
-
var src_default = (
|
|
131
|
-
bundler: "webpack"
|
|
132
|
-
}) => ({
|
|
130
|
+
var src_default = () => ({
|
|
133
131
|
name: "@modern-js/app-tools",
|
|
134
132
|
post: [
|
|
135
133
|
"@modern-js/plugin-initialize",
|
|
@@ -142,15 +140,7 @@ var src_default = (options = {
|
|
|
142
140
|
"@modern-js/plugin-polyfill"
|
|
143
141
|
],
|
|
144
142
|
registerHook: import_hooks.hooks,
|
|
145
|
-
usePlugins: [
|
|
146
|
-
(0, import_initialize.default)({
|
|
147
|
-
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
148
|
-
}),
|
|
149
|
-
(0, import_analyze.default)({
|
|
150
|
-
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
151
|
-
}),
|
|
152
|
-
(0, import_plugin_lint.default)()
|
|
153
|
-
],
|
|
143
|
+
usePlugins: [(0, import_initialize.default)(), (0, import_analyze.default)(), (0, import_plugin_lint.default)()],
|
|
154
144
|
setup: (api) => {
|
|
155
145
|
const locale = (0, import_language.getLocaleLanguage)();
|
|
156
146
|
import_locale.i18n.changeLanguage({ locale });
|
|
@@ -169,19 +159,19 @@ var src_default = (options = {
|
|
|
169
159
|
program.command("deploy").usage("[options]").option(
|
|
170
160
|
"-c --config <config>",
|
|
171
161
|
import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
|
|
172
|
-
).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action((
|
|
162
|
+
).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action((options) => __async(this, null, function* () {
|
|
173
163
|
const { build } = yield Promise.resolve().then(() => __toESM(require("./commands/build")));
|
|
174
164
|
yield build(api);
|
|
175
165
|
const { deploy } = yield Promise.resolve().then(() => __toESM(require("./commands/deploy")));
|
|
176
|
-
yield deploy(api,
|
|
166
|
+
yield deploy(api, options);
|
|
177
167
|
process.exit(0);
|
|
178
168
|
}));
|
|
179
169
|
program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("--lang <lang>", import_locale.i18n.t(import_locale.localeKeys.command.new.lang)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option(
|
|
180
170
|
"-c, --config <config>",
|
|
181
171
|
import_locale.i18n.t(import_locale.localeKeys.command.new.config)
|
|
182
|
-
).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).action((
|
|
172
|
+
).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).action((options) => __async(this, null, function* () {
|
|
183
173
|
const { MWANewAction } = yield Promise.resolve().then(() => __toESM(require("@modern-js/new-action")));
|
|
184
|
-
yield MWANewAction(__spreadProps(__spreadValues({},
|
|
174
|
+
yield MWANewAction(__spreadProps(__spreadValues({}, options), { locale: options.lang || locale }));
|
|
185
175
|
}));
|
|
186
176
|
program.command("inspect").description("inspect internal webpack config").option(
|
|
187
177
|
`--env <env>`,
|
|
@@ -194,9 +184,9 @@ var src_default = (options = {
|
|
|
194
184
|
).option("--verbose", import_locale.i18n.t(import_locale.localeKeys.command.inspect.verbose)).option(
|
|
195
185
|
"-c --config <config>",
|
|
196
186
|
import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
|
|
197
|
-
).action((
|
|
187
|
+
).action((options) => __async(this, null, function* () {
|
|
198
188
|
const { inspect } = yield Promise.resolve().then(() => __toESM(require("./commands/inspect")));
|
|
199
|
-
inspect(api,
|
|
189
|
+
inspect(api, options);
|
|
200
190
|
}));
|
|
201
191
|
upgradeModel.defineCommand(program.command("upgrade"));
|
|
202
192
|
});
|