@modern-js/app-tools 2.3.1-alpha.2 → 3.0.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +87 -0
- package/README.md +14 -18
- package/dist/js/modern/analyze/getServerRoutes.js +5 -2
- package/dist/js/modern/analyze/index.js +47 -46
- 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/{share.js → shared/createCopyPattern.js} +0 -0
- package/dist/js/modern/builder/shared/index.js +3 -0
- package/dist/js/modern/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -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 → 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/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/getServerRoutes.js +3 -1
- package/dist/js/node/analyze/index.js +48 -47
- package/dist/js/node/builder/builder-rspack/index.js +31 -0
- 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/{loaders → shared/loaders}/serverModuleLoader.js +0 -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/config/{initial → initialize}/index.js +10 -16
- package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
- 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/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/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 +5 -5
- package/dist/js/treeshaking/analyze/templates.js +6 -6
- 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/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
- package/dist/js/treeshaking/builder/{share.js → shared/createCopyPattern.js} +0 -0
- package/dist/js/treeshaking/builder/shared/index.js +3 -0
- package/dist/js/treeshaking/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -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/generateCode.d.ts +1 -1
- package/dist/types/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
- package/dist/types/analyze/getServerRoutes.d.ts +1 -1
- package/dist/types/analyze/index.d.ts +5 -1
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +4 -0
- package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
- package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
- package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
- package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
- package/dist/types/builder/generator/index.d.ts +17 -0
- package/dist/types/builder/index.d.ts +1 -18
- package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
- package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
- package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
- package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
- package/dist/types/builder/shared/types.d.ts +16 -0
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/deploy.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/commands/serve.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/index.d.ts +3 -2
- package/dist/types/config/initialize/index.d.ts +2 -0
- package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
- package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
- package/dist/types/config/legacy/index.d.ts +3 -0
- package/dist/types/defineConfig.d.ts +2 -2
- package/dist/types/index.d.ts +7 -3
- package/dist/types/initialize/index.d.ts +6 -2
- package/dist/types/types/config/deploy.d.ts +1 -2
- package/dist/types/types/config/dev.d.ts +2 -3
- package/dist/types/types/config/experiments.d.ts +1 -2
- package/dist/types/types/config/html.d.ts +5 -3
- package/dist/types/types/config/index.d.ts +41 -48
- package/dist/types/types/config/output.d.ts +8 -3
- package/dist/types/types/config/performance.d.ts +6 -3
- package/dist/types/types/config/security.d.ts +3 -3
- package/dist/types/types/config/source.d.ts +7 -3
- package/dist/types/types/config/tools.d.ts +10 -4
- package/dist/types/types/hooks.d.ts +6 -4
- package/dist/types/types/index.d.ts +19 -7
- package/dist/types/types/utils.d.ts +7 -0
- package/dist/types/utils/config.d.ts +1 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/package.json +34 -25
- 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/config/initial/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
- package/dist/types/config/initial/index.d.ts +0 -4
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -0,0 +1,301 @@
|
|
1
|
+
function _arrayLikeToArray(arr, len) {
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
4
|
+
return arr2;
|
5
|
+
}
|
6
|
+
function _arrayWithoutHoles(arr) {
|
7
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
8
|
+
}
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
10
|
+
try {
|
11
|
+
var info = gen[key](arg);
|
12
|
+
var value = info.value;
|
13
|
+
} catch (error) {
|
14
|
+
reject(error);
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
if (info.done) {
|
18
|
+
resolve(value);
|
19
|
+
} else {
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
function _asyncToGenerator(fn) {
|
24
|
+
return function() {
|
25
|
+
var self = this, args = arguments;
|
26
|
+
return new Promise(function(resolve, reject) {
|
27
|
+
var gen = fn.apply(self, args);
|
28
|
+
function _next(value) {
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
30
|
+
}
|
31
|
+
function _throw(err) {
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
33
|
+
}
|
34
|
+
_next(undefined);
|
35
|
+
});
|
36
|
+
};
|
37
|
+
}
|
38
|
+
function _defineProperty(obj, key, value) {
|
39
|
+
if (key in obj) {
|
40
|
+
Object.defineProperty(obj, key, {
|
41
|
+
value: value,
|
42
|
+
enumerable: true,
|
43
|
+
configurable: true,
|
44
|
+
writable: true
|
45
|
+
});
|
46
|
+
} else {
|
47
|
+
obj[key] = value;
|
48
|
+
}
|
49
|
+
return obj;
|
50
|
+
}
|
51
|
+
function _iterableToArray(iter) {
|
52
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
53
|
+
}
|
54
|
+
function _nonIterableSpread() {
|
55
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
56
|
+
}
|
57
|
+
function _objectSpread(target) {
|
58
|
+
for(var i = 1; i < arguments.length; i++){
|
59
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
60
|
+
var ownKeys = Object.keys(source);
|
61
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
62
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
63
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
64
|
+
}));
|
65
|
+
}
|
66
|
+
ownKeys.forEach(function(key) {
|
67
|
+
_defineProperty(target, key, source[key]);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
return target;
|
71
|
+
}
|
72
|
+
function ownKeys(object, enumerableOnly) {
|
73
|
+
var keys = Object.keys(object);
|
74
|
+
if (Object.getOwnPropertySymbols) {
|
75
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
76
|
+
if (enumerableOnly) {
|
77
|
+
symbols = symbols.filter(function(sym) {
|
78
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
79
|
+
});
|
80
|
+
}
|
81
|
+
keys.push.apply(keys, symbols);
|
82
|
+
}
|
83
|
+
return keys;
|
84
|
+
}
|
85
|
+
function _objectSpreadProps(target, source) {
|
86
|
+
source = source != null ? source : {};
|
87
|
+
if (Object.getOwnPropertyDescriptors) {
|
88
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
89
|
+
} else {
|
90
|
+
ownKeys(Object(source)).forEach(function(key) {
|
91
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
92
|
+
});
|
93
|
+
}
|
94
|
+
return target;
|
95
|
+
}
|
96
|
+
function _toConsumableArray(arr) {
|
97
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
98
|
+
}
|
99
|
+
function _unsupportedIterableToArray(o, minLen) {
|
100
|
+
if (!o) return;
|
101
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
102
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
103
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
104
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
105
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
106
|
+
}
|
107
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
108
|
+
var f, y, t, g, _ = {
|
109
|
+
label: 0,
|
110
|
+
sent: function() {
|
111
|
+
if (t[0] & 1) throw t[1];
|
112
|
+
return t[1];
|
113
|
+
},
|
114
|
+
trys: [],
|
115
|
+
ops: []
|
116
|
+
};
|
117
|
+
return g = {
|
118
|
+
next: verb(0),
|
119
|
+
"throw": verb(1),
|
120
|
+
"return": verb(2)
|
121
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
122
|
+
return this;
|
123
|
+
}), g;
|
124
|
+
function verb(n) {
|
125
|
+
return function(v) {
|
126
|
+
return step([
|
127
|
+
n,
|
128
|
+
v
|
129
|
+
]);
|
130
|
+
};
|
131
|
+
}
|
132
|
+
function step(op) {
|
133
|
+
if (f) throw new TypeError("Generator is already executing.");
|
134
|
+
while(_)try {
|
135
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
136
|
+
if (y = 0, t) op = [
|
137
|
+
op[0] & 2,
|
138
|
+
t.value
|
139
|
+
];
|
140
|
+
switch(op[0]){
|
141
|
+
case 0:
|
142
|
+
case 1:
|
143
|
+
t = op;
|
144
|
+
break;
|
145
|
+
case 4:
|
146
|
+
_.label++;
|
147
|
+
return {
|
148
|
+
value: op[1],
|
149
|
+
done: false
|
150
|
+
};
|
151
|
+
case 5:
|
152
|
+
_.label++;
|
153
|
+
y = op[1];
|
154
|
+
op = [
|
155
|
+
0
|
156
|
+
];
|
157
|
+
continue;
|
158
|
+
case 7:
|
159
|
+
op = _.ops.pop();
|
160
|
+
_.trys.pop();
|
161
|
+
continue;
|
162
|
+
default:
|
163
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
164
|
+
_ = 0;
|
165
|
+
continue;
|
166
|
+
}
|
167
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
168
|
+
_.label = op[1];
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
if (op[0] === 6 && _.label < t[1]) {
|
172
|
+
_.label = t[1];
|
173
|
+
t = op;
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
if (t && _.label < t[2]) {
|
177
|
+
_.label = t[2];
|
178
|
+
_.ops.push(op);
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
if (t[2]) _.ops.pop();
|
182
|
+
_.trys.pop();
|
183
|
+
continue;
|
184
|
+
}
|
185
|
+
op = body.call(thisArg, _);
|
186
|
+
} catch (e) {
|
187
|
+
op = [
|
188
|
+
6,
|
189
|
+
e
|
190
|
+
];
|
191
|
+
y = 0;
|
192
|
+
} finally{
|
193
|
+
f = t = 0;
|
194
|
+
}
|
195
|
+
if (op[0] & 5) throw op[1];
|
196
|
+
return {
|
197
|
+
value: op[0] ? op[1] : void 0,
|
198
|
+
done: true
|
199
|
+
};
|
200
|
+
}
|
201
|
+
};
|
202
|
+
import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
|
203
|
+
import { applyOptionsChain } from "@modern-js/utils";
|
204
|
+
import { createCopyPattern } from "../shared";
|
205
|
+
import { generateBuilder } from "../generator";
|
206
|
+
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
207
|
+
function createWebpackBuilderForModern(options) {
|
208
|
+
return generateBuilder(options, builderWebpackProvider, {
|
209
|
+
modifyBuilderConfig: function modifyBuilderConfig(config) {
|
210
|
+
modifyOutputConfig(config, options.appContext);
|
211
|
+
},
|
212
|
+
modifyBuilderInstance: function modifyBuilderInstance(builder) {
|
213
|
+
return _asyncToGenerator(function() {
|
214
|
+
return __generator(this, function(_state) {
|
215
|
+
switch(_state.label){
|
216
|
+
case 0:
|
217
|
+
return [
|
218
|
+
4,
|
219
|
+
applyBuilderPlugins(builder, options)
|
220
|
+
];
|
221
|
+
case 1:
|
222
|
+
_state.sent();
|
223
|
+
return [
|
224
|
+
2
|
225
|
+
];
|
226
|
+
}
|
227
|
+
});
|
228
|
+
})();
|
229
|
+
}
|
230
|
+
});
|
231
|
+
}
|
232
|
+
function modifyOutputConfig(config, appContext) {
|
233
|
+
var createOutputConfig = function createOutputConfig(config2, appContext2) {
|
234
|
+
var defaultCopyPattern = createCopyPattern(appContext2, config2, "upload");
|
235
|
+
var copy = config2.output.copy;
|
236
|
+
var copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
|
237
|
+
var builderCopy = _toConsumableArray(copyOptions || []).concat([
|
238
|
+
defaultCopyPattern
|
239
|
+
]);
|
240
|
+
return _objectSpreadProps(_objectSpread({}, config2.output), {
|
241
|
+
copy: builderCopy
|
242
|
+
});
|
243
|
+
};
|
244
|
+
config.output = createOutputConfig(config, appContext);
|
245
|
+
}
|
246
|
+
function applyBuilderPlugins(builder, options) {
|
247
|
+
return _applyBuilderPlugins.apply(this, arguments);
|
248
|
+
}
|
249
|
+
function _applyBuilderPlugins() {
|
250
|
+
_applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
|
251
|
+
var normalizedConfig, PluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, PluginEsbuild;
|
252
|
+
return __generator(this, function(_state) {
|
253
|
+
switch(_state.label){
|
254
|
+
case 0:
|
255
|
+
normalizedConfig = options.normalizedConfig;
|
256
|
+
if (!!normalizedConfig.output.disableNodePolyfill) return [
|
257
|
+
3,
|
258
|
+
2
|
259
|
+
];
|
260
|
+
return [
|
261
|
+
4,
|
262
|
+
import("@modern-js/builder-plugin-node-polyfill")
|
263
|
+
];
|
264
|
+
case 1:
|
265
|
+
PluginNodePolyfill = _state.sent().PluginNodePolyfill;
|
266
|
+
builder.addPlugins([
|
267
|
+
PluginNodePolyfill()
|
268
|
+
]);
|
269
|
+
_state.label = 2;
|
270
|
+
case 2:
|
271
|
+
if (!normalizedConfig.tools.esbuild) return [
|
272
|
+
3,
|
273
|
+
4
|
274
|
+
];
|
275
|
+
_normalizedConfig_tools = normalizedConfig.tools, esbuildOptions = _normalizedConfig_tools.esbuild;
|
276
|
+
return [
|
277
|
+
4,
|
278
|
+
import("@modern-js/builder-plugin-esbuild")
|
279
|
+
];
|
280
|
+
case 3:
|
281
|
+
PluginEsbuild = _state.sent().PluginEsbuild;
|
282
|
+
builder.addPlugins([
|
283
|
+
PluginEsbuild({
|
284
|
+
loader: false,
|
285
|
+
minimize: applyOptionsChain({}, esbuildOptions)
|
286
|
+
})
|
287
|
+
]);
|
288
|
+
_state.label = 4;
|
289
|
+
case 4:
|
290
|
+
builder.addPlugins([
|
291
|
+
PluginCompatModern(options)
|
292
|
+
]);
|
293
|
+
return [
|
294
|
+
2
|
295
|
+
];
|
296
|
+
}
|
297
|
+
});
|
298
|
+
});
|
299
|
+
return _applyBuilderPlugins.apply(this, arguments);
|
300
|
+
}
|
301
|
+
export { createWebpackBuilderForModern };
|
@@ -215,6 +215,9 @@ var RouterPlugin = /*#__PURE__*/ function() {
|
|
215
215
|
if (target === "node" || Array.isArray(target) && target.includes("node")) {
|
216
216
|
return;
|
217
217
|
}
|
218
|
+
if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
|
219
|
+
return;
|
220
|
+
}
|
218
221
|
var webpack = compiler.webpack;
|
219
222
|
var Compilation = webpack.Compilation, sources = webpack.sources;
|
220
223
|
var RawSource = sources.RawSource;
|
@@ -232,7 +235,7 @@ var RouterPlugin = /*#__PURE__*/ function() {
|
|
232
235
|
name: PLUGIN_NAME,
|
233
236
|
stage: PROCESS_ASSETS_STAGE_REPORT
|
234
237
|
}, /*#__PURE__*/ _asyncToGenerator(function() {
|
235
|
-
var stats, publicPath, routeAssets, namedChunkGroups, assetsByChunkName, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
238
|
+
var stats, publicPath, routeAssets, namedChunkGroups, assetsByChunkName, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
|
236
239
|
return __generator(this, function(_state) {
|
237
240
|
switch(_state.label){
|
238
241
|
case 0:
|
@@ -252,7 +255,7 @@ var RouterPlugin = /*#__PURE__*/ function() {
|
|
252
255
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
253
256
|
try {
|
254
257
|
for(_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
255
|
-
|
258
|
+
_step_value = _slicedToArray(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
|
256
259
|
if (assetsByChunkName[name]) {
|
257
260
|
routeAssets[name] = {
|
258
261
|
chunkIds: chunkGroup.chunks,
|
@@ -340,4 +343,4 @@ var RouterPlugin = /*#__PURE__*/ function() {
|
|
340
343
|
]);
|
341
344
|
return RouterPlugin;
|
342
345
|
}();
|
343
|
-
export { RouterPlugin
|
346
|
+
export { RouterPlugin };
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./RouterPlugin";
|
@@ -0,0 +1,41 @@
|
|
1
|
+
function createBuilderOptions(target, appContext) {
|
2
|
+
var entries = {};
|
3
|
+
var _appContext_entrypoints = appContext.entrypoints, entrypoints = _appContext_entrypoints === void 0 ? [] : _appContext_entrypoints, checkedEntries = appContext.checkedEntries;
|
4
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
5
|
+
try {
|
6
|
+
for(var _iterator = entrypoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
7
|
+
var _step_value = _step.value, entryName = _step_value.entryName, entry = _step_value.entry;
|
8
|
+
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
9
|
+
continue;
|
10
|
+
}
|
11
|
+
if (entryName in entries) {
|
12
|
+
entries[entryName].push(entry);
|
13
|
+
} else {
|
14
|
+
entries[entryName] = [
|
15
|
+
entry
|
16
|
+
];
|
17
|
+
}
|
18
|
+
}
|
19
|
+
} catch (err) {
|
20
|
+
_didIteratorError = true;
|
21
|
+
_iteratorError = err;
|
22
|
+
} finally{
|
23
|
+
try {
|
24
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
25
|
+
_iterator.return();
|
26
|
+
}
|
27
|
+
} finally{
|
28
|
+
if (_didIteratorError) {
|
29
|
+
throw _iteratorError;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return {
|
34
|
+
cwd: appContext.appDirectory,
|
35
|
+
target: target,
|
36
|
+
configPath: appContext.configFile || void 0,
|
37
|
+
entry: entries,
|
38
|
+
framework: appContext.metaName
|
39
|
+
};
|
40
|
+
}
|
41
|
+
export { createBuilderOptions };
|
@@ -0,0 +1,70 @@
|
|
1
|
+
function _defineProperty(obj, key, value) {
|
2
|
+
if (key in obj) {
|
3
|
+
Object.defineProperty(obj, key, {
|
4
|
+
value: value,
|
5
|
+
enumerable: true,
|
6
|
+
configurable: true,
|
7
|
+
writable: true
|
8
|
+
});
|
9
|
+
} else {
|
10
|
+
obj[key] = value;
|
11
|
+
}
|
12
|
+
return obj;
|
13
|
+
}
|
14
|
+
function _objectSpread(target) {
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
17
|
+
var ownKeys = Object.keys(source);
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
21
|
+
}));
|
22
|
+
}
|
23
|
+
ownKeys.forEach(function(key) {
|
24
|
+
_defineProperty(target, key, source[key]);
|
25
|
+
});
|
26
|
+
}
|
27
|
+
return target;
|
28
|
+
}
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
30
|
+
var keys = Object.keys(object);
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
33
|
+
if (enumerableOnly) {
|
34
|
+
symbols = symbols.filter(function(sym) {
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
36
|
+
});
|
37
|
+
}
|
38
|
+
keys.push.apply(keys, symbols);
|
39
|
+
}
|
40
|
+
return keys;
|
41
|
+
}
|
42
|
+
function _objectSpreadProps(target, source) {
|
43
|
+
source = source != null ? source : {};
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
46
|
+
} else {
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
49
|
+
});
|
50
|
+
}
|
51
|
+
return target;
|
52
|
+
}
|
53
|
+
function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderConfig) {
|
54
|
+
var htmlConfig = _objectSpread({}, resolveConfig.html);
|
55
|
+
if (!htmlConfig.template) {
|
56
|
+
htmlConfig.templateByEntries = _objectSpread({}, htmlConfig.templateByEntries, appContext.htmlTemplates);
|
57
|
+
}
|
58
|
+
var config = _objectSpreadProps(_objectSpread({}, resolveConfig), {
|
59
|
+
dev: _objectSpreadProps(_objectSpread({}, resolveConfig.dev), {
|
60
|
+
port: appContext.port
|
61
|
+
}),
|
62
|
+
html: htmlConfig,
|
63
|
+
output: _objectSpreadProps(_objectSpread({}, resolveConfig.output), {
|
64
|
+
cleanDistPath: false
|
65
|
+
})
|
66
|
+
});
|
67
|
+
modifyBuilderConfig === null || modifyBuilderConfig === void 0 ? void 0 : modifyBuilderConfig(config);
|
68
|
+
return config;
|
69
|
+
}
|
70
|
+
export { createBuilderProviderConfig };
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
|
2
|
+
function getBuilderTargets(normalizedConfig) {
|
3
|
+
var targets = [
|
4
|
+
"web"
|
5
|
+
];
|
6
|
+
var useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
7
|
+
if (useNodeTarget) {
|
8
|
+
targets.push("node");
|
9
|
+
}
|
10
|
+
var useWorkerTarget = isProd() ? isServiceWorker(normalizedConfig) : false;
|
11
|
+
if (useWorkerTarget) {
|
12
|
+
targets.push("service-worker");
|
13
|
+
}
|
14
|
+
return targets;
|
15
|
+
}
|
16
|
+
export { getBuilderTargets };
|
@@ -0,0 +1,199 @@
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
2
|
+
try {
|
3
|
+
var info = gen[key](arg);
|
4
|
+
var value = info.value;
|
5
|
+
} catch (error) {
|
6
|
+
reject(error);
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
if (info.done) {
|
10
|
+
resolve(value);
|
11
|
+
} else {
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
function _asyncToGenerator(fn) {
|
16
|
+
return function() {
|
17
|
+
var self = this, args = arguments;
|
18
|
+
return new Promise(function(resolve, reject) {
|
19
|
+
var gen = fn.apply(self, args);
|
20
|
+
function _next(value) {
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
22
|
+
}
|
23
|
+
function _throw(err) {
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
25
|
+
}
|
26
|
+
_next(undefined);
|
27
|
+
});
|
28
|
+
};
|
29
|
+
}
|
30
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
31
|
+
var f, y, t, g, _ = {
|
32
|
+
label: 0,
|
33
|
+
sent: function() {
|
34
|
+
if (t[0] & 1) throw t[1];
|
35
|
+
return t[1];
|
36
|
+
},
|
37
|
+
trys: [],
|
38
|
+
ops: []
|
39
|
+
};
|
40
|
+
return g = {
|
41
|
+
next: verb(0),
|
42
|
+
"throw": verb(1),
|
43
|
+
"return": verb(2)
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
45
|
+
return this;
|
46
|
+
}), g;
|
47
|
+
function verb(n) {
|
48
|
+
return function(v) {
|
49
|
+
return step([
|
50
|
+
n,
|
51
|
+
v
|
52
|
+
]);
|
53
|
+
};
|
54
|
+
}
|
55
|
+
function step(op) {
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
57
|
+
while(_)try {
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
59
|
+
if (y = 0, t) op = [
|
60
|
+
op[0] & 2,
|
61
|
+
t.value
|
62
|
+
];
|
63
|
+
switch(op[0]){
|
64
|
+
case 0:
|
65
|
+
case 1:
|
66
|
+
t = op;
|
67
|
+
break;
|
68
|
+
case 4:
|
69
|
+
_.label++;
|
70
|
+
return {
|
71
|
+
value: op[1],
|
72
|
+
done: false
|
73
|
+
};
|
74
|
+
case 5:
|
75
|
+
_.label++;
|
76
|
+
y = op[1];
|
77
|
+
op = [
|
78
|
+
0
|
79
|
+
];
|
80
|
+
continue;
|
81
|
+
case 7:
|
82
|
+
op = _.ops.pop();
|
83
|
+
_.trys.pop();
|
84
|
+
continue;
|
85
|
+
default:
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
87
|
+
_ = 0;
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
91
|
+
_.label = op[1];
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
95
|
+
_.label = t[1];
|
96
|
+
t = op;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
if (t && _.label < t[2]) {
|
100
|
+
_.label = t[2];
|
101
|
+
_.ops.push(op);
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
if (t[2]) _.ops.pop();
|
105
|
+
_.trys.pop();
|
106
|
+
continue;
|
107
|
+
}
|
108
|
+
op = body.call(thisArg, _);
|
109
|
+
} catch (e) {
|
110
|
+
op = [
|
111
|
+
6,
|
112
|
+
e
|
113
|
+
];
|
114
|
+
y = 0;
|
115
|
+
} finally{
|
116
|
+
f = t = 0;
|
117
|
+
}
|
118
|
+
if (op[0] & 5) throw op[1];
|
119
|
+
return {
|
120
|
+
value: op[0] ? op[1] : void 0,
|
121
|
+
done: true
|
122
|
+
};
|
123
|
+
}
|
124
|
+
};
|
125
|
+
import { createBuilder } from "@modern-js/builder";
|
126
|
+
import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
|
127
|
+
import { getBuilderTargets } from "./getBuilderTargets";
|
128
|
+
import { createBuilderOptions } from "./createBuilderOptions";
|
129
|
+
function generateBuilder(options, generateProvider, utils) {
|
130
|
+
return _generateBuilder.apply(this, arguments);
|
131
|
+
}
|
132
|
+
function _generateBuilder() {
|
133
|
+
_generateBuilder = _asyncToGenerator(function(options, generateProvider, utils) {
|
134
|
+
var normalizedConfig, appContext, _ref, modifyBuilderConfig, modifyBuilderInstance, builderConfig, provider, target, builderOptions, builder;
|
135
|
+
return __generator(this, function(_state) {
|
136
|
+
switch(_state.label){
|
137
|
+
case 0:
|
138
|
+
normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
139
|
+
_ref = utils || {}, modifyBuilderConfig = _ref.modifyBuilderConfig, modifyBuilderInstance = _ref.modifyBuilderInstance;
|
140
|
+
builderConfig = createBuilderProviderConfig(normalizedConfig, appContext, modifyBuilderConfig);
|
141
|
+
provider = generateProvider({
|
142
|
+
builderConfig: builderConfig
|
143
|
+
});
|
144
|
+
target = getBuilderTargets(normalizedConfig);
|
145
|
+
builderOptions = createBuilderOptions(target, appContext);
|
146
|
+
return [
|
147
|
+
4,
|
148
|
+
createBuilder(provider, builderOptions)
|
149
|
+
];
|
150
|
+
case 1:
|
151
|
+
builder = _state.sent();
|
152
|
+
return [
|
153
|
+
4,
|
154
|
+
applyBuilderPlugins(builder, options)
|
155
|
+
];
|
156
|
+
case 2:
|
157
|
+
_state.sent();
|
158
|
+
return [
|
159
|
+
4,
|
160
|
+
modifyBuilderInstance === null || modifyBuilderInstance === void 0 ? void 0 : modifyBuilderInstance(builder)
|
161
|
+
];
|
162
|
+
case 3:
|
163
|
+
_state.sent();
|
164
|
+
return [
|
165
|
+
2,
|
166
|
+
builder
|
167
|
+
];
|
168
|
+
}
|
169
|
+
});
|
170
|
+
});
|
171
|
+
return _generateBuilder.apply(this, arguments);
|
172
|
+
}
|
173
|
+
function applyBuilderPlugins(builder, options) {
|
174
|
+
return _applyBuilderPlugins.apply(this, arguments);
|
175
|
+
}
|
176
|
+
function _applyBuilderPlugins() {
|
177
|
+
_applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
|
178
|
+
var builderPluginAdapterModern;
|
179
|
+
return __generator(this, function(_state) {
|
180
|
+
switch(_state.label){
|
181
|
+
case 0:
|
182
|
+
return [
|
183
|
+
4,
|
184
|
+
import("../shared/builderPlugins/adapterModern")
|
185
|
+
];
|
186
|
+
case 1:
|
187
|
+
builderPluginAdapterModern = _state.sent().builderPluginAdapterModern;
|
188
|
+
builder.addPlugins([
|
189
|
+
builderPluginAdapterModern(options)
|
190
|
+
]);
|
191
|
+
return [
|
192
|
+
2
|
193
|
+
];
|
194
|
+
}
|
195
|
+
});
|
196
|
+
});
|
197
|
+
return _applyBuilderPlugins.apply(this, arguments);
|
198
|
+
}
|
199
|
+
export { generateBuilder };
|