@modern-js/app-tools 2.0.0-beta.4 → 2.0.0-beta.6
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/CHANGELOG.md +314 -0
- package/bin/modern.js +2 -0
- package/dist/js/modern/analyze/constants.js +10 -0
- package/dist/js/modern/analyze/generateCode.js +7 -9
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +9 -6
- package/dist/js/modern/analyze/getFileSystemEntry.js +11 -3
- package/dist/js/modern/analyze/index.js +7 -5
- package/dist/js/modern/analyze/nestedRoutes.js +29 -22
- package/dist/js/modern/analyze/templates.js +8 -1
- package/dist/js/modern/analyze/utils.js +19 -3
- package/dist/js/modern/builder/builderPlugins/compatModern.js +8 -2
- package/dist/js/modern/builder/index.js +1 -7
- package/dist/js/modern/commands/dev.js +6 -9
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/{start.js → serve.js} +3 -1
- package/dist/js/modern/config/default.js +38 -61
- package/dist/js/modern/config/initial/createOutputConfig.js +1 -3
- package/dist/js/modern/config/initial/createSourceConfig.js +5 -1
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +5 -1
- package/dist/js/modern/hooks.js +1 -0
- package/dist/js/modern/index.js +5 -5
- package/dist/js/modern/initialize/index.js +5 -4
- package/dist/js/modern/locale/en.js +1 -1
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/modern/schema/index.js +3 -1
- package/dist/js/modern/utils/commands.js +6 -1
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/node/analyze/Builder.js +14 -8
- package/dist/js/node/analyze/constants.js +35 -3
- package/dist/js/node/analyze/generateCode.js +27 -24
- package/dist/js/node/analyze/getBundleEntry.js +7 -3
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +33 -28
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +24 -22
- package/dist/js/node/analyze/getClientRoutes/index.js +8 -3
- package/dist/js/node/analyze/getClientRoutes/utils.js +10 -3
- package/dist/js/node/analyze/getFileSystemEntry.js +18 -6
- package/dist/js/node/analyze/getHtmlTemplate.js +18 -14
- package/dist/js/node/analyze/getServerRoutes.js +36 -34
- package/dist/js/node/analyze/index.js +45 -59
- package/dist/js/node/analyze/isDefaultExportFunction.js +7 -3
- package/dist/js/node/analyze/makeLegalIdentifier.js +7 -3
- package/dist/js/node/analyze/nestedRoutes.js +58 -49
- package/dist/js/node/analyze/templates.js +45 -32
- package/dist/js/node/analyze/utils.js +39 -17
- package/dist/js/node/builder/builderPlugins/compatModern.js +32 -24
- package/dist/js/node/builder/index.js +36 -48
- package/dist/js/node/builder/loaders/routerLoader.js +5 -3
- package/dist/js/node/builder/loaders/serverModuleLoader.js +5 -3
- package/dist/js/node/builder/share.js +7 -3
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +7 -3
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +7 -3
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +9 -7
- package/dist/js/node/commands/build.js +30 -28
- package/dist/js/node/commands/deploy.js +9 -5
- package/dist/js/node/commands/dev.js +39 -40
- package/dist/js/node/commands/index.js +5 -5
- package/dist/js/node/commands/inspect.js +10 -6
- package/dist/js/node/commands/{start.js → serve.js} +16 -10
- package/dist/js/node/config/default.js +44 -64
- package/dist/js/node/config/index.js +10 -3
- package/dist/js/node/config/initial/createHtmlConfig.js +7 -3
- package/dist/js/node/config/initial/createOutputConfig.js +8 -6
- package/dist/js/node/config/initial/createSourceConfig.js +12 -4
- package/dist/js/node/config/initial/createToolsConfig.js +7 -3
- package/dist/js/node/config/initial/index.js +9 -3
- package/dist/js/node/config/initial/inits.js +26 -22
- package/dist/js/node/config/initial/transformNormalizedConfig.js +12 -4
- package/dist/js/node/defineConfig.js +25 -22
- package/dist/js/node/exports/server.js +7 -3
- package/dist/js/node/hooks.js +8 -3
- package/dist/js/node/index.js +56 -69
- package/dist/js/node/initialize/index.js +33 -32
- package/dist/js/node/locale/en.js +8 -4
- package/dist/js/node/locale/index.js +8 -3
- package/dist/js/node/locale/zh.js +8 -4
- package/dist/js/node/schema/Schema.js +7 -3
- package/dist/js/node/schema/index.js +11 -4
- package/dist/js/node/schema/legacy.js +5 -3
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +3 -3
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +5 -5
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/commands.js +14 -4
- package/dist/js/node/utils/config.js +35 -30
- package/dist/js/node/utils/createFileWatcher.js +15 -10
- package/dist/js/node/utils/createServer.js +35 -29
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/getSpecifiedEntries.js +10 -6
- package/dist/js/node/utils/language.js +7 -3
- package/dist/js/node/utils/printInstructions.js +10 -6
- package/dist/js/node/utils/restart.js +11 -7
- package/dist/js/node/utils/routes.js +11 -7
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +10 -1
- package/dist/js/treeshaking/analyze/generateCode.js +7 -11
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +9 -6
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +11 -3
- package/dist/js/treeshaking/analyze/index.js +7 -4
- package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
- package/dist/js/treeshaking/analyze/templates.js +6 -1
- package/dist/js/treeshaking/analyze/utils.js +12 -3
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -2
- package/dist/js/treeshaking/builder/index.js +1 -7
- package/dist/js/treeshaking/commands/dev.js +19 -24
- package/dist/js/treeshaking/commands/index.js +1 -1
- package/dist/js/treeshaking/commands/{start.js → serve.js} +10 -3
- package/dist/js/treeshaking/config/default.js +53 -56
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +1 -3
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +5 -1
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +5 -1
- package/dist/js/treeshaking/hooks.js +1 -0
- package/dist/js/treeshaking/index.js +5 -5
- package/dist/js/treeshaking/initialize/index.js +6 -5
- package/dist/js/treeshaking/locale/en.js +1 -1
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/js/treeshaking/schema/index.js +7 -1
- package/dist/js/treeshaking/utils/commands.js +5 -1
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/types/analyze/constants.d.ts +10 -1
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/{start.d.ts → serve.d.ts} +0 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locale/en.d.ts +1 -1
- package/dist/types/locale/index.d.ts +2 -2
- package/dist/types/locale/zh.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +3 -0
- package/dist/types/types/config/source.d.ts +1 -0
- package/dist/types/types/hooks.d.ts +3 -0
- package/dist/types/utils/commands.d.ts +2 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
- package/package.json +25 -22
|
@@ -11,45 +11,64 @@ function _defineProperty(obj, key, value) {
|
|
|
11
11
|
}
|
|
12
12
|
return obj;
|
|
13
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
|
+
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
|
14
54
|
function createDefaultConfig(appContext) {
|
|
55
|
+
var defaultBuilderConfig = createDefaultBuilderConfig();
|
|
56
|
+
var dev = _objectSpread({}, defaultBuilderConfig.dev);
|
|
57
|
+
var tools = _objectSpread({}, defaultBuilderConfig.tools);
|
|
58
|
+
var output = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.output), {
|
|
59
|
+
disableNodePolyfill: true
|
|
60
|
+
});
|
|
15
61
|
var _obj;
|
|
16
|
-
var
|
|
17
|
-
var source = {
|
|
62
|
+
var source = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.source), {
|
|
18
63
|
entries: void 0,
|
|
19
64
|
enableAsyncEntry: false,
|
|
20
65
|
disableDefaultEntries: false,
|
|
21
66
|
entriesDir: "./src",
|
|
22
67
|
configDir: "./config",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
alias: defaultAlias
|
|
27
|
-
};
|
|
28
|
-
var output = {
|
|
29
|
-
assetPrefix: "/",
|
|
30
|
-
distPath: {
|
|
31
|
-
html: "html",
|
|
32
|
-
js: "static/js",
|
|
33
|
-
css: "static/css",
|
|
34
|
-
media: "static/media",
|
|
35
|
-
root: "dist"
|
|
36
|
-
},
|
|
37
|
-
copy: void 0,
|
|
38
|
-
disableCssModuleExtension: false,
|
|
39
|
-
enableCssModuleTSDeclaration: false,
|
|
40
|
-
disableMinimize: false,
|
|
41
|
-
enableInlineStyles: false,
|
|
42
|
-
enableInlineScripts: false,
|
|
43
|
-
disableSourceMap: false,
|
|
44
|
-
disableInlineRuntimeChunk: false,
|
|
45
|
-
disableFilenameHash: false,
|
|
46
|
-
enableLatestDecorators: false,
|
|
47
|
-
polyfill: "entry",
|
|
48
|
-
cssModuleLocalIdentName: void 0
|
|
49
|
-
};
|
|
50
|
-
var html = {
|
|
68
|
+
alias: (_obj = {}, _defineProperty(_obj, appContext.internalDirAlias, appContext.internalDirectory), _defineProperty(_obj, appContext.internalSrcAlias, appContext.srcDirectory), _defineProperty(_obj, "@", appContext.srcDirectory), _defineProperty(_obj, "@shared", appContext.sharedDirectory), _obj)
|
|
69
|
+
});
|
|
70
|
+
var html = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.html), {
|
|
51
71
|
title: "",
|
|
52
|
-
titleByEntries: void 0,
|
|
53
72
|
meta: {
|
|
54
73
|
charset: {
|
|
55
74
|
charset: "utf-8"
|
|
@@ -64,17 +83,8 @@ function createDefaultConfig(appContext) {
|
|
|
64
83
|
imagemode: "force",
|
|
65
84
|
"wap-font-scale": "no",
|
|
66
85
|
"format-detection": "telephone=no"
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
inject: "head",
|
|
70
|
-
injectByEntries: void 0,
|
|
71
|
-
mountId: "root",
|
|
72
|
-
favicon: "",
|
|
73
|
-
faviconByEntries: void 0,
|
|
74
|
-
disableHtmlFolder: false,
|
|
75
|
-
templateParameters: {},
|
|
76
|
-
templateParametersByEntries: void 0
|
|
77
|
-
};
|
|
86
|
+
}
|
|
87
|
+
});
|
|
78
88
|
var server = {
|
|
79
89
|
routes: void 0,
|
|
80
90
|
publicRoutes: void 0,
|
|
@@ -83,20 +93,6 @@ function createDefaultConfig(appContext) {
|
|
|
83
93
|
baseUrl: "/",
|
|
84
94
|
port: 8080
|
|
85
95
|
};
|
|
86
|
-
var dev = {
|
|
87
|
-
assetPrefix: false,
|
|
88
|
-
https: false
|
|
89
|
-
};
|
|
90
|
-
var tools = {
|
|
91
|
-
webpack: void 0,
|
|
92
|
-
babel: void 0,
|
|
93
|
-
postcss: void 0,
|
|
94
|
-
autoprefixer: void 0,
|
|
95
|
-
devServer: void 0,
|
|
96
|
-
tsLoader: void 0,
|
|
97
|
-
terser: void 0,
|
|
98
|
-
minifyCss: void 0
|
|
99
|
-
};
|
|
100
96
|
return {
|
|
101
97
|
source: source,
|
|
102
98
|
output: output,
|
|
@@ -105,6 +101,7 @@ function createDefaultConfig(appContext) {
|
|
|
105
101
|
html: html,
|
|
106
102
|
tools: tools,
|
|
107
103
|
plugins: [],
|
|
104
|
+
builderPlugins: [],
|
|
108
105
|
runtime: {},
|
|
109
106
|
runtimeByEntries: {}
|
|
110
107
|
};
|
|
@@ -19,6 +19,7 @@ function createOutputConfig(config) {
|
|
|
19
19
|
font: dataUriLimit,
|
|
20
20
|
media: dataUriLimit
|
|
21
21
|
},
|
|
22
|
+
cssModuleLocalIdentName: cssModuleLocalIdentName,
|
|
22
23
|
disableCssExtract: disableCssExtract,
|
|
23
24
|
disableCssModuleExtension: disableCssModuleExtension,
|
|
24
25
|
disableInlineRuntimeChunk: disableInlineRuntimeChunk,
|
|
@@ -31,9 +32,6 @@ function createOutputConfig(config) {
|
|
|
31
32
|
polyfill: polyfill,
|
|
32
33
|
disableFilenameHash: disableAssetsCache,
|
|
33
34
|
enableLatestDecorators: enableLatestDecorators,
|
|
34
|
-
filename: {
|
|
35
|
-
css: cssModuleLocalIdentName
|
|
36
|
-
},
|
|
37
35
|
ssg: ssg,
|
|
38
36
|
enableAssetFallback: true,
|
|
39
37
|
enableAssetManifest: true,
|
|
@@ -32,7 +32,11 @@ function createSourceConfig(config) {
|
|
|
32
32
|
enableAsyncEntry: enableAsyncEntry,
|
|
33
33
|
disableDefaultEntries: disableDefaultEntries,
|
|
34
34
|
entriesDir: entriesDir,
|
|
35
|
-
configDir: configDir
|
|
35
|
+
configDir: configDir,
|
|
36
|
+
resolveExtensionPrefix: {
|
|
37
|
+
web: ".web",
|
|
38
|
+
node: ".node"
|
|
39
|
+
}
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
export { createSourceConfig };
|
|
@@ -21,11 +21,15 @@ function transformNormalizedConfig(config) {
|
|
|
21
21
|
server: server,
|
|
22
22
|
cliOptions: cliOptions,
|
|
23
23
|
testing: testing,
|
|
24
|
+
builderPlugins: [],
|
|
24
25
|
plugins: plugins,
|
|
25
26
|
security: {},
|
|
26
27
|
_raw: {},
|
|
27
28
|
experiments: {},
|
|
28
|
-
|
|
29
|
+
autoLoadPlugins: true,
|
|
30
|
+
performance: {
|
|
31
|
+
removeMomentLocale: true
|
|
32
|
+
}
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
export { transformNormalizedConfig };
|
|
@@ -10,6 +10,7 @@ var hooks = {
|
|
|
10
10
|
htmlPartials: createAsyncWaterfall(),
|
|
11
11
|
beforeGenerateRoutes: createAsyncWaterfall(),
|
|
12
12
|
addDefineTypes: createAsyncWaterfall(),
|
|
13
|
+
collectServerPlugins: createAsyncWaterfall(),
|
|
13
14
|
beforeDev: createAsyncWorkflow(),
|
|
14
15
|
afterDev: createAsyncWorkflow(),
|
|
15
16
|
beforeCreateCompiler: createAsyncWorkflow(),
|
|
@@ -201,7 +201,7 @@ var devCommand = function() {
|
|
|
201
201
|
];
|
|
202
202
|
case 1:
|
|
203
203
|
devToolMetas = _state.sent();
|
|
204
|
-
devProgram = program.command("dev").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(function() {
|
|
204
|
+
devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(function() {
|
|
205
205
|
var _ref = _asyncToGenerator(function(options) {
|
|
206
206
|
var dev;
|
|
207
207
|
return __generator(this, function(_state) {
|
|
@@ -449,7 +449,7 @@ var src_default = function() {
|
|
|
449
449
|
"@modern-js/plugin-document",
|
|
450
450
|
"@modern-js/plugin-state",
|
|
451
451
|
"@modern-js/plugin-router",
|
|
452
|
-
"@modern-js/plugin-router-
|
|
452
|
+
"@modern-js/plugin-router-v5",
|
|
453
453
|
"@modern-js/plugin-polyfill"
|
|
454
454
|
],
|
|
455
455
|
registerHook: hooks,
|
|
@@ -482,14 +482,14 @@ var src_default = function() {
|
|
|
482
482
|
];
|
|
483
483
|
case 2:
|
|
484
484
|
_state.sent();
|
|
485
|
-
program.command("
|
|
485
|
+
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(/*#__PURE__*/ _asyncToGenerator(function() {
|
|
486
486
|
var start;
|
|
487
487
|
return __generator(this, function(_state) {
|
|
488
488
|
switch(_state.label){
|
|
489
489
|
case 0:
|
|
490
490
|
return [
|
|
491
491
|
4,
|
|
492
|
-
import("./commands/
|
|
492
|
+
import("./commands/serve")
|
|
493
493
|
];
|
|
494
494
|
case 1:
|
|
495
495
|
start = _state.sent().start;
|
|
@@ -614,7 +614,7 @@ var src_default = function() {
|
|
|
614
614
|
switch(_state.label){
|
|
615
615
|
case 0:
|
|
616
616
|
command = getCommand();
|
|
617
|
-
if (!(command === "dev" || command === "build")) return [
|
|
617
|
+
if (!(command === "dev" || command === "start" || command === "build")) return [
|
|
618
618
|
3,
|
|
619
619
|
2
|
|
620
620
|
];
|
|
@@ -176,7 +176,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
176
176
|
};
|
|
177
177
|
import { ensureAbsolutePath, getPort, isDev } from "@modern-js/utils";
|
|
178
178
|
import { legacySchema, schema } from "../schema";
|
|
179
|
-
import {
|
|
179
|
+
import { isDevCommand } from "../utils/commands";
|
|
180
180
|
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
|
181
181
|
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
|
|
182
182
|
var initialize_default = function() {
|
|
@@ -234,11 +234,13 @@ var initialize_default = function() {
|
|
|
234
234
|
tools: normalizedConfig.tools || {},
|
|
235
235
|
testing: normalizedConfig.testing || {},
|
|
236
236
|
plugins: normalizedConfig.plugins || [],
|
|
237
|
+
builderPlugins: normalizedConfig.builderPlugins || [],
|
|
237
238
|
runtime: normalizedConfig.runtime || {},
|
|
238
239
|
runtimeByEntries: normalizedConfig.runtimeByEntries || {},
|
|
239
240
|
deploy: normalizedConfig.deploy || {},
|
|
240
241
|
performance: normalizedConfig.performance || {},
|
|
241
|
-
experiments: normalizedConfig.experiments || {}
|
|
242
|
+
experiments: normalizedConfig.experiments || {},
|
|
243
|
+
autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
];
|
|
@@ -255,12 +257,11 @@ function getDevServerPort(appContext, resolved) {
|
|
|
255
257
|
}
|
|
256
258
|
function _getDevServerPort() {
|
|
257
259
|
_getDevServerPort = _asyncToGenerator(function(appContext, resolved) {
|
|
258
|
-
var
|
|
260
|
+
var _port, _tmp;
|
|
259
261
|
return __generator(this, function(_state) {
|
|
260
262
|
switch(_state.label){
|
|
261
263
|
case 0:
|
|
262
|
-
|
|
263
|
-
if (!(isDev() && command === "dev")) return [
|
|
264
|
+
if (!(isDev() && isDevCommand())) return [
|
|
264
265
|
3,
|
|
265
266
|
4
|
|
266
267
|
];
|
|
@@ -57,6 +57,9 @@ var source = {
|
|
|
57
57
|
entriesDir: {
|
|
58
58
|
type: "string"
|
|
59
59
|
},
|
|
60
|
+
disableEntryDirs: {
|
|
61
|
+
type: "array"
|
|
62
|
+
},
|
|
60
63
|
configDir: {
|
|
61
64
|
type: "string"
|
|
62
65
|
},
|
|
@@ -176,7 +179,10 @@ var deploy = {
|
|
|
176
179
|
]
|
|
177
180
|
}
|
|
178
181
|
};
|
|
182
|
+
var builderPlugins = {
|
|
183
|
+
type: "array"
|
|
184
|
+
};
|
|
179
185
|
var schema = new Schema();
|
|
180
|
-
schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
|
|
186
|
+
schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy).set("builderPlugin", builderPlugins);
|
|
181
187
|
import { default as default2 } from "./legacy";
|
|
182
188
|
export { default2 as legacySchema, schema };
|
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
function _defineProperty(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _objectSpread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_defineProperty(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function ownKeys(object, enumerableOnly) {
|
|
59
|
+
var keys = Object.keys(object);
|
|
60
|
+
if (Object.getOwnPropertySymbols) {
|
|
61
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
+
if (enumerableOnly) {
|
|
63
|
+
symbols = symbols.filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
keys.push.apply(keys, symbols);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
function _objectSpreadProps(target, source) {
|
|
72
|
+
source = source != null ? source : {};
|
|
73
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
+
} else {
|
|
76
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
82
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
83
|
+
var f, y, t, g, _ = {
|
|
84
|
+
label: 0,
|
|
85
|
+
sent: function() {
|
|
86
|
+
if (t[0] & 1) throw t[1];
|
|
87
|
+
return t[1];
|
|
88
|
+
},
|
|
89
|
+
trys: [],
|
|
90
|
+
ops: []
|
|
91
|
+
};
|
|
92
|
+
return g = {
|
|
93
|
+
next: verb(0),
|
|
94
|
+
"throw": verb(1),
|
|
95
|
+
"return": verb(2)
|
|
96
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
97
|
+
return this;
|
|
98
|
+
}), g;
|
|
99
|
+
function verb(n) {
|
|
100
|
+
return function(v) {
|
|
101
|
+
return step([
|
|
102
|
+
n,
|
|
103
|
+
v
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function step(op) {
|
|
108
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
109
|
+
while(_)try {
|
|
110
|
+
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;
|
|
111
|
+
if (y = 0, t) op = [
|
|
112
|
+
op[0] & 2,
|
|
113
|
+
t.value
|
|
114
|
+
];
|
|
115
|
+
switch(op[0]){
|
|
116
|
+
case 0:
|
|
117
|
+
case 1:
|
|
118
|
+
t = op;
|
|
119
|
+
break;
|
|
120
|
+
case 4:
|
|
121
|
+
_.label++;
|
|
122
|
+
return {
|
|
123
|
+
value: op[1],
|
|
124
|
+
done: false
|
|
125
|
+
};
|
|
126
|
+
case 5:
|
|
127
|
+
_.label++;
|
|
128
|
+
y = op[1];
|
|
129
|
+
op = [
|
|
130
|
+
0
|
|
131
|
+
];
|
|
132
|
+
continue;
|
|
133
|
+
case 7:
|
|
134
|
+
op = _.ops.pop();
|
|
135
|
+
_.trys.pop();
|
|
136
|
+
continue;
|
|
137
|
+
default:
|
|
138
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
139
|
+
_ = 0;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
143
|
+
_.label = op[1];
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
147
|
+
_.label = t[1];
|
|
148
|
+
t = op;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
if (t && _.label < t[2]) {
|
|
152
|
+
_.label = t[2];
|
|
153
|
+
_.ops.push(op);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
if (t[2]) _.ops.pop();
|
|
157
|
+
_.trys.pop();
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
op = body.call(thisArg, _);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
op = [
|
|
163
|
+
6,
|
|
164
|
+
e
|
|
165
|
+
];
|
|
166
|
+
y = 0;
|
|
167
|
+
} finally{
|
|
168
|
+
f = t = 0;
|
|
169
|
+
}
|
|
170
|
+
if (op[0] & 5) throw op[1];
|
|
171
|
+
return {
|
|
172
|
+
value: op[0] ? op[1] : void 0,
|
|
173
|
+
done: true
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
function getServerInternalPlugins(api) {
|
|
178
|
+
return _getServerInternalPlugins.apply(this, arguments);
|
|
179
|
+
}
|
|
180
|
+
function _getServerInternalPlugins() {
|
|
181
|
+
_getServerInternalPlugins = _asyncToGenerator(function(api) {
|
|
182
|
+
var hookRunners, ref, serverPlugins, serverInternalPlugins;
|
|
183
|
+
return __generator(this, function(_state) {
|
|
184
|
+
switch(_state.label){
|
|
185
|
+
case 0:
|
|
186
|
+
hookRunners = api.useHookRunners();
|
|
187
|
+
return [
|
|
188
|
+
4,
|
|
189
|
+
hookRunners.collectServerPlugins({
|
|
190
|
+
plugins: []
|
|
191
|
+
})
|
|
192
|
+
];
|
|
193
|
+
case 1:
|
|
194
|
+
ref = _state.sent(), serverPlugins = ref.plugins;
|
|
195
|
+
serverInternalPlugins = serverPlugins.reduce(function(result, plugin) {
|
|
196
|
+
return Object.assign(result, plugin);
|
|
197
|
+
}, {});
|
|
198
|
+
api.setAppContext(_objectSpreadProps(_objectSpread({}, api.useAppContext()), {
|
|
199
|
+
serverInternalPlugins: serverInternalPlugins
|
|
200
|
+
}));
|
|
201
|
+
return [
|
|
202
|
+
2,
|
|
203
|
+
serverInternalPlugins
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
return _getServerInternalPlugins.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
export { getServerInternalPlugins };
|
|
@@ -15,4 +15,13 @@ export declare const FILE_SYSTEM_ROUTES_INDEX = "index";
|
|
|
15
15
|
export declare const FILE_SYSTEM_ROUTES_IGNORED_REGEX: RegExp;
|
|
16
16
|
export declare const HTML_PARTIALS_FOLDER = "html";
|
|
17
17
|
export declare const HTML_PARTIALS_EXTENSIONS: string[];
|
|
18
|
-
export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
18
|
+
export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
19
|
+
export declare const NESTED_ROUTE: {
|
|
20
|
+
LAYOUT_FILE: string;
|
|
21
|
+
LAYOUT_LOADER_FILE: string;
|
|
22
|
+
PAGE_FILE: string;
|
|
23
|
+
PAGE_LOADER_FILE: string;
|
|
24
|
+
LOADING_FILE: string;
|
|
25
|
+
ERROR_FILE: string;
|
|
26
|
+
LOADER_FILE: string;
|
|
27
|
+
};
|
|
@@ -14,7 +14,8 @@ export declare const getDefaultImports: ({
|
|
|
14
14
|
internalDirAlias: string;
|
|
15
15
|
internalDirectory: string;
|
|
16
16
|
}) => ImportStatement[];
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const isPageComponentFile: (filePath: string) => boolean;
|
|
18
|
+
export declare const isNestedRouteComponent: (nestedRouteEntries: string[], absoluteFilePath: string) => boolean;
|
|
18
19
|
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
19
20
|
export declare const parseModule: ({
|
|
20
21
|
source,
|
|
File without changes
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CliPlugin, PluginAPI } from '@modern-js/core';
|
|
|
3
3
|
import { AppTools } from './types';
|
|
4
4
|
export * from './defineConfig';
|
|
5
5
|
export * from './types';
|
|
6
|
+
export type { RuntimeUserConfig } from './types/config';
|
|
6
7
|
export declare const devCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
|
|
7
8
|
export declare const buildCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
|
|
8
9
|
|
|
@@ -14,7 +14,7 @@ declare const localeKeys: {
|
|
|
14
14
|
build: {
|
|
15
15
|
describe: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
serve: {
|
|
18
18
|
describe: string;
|
|
19
19
|
};
|
|
20
20
|
deploy: {
|
|
@@ -47,7 +47,7 @@ declare const localeKeys: {
|
|
|
47
47
|
build: {
|
|
48
48
|
describe: string;
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
serve: {
|
|
51
51
|
describe: string;
|
|
52
52
|
};
|
|
53
53
|
deploy: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UserConfig } from '@modern-js/core';
|
|
2
2
|
import type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig } from '@modern-js/server-core';
|
|
3
|
+
import type { BuilderPlugin } from '@modern-js/builder-webpack-provider';
|
|
3
4
|
import type { AppToolsHooks } from '../hooks';
|
|
4
5
|
import type { OutputNormalizedConfig, OutputUserConfig } from './output';
|
|
5
6
|
import type { SourceNormalizedConfig, SourceUserConfig } from './source';
|
|
@@ -32,6 +33,7 @@ export interface AppToolsUserConfig {
|
|
|
32
33
|
runtimeByEntries?: RuntimeByEntriesUserConfig;
|
|
33
34
|
performance?: PerformanceUserConfig;
|
|
34
35
|
experiments?: ExperimentsUserConfig;
|
|
36
|
+
builderPlugins?: BuilderPlugin[];
|
|
35
37
|
/**
|
|
36
38
|
* The configuration of `bff` is provided by `bff` plugin.
|
|
37
39
|
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
@@ -54,6 +56,7 @@ export declare type AppToolsNormalizedConfig = {
|
|
|
54
56
|
tools: ToolsNormalizedConfig;
|
|
55
57
|
performance: PerformanceNormalizedConfig;
|
|
56
58
|
experiments: ExperimentsNormalizedConfig;
|
|
59
|
+
builderPlugins: BuilderPlugin[];
|
|
57
60
|
cliOptions?: Record<string, any>;
|
|
58
61
|
_raw: UserConfig<{
|
|
59
62
|
hooks: AppToolsHooks;
|
|
@@ -11,6 +11,7 @@ export interface SourceUserConfig extends BuilderSourceConfig {
|
|
|
11
11
|
enableAsyncEntry?: boolean;
|
|
12
12
|
disableDefaultEntries?: boolean;
|
|
13
13
|
entriesDir?: string;
|
|
14
|
+
disableEntryDirs?: string[];
|
|
14
15
|
configDir?: string;
|
|
15
16
|
/**
|
|
16
17
|
* The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
|