@modern-js/app-tools 2.8.1-alpha.0 → 2.8.1-alpha.2
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 +11 -11
- 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,6 @@
|
|
|
1
|
+
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
|
2
|
+
import { generateBuilder } from "../generator";
|
|
3
|
+
function createRspackBuilderForModern(options) {
|
|
4
|
+
return generateBuilder(options, builderRspackProvider);
|
|
5
|
+
}
|
|
6
|
+
export { createRspackBuilderForModern };
|
|
@@ -0,0 +1,64 @@
|
|
|
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 _iterableToArray(iter) {
|
|
10
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
+
}
|
|
12
|
+
function _nonIterableSpread() {
|
|
13
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
+
}
|
|
15
|
+
function _toConsumableArray(arr) {
|
|
16
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
17
|
+
}
|
|
18
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
19
|
+
if (!o) return;
|
|
20
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
21
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
|
+
}
|
|
26
|
+
import { join } from "path";
|
|
27
|
+
import { createCopyPattern } from "../../shared";
|
|
28
|
+
import { RouterPlugin } from "../webpackPlugins";
|
|
29
|
+
var PluginCompatModern = function(options) {
|
|
30
|
+
return {
|
|
31
|
+
name: "builder-plugin-compat-modern",
|
|
32
|
+
setup: function setup(api) {
|
|
33
|
+
var modernConfig = options.normalizedConfig, appContext = options.appContext;
|
|
34
|
+
api.modifyWebpackChain(function(chain, param) {
|
|
35
|
+
var CHAIN_ID = param.CHAIN_ID;
|
|
36
|
+
var _modernConfig_runtime;
|
|
37
|
+
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
38
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
39
|
+
var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
|
|
40
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
|
|
41
|
+
var _args_;
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
patterns: _toConsumableArray(((_args_ = args[0]) === null || _args_ === void 0 ? void 0 : _args_.patterns) || []).concat([
|
|
45
|
+
defaultCopyPattern
|
|
46
|
+
])
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var entrypoints = appContext.entrypoints;
|
|
52
|
+
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
|
53
|
+
return entrypoint.nestedRoutesEntry;
|
|
54
|
+
});
|
|
55
|
+
var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_runtime = modernConfig.runtime) === null || _modernConfig_runtime === void 0 ? void 0 : _modernConfig_runtime.router;
|
|
56
|
+
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
|
57
|
+
if (existNestedRoutes || routerManifest) {
|
|
58
|
+
chain.plugin("route-plugin").use(RouterPlugin);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export { PluginCompatModern };
|
|
@@ -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 };
|