@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,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { createDefaultConfig, createLegacyDefaultConfig } from "./default";
|
|
2
|
+
import { initialNormalizedConfig, checkIsLegacyConfig } from "./initial";
|
|
3
|
+
export { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, initialNormalizedConfig };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
+
import { transformNormalizedConfig } from "./transformNormalizedConfig";
|
|
3
|
+
function checkIsLegacyConfig(config) {
|
|
4
|
+
return Boolean(config.legacy);
|
|
5
|
+
}
|
|
6
|
+
function initialNormalizedConfig(config, appContext) {
|
|
7
|
+
initHtmlConfig(config, appContext);
|
|
8
|
+
initSourceConfig(config, appContext);
|
|
9
|
+
initToolsConfig(config);
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
12
|
+
export { checkIsLegacyConfig, initialNormalizedConfig, transformNormalizedConfig };
|
|
@@ -105,7 +105,7 @@ function initHtmlConfig(config, appContext) {
|
|
|
105
105
|
config.html.favicon = createBuilderFavicon(config, appContext);
|
|
106
106
|
return config.html;
|
|
107
107
|
}
|
|
108
|
-
function initSourceConfig(config, appContext
|
|
108
|
+
function initSourceConfig(config, appContext) {
|
|
109
109
|
var createBuilderGlobalVars = function createBuilderGlobalVars(config2, appContext2) {
|
|
110
110
|
var _source = config2.source, _globalVars = _source.globalVars, globalVars = _globalVars === void 0 ? {} : _globalVars;
|
|
111
111
|
var publicEnv = getAutoInjectEnv(appContext2);
|
|
@@ -176,10 +176,8 @@ function initSourceConfig(config, appContext, bundler) {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
config.source.include = createBuilderInclude(config, appContext);
|
|
179
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
179
180
|
config.source.globalVars = createBuilderGlobalVars(config, appContext);
|
|
180
|
-
if (bundler === "webpack") {
|
|
181
|
-
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
182
|
-
}
|
|
183
181
|
}
|
|
184
182
|
function initToolsConfig(config) {
|
|
185
183
|
var defaultTsChecker = {
|
|
@@ -439,9 +439,6 @@ var buildCommand = function() {
|
|
|
439
439
|
};
|
|
440
440
|
}();
|
|
441
441
|
var src_default = function() {
|
|
442
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
443
|
-
bundler: "webpack"
|
|
444
|
-
};
|
|
445
442
|
return {
|
|
446
443
|
name: "@modern-js/app-tools",
|
|
447
444
|
post: [
|
|
@@ -456,12 +453,8 @@ var src_default = function() {
|
|
|
456
453
|
],
|
|
457
454
|
registerHook: hooks,
|
|
458
455
|
usePlugins: [
|
|
459
|
-
initializePlugin(
|
|
460
|
-
|
|
461
|
-
}),
|
|
462
|
-
analyzePlugin({
|
|
463
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
464
|
-
}),
|
|
456
|
+
initializePlugin(),
|
|
457
|
+
analyzePlugin(),
|
|
465
458
|
lintPlugin()
|
|
466
459
|
],
|
|
467
460
|
setup: function(api) {
|
|
@@ -512,7 +505,7 @@ var src_default = function() {
|
|
|
512
505
|
});
|
|
513
506
|
}));
|
|
514
507
|
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
|
|
515
|
-
var _ref = _asyncToGenerator(function(
|
|
508
|
+
var _ref = _asyncToGenerator(function(options) {
|
|
516
509
|
var build, deploy;
|
|
517
510
|
return __generator(this, function(_state) {
|
|
518
511
|
switch(_state.label){
|
|
@@ -537,7 +530,7 @@ var src_default = function() {
|
|
|
537
530
|
deploy = _state.sent().deploy;
|
|
538
531
|
return [
|
|
539
532
|
4,
|
|
540
|
-
deploy(api,
|
|
533
|
+
deploy(api, options)
|
|
541
534
|
];
|
|
542
535
|
case 4:
|
|
543
536
|
_state.sent();
|
|
@@ -548,12 +541,12 @@ var src_default = function() {
|
|
|
548
541
|
}
|
|
549
542
|
});
|
|
550
543
|
});
|
|
551
|
-
return function(
|
|
544
|
+
return function(options) {
|
|
552
545
|
return _ref.apply(this, arguments);
|
|
553
546
|
};
|
|
554
547
|
}());
|
|
555
548
|
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(function() {
|
|
556
|
-
var _ref = _asyncToGenerator(function(
|
|
549
|
+
var _ref = _asyncToGenerator(function(options) {
|
|
557
550
|
var MWANewAction;
|
|
558
551
|
return __generator(this, function(_state) {
|
|
559
552
|
switch(_state.label){
|
|
@@ -566,8 +559,8 @@ var src_default = function() {
|
|
|
566
559
|
MWANewAction = _state.sent().MWANewAction;
|
|
567
560
|
return [
|
|
568
561
|
4,
|
|
569
|
-
MWANewAction(_objectSpreadProps(_objectSpread({},
|
|
570
|
-
locale:
|
|
562
|
+
MWANewAction(_objectSpreadProps(_objectSpread({}, options), {
|
|
563
|
+
locale: options.lang || locale
|
|
571
564
|
}))
|
|
572
565
|
];
|
|
573
566
|
case 2:
|
|
@@ -578,12 +571,12 @@ var src_default = function() {
|
|
|
578
571
|
}
|
|
579
572
|
});
|
|
580
573
|
});
|
|
581
|
-
return function(
|
|
574
|
+
return function(options) {
|
|
582
575
|
return _ref.apply(this, arguments);
|
|
583
576
|
};
|
|
584
577
|
}());
|
|
585
578
|
program.command("inspect").description("inspect internal webpack config").option("--env <env>", i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(function() {
|
|
586
|
-
var _ref = _asyncToGenerator(function(
|
|
579
|
+
var _ref = _asyncToGenerator(function(options) {
|
|
587
580
|
var inspect;
|
|
588
581
|
return __generator(this, function(_state) {
|
|
589
582
|
switch(_state.label){
|
|
@@ -594,14 +587,14 @@ var src_default = function() {
|
|
|
594
587
|
];
|
|
595
588
|
case 1:
|
|
596
589
|
inspect = _state.sent().inspect;
|
|
597
|
-
inspect(api,
|
|
590
|
+
inspect(api, options);
|
|
598
591
|
return [
|
|
599
592
|
2
|
|
600
593
|
];
|
|
601
594
|
}
|
|
602
595
|
});
|
|
603
596
|
});
|
|
604
|
-
return function(
|
|
597
|
+
return function(options) {
|
|
605
598
|
return _ref.apply(this, arguments);
|
|
606
599
|
};
|
|
607
600
|
}());
|
|
@@ -176,16 +176,16 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
176
176
|
};
|
|
177
177
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
178
178
|
import { legacySchema, schema } from "../schema";
|
|
179
|
-
import {
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
|
180
|
+
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
|
|
181
|
+
var initialize_default = function() {
|
|
182
182
|
return {
|
|
183
183
|
name: "@modern-js/plugin-initialize",
|
|
184
184
|
setup: function setup(api) {
|
|
185
185
|
var config = function() {
|
|
186
186
|
var appContext = api.useAppContext();
|
|
187
187
|
var userConfig = api.useConfigContext();
|
|
188
|
-
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext
|
|
188
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
|
189
189
|
};
|
|
190
190
|
var validateSchema = function() {
|
|
191
191
|
var userConfig = api.useConfigContext();
|
|
@@ -216,34 +216,31 @@ var initialize_default = function(param) {
|
|
|
216
216
|
});
|
|
217
217
|
api.setAppContext(appContext);
|
|
218
218
|
normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
219
|
-
resolved._raw = userConfig;
|
|
220
|
-
resolved.server = _objectSpreadProps(_objectSpread({}, normalizedConfig.server || {}), {
|
|
221
|
-
port: port
|
|
222
|
-
});
|
|
223
|
-
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
|
|
224
|
-
stabilizeConfig(resolved, normalizedConfig, [
|
|
225
|
-
"source",
|
|
226
|
-
"bff",
|
|
227
|
-
"dev",
|
|
228
|
-
"html",
|
|
229
|
-
"output",
|
|
230
|
-
"tools",
|
|
231
|
-
"testing",
|
|
232
|
-
"plugins",
|
|
233
|
-
"builderPlugins",
|
|
234
|
-
"runtime",
|
|
235
|
-
"runtimeByEntries",
|
|
236
|
-
"deploy",
|
|
237
|
-
"performance"
|
|
238
|
-
]);
|
|
239
|
-
if (bundler === "webpack") {
|
|
240
|
-
resolved.security = normalizedConfig.security || {};
|
|
241
|
-
resolved.experiments = normalizedConfig.experiments;
|
|
242
|
-
}
|
|
243
219
|
return [
|
|
244
220
|
2,
|
|
245
221
|
{
|
|
246
|
-
resolved:
|
|
222
|
+
resolved: {
|
|
223
|
+
_raw: userConfig,
|
|
224
|
+
source: normalizedConfig.source || {},
|
|
225
|
+
server: _objectSpreadProps(_objectSpread({}, normalizedConfig.server || {}), {
|
|
226
|
+
port: port
|
|
227
|
+
}),
|
|
228
|
+
bff: normalizedConfig.bff || {},
|
|
229
|
+
dev: normalizedConfig.dev || {},
|
|
230
|
+
html: normalizedConfig.html || {},
|
|
231
|
+
output: normalizedConfig.output || {},
|
|
232
|
+
security: normalizedConfig.security || {},
|
|
233
|
+
tools: normalizedConfig.tools || {},
|
|
234
|
+
testing: normalizedConfig.testing || {},
|
|
235
|
+
plugins: normalizedConfig.plugins || [],
|
|
236
|
+
builderPlugins: normalizedConfig.builderPlugins || [],
|
|
237
|
+
runtime: normalizedConfig.runtime || {},
|
|
238
|
+
runtimeByEntries: normalizedConfig.runtimeByEntries || {},
|
|
239
|
+
deploy: normalizedConfig.deploy || {},
|
|
240
|
+
performance: normalizedConfig.performance || {},
|
|
241
|
+
experiments: normalizedConfig.experiments || {},
|
|
242
|
+
autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
|
|
243
|
+
}
|
|
247
244
|
}
|
|
248
245
|
];
|
|
249
246
|
}
|
|
@@ -254,11 +251,6 @@ var initialize_default = function(param) {
|
|
|
254
251
|
}
|
|
255
252
|
};
|
|
256
253
|
};
|
|
257
|
-
function stabilizeConfig(resolve, config, keys) {
|
|
258
|
-
keys.forEach(function(key) {
|
|
259
|
-
resolve[key] = config[key] || {};
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
254
|
function getServerPort(config) {
|
|
263
255
|
return _getServerPort.apply(this, arguments);
|
|
264
256
|
}
|
|
@@ -26,11 +26,9 @@ export declare const html: (partials: {
|
|
|
26
26
|
body: string[];
|
|
27
27
|
}) => string;
|
|
28
28
|
export declare const routesForServer: ({
|
|
29
|
-
routes
|
|
30
|
-
metaName
|
|
29
|
+
routes
|
|
31
30
|
}: {
|
|
32
31
|
routes: (NestedRoute | PageRoute)[];
|
|
33
|
-
metaName: string;
|
|
34
32
|
}) => string;
|
|
35
33
|
export declare const fileSystemRoutes: ({
|
|
36
34
|
routes,
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
3
|
import { BuilderOptions } from '../../shared';
|
|
4
|
-
type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
|
|
5
|
-
type FnParameter<T extends {
|
|
6
|
-
[p: string]: (arg: any) => void;
|
|
7
|
-
}> = { [P in keyof T]: Parameter<T[P]> };
|
|
8
|
-
export type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
|
|
9
4
|
/**
|
|
10
5
|
* Provides default configuration consistent with modern.js v1
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
|
-
export declare const
|
|
14
|
-
export {};
|
|
8
|
+
export declare const builderPluginCompatModern: (options: BuilderOptions<'webpack'>) => BuilderPlugin<BuilderPluginAPI>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.5.
|
|
14
|
+
"version": "2.5.1-alpha.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/index.js",
|
|
@@ -62,38 +62,38 @@
|
|
|
62
62
|
"@babel/runtime": "^7.18.0",
|
|
63
63
|
"@babel/traverse": "^7.18.0",
|
|
64
64
|
"@babel/types": "^7.18.0",
|
|
65
|
-
"@modern-js/plugin-data-loader": "2.5.0-alpha.0",
|
|
66
|
-
"es-module-lexer": "^1.1.0",
|
|
67
|
-
"esbuild": "0.15.7",
|
|
68
65
|
"@modern-js/builder": "2.5.0",
|
|
69
66
|
"@modern-js/builder-plugin-esbuild": "2.5.0",
|
|
70
67
|
"@modern-js/builder-plugin-node-polyfill": "2.5.0",
|
|
71
|
-
"@modern-js/builder-shared": "2.5.0",
|
|
68
|
+
"@modern-js/builder-shared": "2.5.1-alpha.0",
|
|
72
69
|
"@modern-js/builder-webpack-provider": "2.5.0",
|
|
73
70
|
"@modern-js/core": "2.5.0",
|
|
74
71
|
"@modern-js/new-action": "2.5.0",
|
|
75
72
|
"@modern-js/node-bundle-require": "2.5.0",
|
|
76
|
-
"@modern-js/plugin-i18n": "2.5.0",
|
|
77
73
|
"@modern-js/plugin": "2.5.0",
|
|
74
|
+
"@modern-js/plugin-data-loader": "2.5.0",
|
|
75
|
+
"@modern-js/plugin-i18n": "2.5.0",
|
|
78
76
|
"@modern-js/plugin-lint": "2.5.0",
|
|
79
77
|
"@modern-js/prod-server": "2.5.0",
|
|
80
78
|
"@modern-js/server": "2.5.0",
|
|
81
|
-
"@modern-js/upgrade": "2.5.0",
|
|
82
79
|
"@modern-js/types": "2.5.0",
|
|
83
|
-
"@modern-js/
|
|
80
|
+
"@modern-js/upgrade": "2.5.0",
|
|
81
|
+
"@modern-js/utils": "2.5.0",
|
|
82
|
+
"es-module-lexer": "^1.1.0",
|
|
83
|
+
"esbuild": "0.15.7"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
+
"@modern-js/builder-plugin-swc": "2.5.0",
|
|
87
|
+
"@modern-js/builder-rspack-provider": "2.5.0",
|
|
88
|
+
"@modern-js/server-core": "2.5.0",
|
|
89
|
+
"@scripts/build": "2.5.0",
|
|
90
|
+
"@scripts/jest-config": "2.5.0",
|
|
86
91
|
"@types/babel__traverse": "^7.14.2",
|
|
87
92
|
"@types/jest": "^27",
|
|
88
93
|
"@types/node": "^14",
|
|
89
94
|
"jest": "^27",
|
|
90
95
|
"typescript": "^4",
|
|
91
|
-
"webpack": "^5.75.0"
|
|
92
|
-
"@modern-js/builder-rspack-provider": "2.5.0",
|
|
93
|
-
"@modern-js/builder-plugin-swc": "2.5.0",
|
|
94
|
-
"@modern-js/server-core": "2.5.0",
|
|
95
|
-
"@scripts/build": "2.5.0",
|
|
96
|
-
"@scripts/jest-config": "2.5.0"
|
|
96
|
+
"webpack": "^5.75.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@modern-js/builder-rspack-provider": "^2.5.0"
|
|
@@ -1,8 +0,0 @@
|
|
|
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 {
|
|
7
|
-
createRspackBuilderForModern
|
|
8
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
import { createCopyPattern } from "../../shared";
|
|
3
|
-
import { RouterPlugin } from "../webpackPlugins";
|
|
4
|
-
const PluginCompatModern = (options) => ({
|
|
5
|
-
name: "builder-plugin-compat-modern",
|
|
6
|
-
setup(api) {
|
|
7
|
-
const { normalizedConfig: modernConfig, appContext } = options;
|
|
8
|
-
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
|
9
|
-
var _a;
|
|
10
|
-
chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
|
|
11
|
-
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
12
|
-
const defaultCopyPattern = createCopyPattern(
|
|
13
|
-
appContext,
|
|
14
|
-
modernConfig,
|
|
15
|
-
"public",
|
|
16
|
-
chain
|
|
17
|
-
);
|
|
18
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
19
|
-
var _a2;
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const { entrypoints } = appContext;
|
|
28
|
-
const existNestedRoutes = entrypoints.some(
|
|
29
|
-
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
30
|
-
);
|
|
31
|
-
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
32
|
-
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
33
|
-
if (existNestedRoutes || routerManifest) {
|
|
34
|
-
chain.plugin("route-plugin").use(RouterPlugin);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
export {
|
|
40
|
-
PluginCompatModern
|
|
41
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import {
|
|
41
|
-
builderWebpackProvider
|
|
42
|
-
} from "@modern-js/builder-webpack-provider";
|
|
43
|
-
import { applyOptionsChain } from "@modern-js/utils";
|
|
44
|
-
import { createCopyPattern } from "../shared";
|
|
45
|
-
import { generateBuilder } from "../generator";
|
|
46
|
-
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
|
47
|
-
function createWebpackBuilderForModern(options) {
|
|
48
|
-
return generateBuilder(options, builderWebpackProvider, {
|
|
49
|
-
modifyBuilderConfig(config) {
|
|
50
|
-
modifyOutputConfig(config, options.appContext);
|
|
51
|
-
},
|
|
52
|
-
modifyBuilderInstance(builder) {
|
|
53
|
-
return __async(this, null, function* () {
|
|
54
|
-
yield applyBuilderPlugins(builder, options);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function modifyOutputConfig(config, appContext) {
|
|
60
|
-
config.output = createOutputConfig(config, appContext);
|
|
61
|
-
function createOutputConfig(config2, appContext2) {
|
|
62
|
-
const defaultCopyPattern = createCopyPattern(appContext2, config2, "upload");
|
|
63
|
-
const { copy } = config2.output;
|
|
64
|
-
const copyOptions = Array.isArray(copy) ? copy : copy == null ? void 0 : copy.patterns;
|
|
65
|
-
const builderCopy = [...copyOptions || [], defaultCopyPattern];
|
|
66
|
-
return __spreadProps(__spreadValues({}, config2.output), {
|
|
67
|
-
copy: builderCopy
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function applyBuilderPlugins(builder, options) {
|
|
72
|
-
return __async(this, null, function* () {
|
|
73
|
-
const { normalizedConfig } = options;
|
|
74
|
-
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
75
|
-
const { PluginNodePolyfill } = yield import("@modern-js/builder-plugin-node-polyfill");
|
|
76
|
-
builder.addPlugins([PluginNodePolyfill()]);
|
|
77
|
-
}
|
|
78
|
-
if (normalizedConfig.tools.esbuild) {
|
|
79
|
-
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
80
|
-
const { PluginEsbuild } = yield import("@modern-js/builder-plugin-esbuild");
|
|
81
|
-
builder.addPlugins([
|
|
82
|
-
PluginEsbuild({
|
|
83
|
-
loader: false,
|
|
84
|
-
minimize: applyOptionsChain({}, esbuildOptions)
|
|
85
|
-
})
|
|
86
|
-
]);
|
|
87
|
-
}
|
|
88
|
-
builder.addPlugins([PluginCompatModern(options)]);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
createWebpackBuilderForModern
|
|
93
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./RouterPlugin";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function createBuilderOptions(target, appContext) {
|
|
2
|
-
const entries = {};
|
|
3
|
-
const { entrypoints = [], checkedEntries } = appContext;
|
|
4
|
-
for (const { entryName, entry } of entrypoints) {
|
|
5
|
-
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
|
6
|
-
continue;
|
|
7
|
-
}
|
|
8
|
-
if (entryName in entries) {
|
|
9
|
-
entries[entryName].push(entry);
|
|
10
|
-
} else {
|
|
11
|
-
entries[entryName] = [entry];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
cwd: appContext.appDirectory,
|
|
16
|
-
target,
|
|
17
|
-
configPath: appContext.configFile || void 0,
|
|
18
|
-
entry: entries,
|
|
19
|
-
framework: appContext.metaName
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
createBuilderOptions
|
|
24
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderConfig) {
|
|
21
|
-
const htmlConfig = __spreadValues({}, resolveConfig.html);
|
|
22
|
-
if (!htmlConfig.template) {
|
|
23
|
-
htmlConfig.templateByEntries = __spreadValues(__spreadValues({}, htmlConfig.templateByEntries), appContext.htmlTemplates);
|
|
24
|
-
}
|
|
25
|
-
const config = __spreadProps(__spreadValues({}, resolveConfig), {
|
|
26
|
-
dev: __spreadProps(__spreadValues({}, resolveConfig.dev), {
|
|
27
|
-
port: appContext.port
|
|
28
|
-
}),
|
|
29
|
-
html: htmlConfig,
|
|
30
|
-
output: __spreadProps(__spreadValues({}, resolveConfig.output), {
|
|
31
|
-
cleanDistPath: false
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
modifyBuilderConfig == null ? void 0 : modifyBuilderConfig(config);
|
|
35
|
-
return config;
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
createBuilderProviderConfig
|
|
39
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isProd, isSSR, isUseSSRBundle } from "@modern-js/utils";
|
|
2
|
-
function getBuilderTargets(normalizedConfig) {
|
|
3
|
-
const targets = ["web"];
|
|
4
|
-
const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
|
5
|
-
if (useNodeTarget) {
|
|
6
|
-
targets.push("node");
|
|
7
|
-
}
|
|
8
|
-
return targets;
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
getBuilderTargets
|
|
12
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import { createBuilder } from "@modern-js/builder";
|
|
22
|
-
import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
|
|
23
|
-
import { getBuilderTargets } from "./getBuilderTargets";
|
|
24
|
-
import { createBuilderOptions } from "./createBuilderOptions";
|
|
25
|
-
function generateBuilder(options, generateProvider, utils) {
|
|
26
|
-
return __async(this, null, function* () {
|
|
27
|
-
const { normalizedConfig, appContext } = options;
|
|
28
|
-
const { modifyBuilderConfig, modifyBuilderInstance } = utils || {};
|
|
29
|
-
const builderConfig = createBuilderProviderConfig(
|
|
30
|
-
normalizedConfig,
|
|
31
|
-
appContext,
|
|
32
|
-
modifyBuilderConfig
|
|
33
|
-
);
|
|
34
|
-
const provider = generateProvider({
|
|
35
|
-
builderConfig
|
|
36
|
-
});
|
|
37
|
-
const target = getBuilderTargets(normalizedConfig);
|
|
38
|
-
const builderOptions = createBuilderOptions(target, appContext);
|
|
39
|
-
const builder = yield createBuilder(provider, builderOptions);
|
|
40
|
-
yield applyBuilderPlugins(builder, options);
|
|
41
|
-
yield modifyBuilderInstance == null ? void 0 : modifyBuilderInstance(builder);
|
|
42
|
-
return builder;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function applyBuilderPlugins(builder, options) {
|
|
46
|
-
return __async(this, null, function* () {
|
|
47
|
-
const { builderPluginAdapterModern } = yield import("../shared/builderPlugins/adapterModern");
|
|
48
|
-
builder.addPlugins([builderPluginAdapterModern(options)]);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
generateBuilder
|
|
53
|
-
};
|