@modern-js/app-tools 2.0.0-beta.2 → 2.0.0-canary.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/CHANGELOG.md +251 -0
- package/bin/modern.js +10 -1
- package/dist/js/modern/analyze/constants.js +38 -16
- package/dist/js/modern/analyze/generateCode.js +271 -211
- package/dist/js/modern/analyze/getBundleEntry.js +31 -32
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +93 -49
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +89 -47
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -2
- package/dist/js/modern/analyze/getClientRoutes/utils.js +23 -10
- package/dist/js/modern/analyze/getFileSystemEntry.js +43 -22
- package/dist/js/modern/analyze/getHtmlTemplate.js +89 -49
- package/dist/js/modern/analyze/getServerRoutes.js +122 -126
- package/dist/js/modern/analyze/index.js +193 -159
- package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -16
- package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -11
- package/dist/js/modern/analyze/nestedRoutes.js +110 -53
- package/dist/js/modern/analyze/templates.js +190 -77
- package/dist/js/modern/analyze/utils.js +98 -51
- package/dist/js/modern/builder/builderPlugins/compatModern.js +124 -107
- package/dist/js/modern/builder/index.js +123 -86
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +22 -20
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +23 -22
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +31 -27
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +98 -84
- package/dist/js/modern/commands/build.js +67 -42
- package/dist/js/modern/commands/deploy.js +27 -4
- package/dist/js/modern/commands/dev.js +93 -47
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/inspect.js +30 -5
- package/dist/js/modern/commands/start.js +37 -16
- package/dist/js/modern/config/default.js +103 -114
- package/dist/js/modern/config/index.js +8 -2
- package/dist/js/modern/config/initial/createHtmlConfig.js +5 -2
- package/dist/js/modern/config/initial/createOutputConfig.js +11 -9
- package/dist/js/modern/config/initial/createSourceConfig.js +5 -2
- package/dist/js/modern/config/initial/createToolsConfig.js +7 -6
- package/dist/js/modern/config/initial/index.js +9 -4
- package/dist/js/modern/config/initial/inits.js +109 -73
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +6 -3
- package/dist/js/modern/defineConfig.js +26 -11
- package/dist/js/modern/exports/server.js +4 -1
- package/dist/js/modern/hooks.js +10 -3
- package/dist/js/modern/index.js +140 -89
- package/dist/js/modern/initialize/index.js +98 -51
- package/dist/js/modern/locale/en.js +20 -21
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +21 -22
- package/dist/js/modern/schema/Schema.js +6 -5
- package/dist/js/modern/schema/index.js +51 -100
- package/dist/js/modern/schema/legacy.js +96 -231
- package/dist/js/modern/types/config/index.js +0 -1
- package/dist/js/modern/types/index.js +0 -1
- package/dist/js/modern/types/legacyConfig/output.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -2
- package/dist/js/modern/utils/config.js +102 -41
- package/dist/js/modern/utils/createFileWatcher.js +84 -51
- package/dist/js/modern/utils/createServer.js +63 -17
- package/dist/js/modern/utils/getSpecifiedEntries.js +46 -19
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/modern/utils/printInstructions.js +27 -8
- package/dist/js/modern/utils/restart.js +43 -16
- package/dist/js/modern/utils/routes.js +29 -12
- package/dist/js/node/analyze/constants.js +54 -35
- package/dist/js/node/analyze/generateCode.js +290 -228
- package/dist/js/node/analyze/getBundleEntry.js +55 -44
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +132 -76
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +128 -74
- package/dist/js/node/analyze/getClientRoutes/index.js +23 -17
- package/dist/js/node/analyze/getClientRoutes/utils.js +44 -21
- package/dist/js/node/analyze/getFileSystemEntry.js +70 -39
- package/dist/js/node/analyze/getHtmlTemplate.js +116 -61
- package/dist/js/node/analyze/getServerRoutes.js +143 -137
- package/dist/js/node/analyze/index.js +240 -174
- package/dist/js/node/analyze/isDefaultExportFunction.js +55 -26
- package/dist/js/node/analyze/makeLegalIdentifier.js +27 -15
- package/dist/js/node/analyze/nestedRoutes.js +140 -67
- package/dist/js/node/analyze/templates.js +211 -84
- package/dist/js/node/analyze/utils.js +123 -62
- package/dist/js/node/builder/builderPlugins/compatModern.js +152 -120
- package/dist/js/node/builder/index.js +151 -95
- package/dist/js/node/builder/loaders/routerLoader.js +36 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +26 -0
- package/dist/js/node/builder/share.js +45 -25
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +39 -26
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +47 -31
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +116 -90
- package/dist/js/node/commands/build.js +89 -52
- package/dist/js/node/commands/deploy.js +45 -10
- package/dist/js/node/commands/dev.js +115 -61
- package/dist/js/node/commands/index.js +19 -38
- package/dist/js/node/commands/inspect.js +48 -11
- package/dist/js/node/commands/start.js +65 -27
- package/dist/js/node/config/default.js +119 -118
- package/dist/js/node/config/index.js +25 -29
- package/dist/js/node/config/initial/createHtmlConfig.js +22 -6
- package/dist/js/node/config/initial/createOutputConfig.js +28 -13
- package/dist/js/node/config/initial/createSourceConfig.js +22 -6
- package/dist/js/node/config/initial/createToolsConfig.js +24 -10
- package/dist/js/node/config/initial/index.js +28 -17
- package/dist/js/node/config/initial/inits.js +126 -81
- package/dist/js/node/config/initial/transformNormalizedConfig.js +31 -15
- package/dist/js/node/defineConfig.js +43 -17
- package/dist/js/node/exports/server.js +21 -10
- package/dist/js/node/hooks.js +44 -29
- package/dist/js/node/index.js +190 -130
- package/dist/js/node/initialize/index.js +116 -61
- package/dist/js/node/locale/en.js +36 -25
- package/dist/js/node/locale/index.js +27 -15
- package/dist/js/node/locale/zh.js +37 -26
- package/dist/js/node/schema/Schema.js +23 -10
- package/dist/js/node/schema/index.js +77 -114
- package/dist/js/node/schema/legacy.js +117 -240
- package/dist/js/node/types/config/index.js +17 -16
- package/dist/js/node/types/index.js +19 -38
- package/dist/js/node/types/legacyConfig/output.js +0 -5
- package/dist/js/node/utils/commands.js +21 -6
- package/dist/js/node/utils/config.js +120 -51
- package/dist/js/node/utils/createFileWatcher.js +104 -60
- package/dist/js/node/utils/createServer.js +86 -25
- package/dist/js/node/utils/getSpecifiedEntries.js +64 -25
- package/dist/js/node/utils/language.js +24 -8
- package/dist/js/node/utils/printInstructions.js +47 -16
- package/dist/js/node/utils/restart.js +61 -21
- package/dist/js/node/utils/routes.js +53 -18
- package/dist/js/treeshaking/analyze/constants.js +28 -16
- package/dist/js/treeshaking/analyze/generateCode.js +604 -355
- package/dist/js/treeshaking/analyze/getBundleEntry.js +52 -63
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +214 -168
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +215 -169
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -2
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +19 -20
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +89 -86
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +298 -125
- package/dist/js/treeshaking/analyze/getServerRoutes.js +210 -146
- package/dist/js/treeshaking/analyze/index.js +558 -303
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +45 -26
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -16
- package/dist/js/treeshaking/analyze/nestedRoutes.js +414 -160
- package/dist/js/treeshaking/analyze/templates.js +432 -161
- package/dist/js/treeshaking/analyze/utils.js +361 -80
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +281 -195
- package/dist/js/treeshaking/builder/index.js +371 -165
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +41 -44
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +108 -44
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +70 -39
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +332 -112
- package/dist/js/treeshaking/commands/build.js +286 -88
- package/dist/js/treeshaking/commands/deploy.js +153 -25
- package/dist/js/treeshaking/commands/dev.js +318 -132
- package/dist/js/treeshaking/commands/index.js +1 -1
- package/dist/js/treeshaking/commands/inspect.js +147 -32
- package/dist/js/treeshaking/commands/start.js +190 -68
- package/dist/js/treeshaking/config/default.js +210 -199
- package/dist/js/treeshaking/config/index.js +3 -2
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -31
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +43 -67
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +37 -40
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -38
- package/dist/js/treeshaking/config/initial/index.js +10 -9
- package/dist/js/treeshaking/config/initial/inits.js +205 -106
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +27 -34
- package/dist/js/treeshaking/defineConfig.js +60 -13
- package/dist/js/treeshaking/exports/server.js +2 -1
- package/dist/js/treeshaking/hooks.js +26 -25
- package/dist/js/treeshaking/index.js +465 -257
- package/dist/js/treeshaking/initialize/index.js +290 -112
- package/dist/js/treeshaking/locale/en.js +34 -33
- package/dist/js/treeshaking/locale/index.js +5 -5
- package/dist/js/treeshaking/locale/zh.js +34 -33
- package/dist/js/treeshaking/schema/Schema.js +267 -69
- package/dist/js/treeshaking/schema/index.js +165 -121
- package/dist/js/treeshaking/schema/legacy.js +323 -256
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +0 -1
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -1
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/commands.js +6 -5
- package/dist/js/treeshaking/utils/config.js +295 -117
- package/dist/js/treeshaking/utils/createFileWatcher.js +278 -118
- package/dist/js/treeshaking/utils/createServer.js +252 -67
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +182 -55
- package/dist/js/treeshaking/utils/language.js +6 -5
- package/dist/js/treeshaking/utils/printInstructions.js +151 -29
- package/dist/js/treeshaking/utils/restart.js +184 -42
- package/dist/js/treeshaking/utils/routes.js +151 -27
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/analyze/constants.d.ts +2 -0
- package/dist/types/analyze/index.d.ts +2 -0
- package/dist/types/analyze/templates.d.ts +8 -7
- package/dist/types/analyze/utils.d.ts +9 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
- package/dist/types/builder/index.d.ts +2 -2
- package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +1 -7
- package/dist/types/defineConfig.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/initialize/index.d.ts +2 -0
- package/dist/types/types/config/index.d.ts +1 -0
- package/dist/types/types/config/output.d.ts +0 -1
- package/dist/types/types/config/source.d.ts +1 -0
- package/dist/types/types/config/tools.d.ts +10 -1
- package/dist/types/types/hooks.d.ts +2 -1
- package/dist/types/types/legacyConfig/dev.d.ts +1 -0
- package/dist/types/types/legacyConfig/output.d.ts +1 -1
- package/dist/types/types/legacyConfig/source.d.ts +1 -0
- package/dist/types/types/legacyConfig/tools.d.ts +1 -0
- package/dist/types/utils/config.d.ts +1 -0
- package/dist/types/utils/createFileWatcher.d.ts +2 -1
- package/dist/types/utils/createServer.d.ts +1 -0
- package/dist/types/utils/restart.d.ts +1 -1
- package/lib/types.d.ts +1 -1
- package/package.json +27 -23
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
function createDefaultConfig(appContext) {
|
|
2
2
|
const defaultAlias = appContext ? {
|
|
3
3
|
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
4
4
|
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
"@": appContext.srcDirectory,
|
|
6
|
+
"@shared": appContext.sharedDirectory
|
|
7
7
|
} : {};
|
|
8
8
|
const source = {
|
|
9
|
-
entries:
|
|
9
|
+
entries: void 0,
|
|
10
10
|
enableAsyncEntry: false,
|
|
11
11
|
disableDefaultEntries: false,
|
|
12
|
-
entriesDir:
|
|
13
|
-
configDir:
|
|
14
|
-
globalVars:
|
|
15
|
-
moduleScopes:
|
|
12
|
+
entriesDir: "./src",
|
|
13
|
+
configDir: "./config",
|
|
14
|
+
globalVars: void 0,
|
|
15
|
+
moduleScopes: void 0,
|
|
16
16
|
include: [],
|
|
17
17
|
alias: defaultAlias
|
|
18
18
|
};
|
|
19
19
|
const output = {
|
|
20
|
-
assetPrefix:
|
|
20
|
+
assetPrefix: "/",
|
|
21
21
|
distPath: {
|
|
22
|
-
html:
|
|
23
|
-
js:
|
|
24
|
-
css:
|
|
25
|
-
media:
|
|
26
|
-
root:
|
|
22
|
+
html: "html",
|
|
23
|
+
js: "static/js",
|
|
24
|
+
css: "static/css",
|
|
25
|
+
media: "static/media",
|
|
26
|
+
root: "dist"
|
|
27
27
|
},
|
|
28
|
-
copy:
|
|
28
|
+
copy: void 0,
|
|
29
29
|
disableCssModuleExtension: false,
|
|
30
30
|
enableCssModuleTSDeclaration: false,
|
|
31
31
|
disableMinimize: false,
|
|
@@ -35,44 +35,38 @@ export function createDefaultConfig(appContext) {
|
|
|
35
35
|
disableInlineRuntimeChunk: false,
|
|
36
36
|
disableFilenameHash: false,
|
|
37
37
|
enableLatestDecorators: false,
|
|
38
|
-
polyfill:
|
|
39
|
-
|
|
40
|
-
cssModuleLocalIdentName: undefined
|
|
38
|
+
polyfill: "entry",
|
|
39
|
+
cssModuleLocalIdentName: void 0
|
|
41
40
|
};
|
|
42
41
|
const html = {
|
|
43
|
-
title:
|
|
44
|
-
titleByEntries:
|
|
42
|
+
title: "",
|
|
43
|
+
titleByEntries: void 0,
|
|
45
44
|
meta: {
|
|
46
|
-
charset: {
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
renderer: 'webkit',
|
|
55
|
-
layoutmode: 'standard',
|
|
56
|
-
imagemode: 'force',
|
|
57
|
-
'wap-font-scale': 'no',
|
|
58
|
-
'format-detection': 'telephone=no'
|
|
45
|
+
charset: { charset: "utf-8" },
|
|
46
|
+
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
|
47
|
+
"http-equiv": { "http-equiv": "x-ua-compatible", content: "ie=edge" },
|
|
48
|
+
renderer: "webkit",
|
|
49
|
+
layoutmode: "standard",
|
|
50
|
+
imagemode: "force",
|
|
51
|
+
"wap-font-scale": "no",
|
|
52
|
+
"format-detection": "telephone=no"
|
|
59
53
|
},
|
|
60
|
-
metaByEntries:
|
|
61
|
-
inject:
|
|
62
|
-
injectByEntries:
|
|
63
|
-
mountId:
|
|
64
|
-
favicon:
|
|
65
|
-
faviconByEntries:
|
|
54
|
+
metaByEntries: void 0,
|
|
55
|
+
inject: "head",
|
|
56
|
+
injectByEntries: void 0,
|
|
57
|
+
mountId: "root",
|
|
58
|
+
favicon: "",
|
|
59
|
+
faviconByEntries: void 0,
|
|
66
60
|
disableHtmlFolder: false,
|
|
67
61
|
templateParameters: {},
|
|
68
|
-
templateParametersByEntries:
|
|
62
|
+
templateParametersByEntries: void 0
|
|
69
63
|
};
|
|
70
64
|
const server = {
|
|
71
|
-
routes:
|
|
72
|
-
publicRoutes:
|
|
73
|
-
ssr:
|
|
74
|
-
ssrByEntries:
|
|
75
|
-
baseUrl:
|
|
65
|
+
routes: void 0,
|
|
66
|
+
publicRoutes: void 0,
|
|
67
|
+
ssr: void 0,
|
|
68
|
+
ssrByEntries: void 0,
|
|
69
|
+
baseUrl: "/",
|
|
76
70
|
port: 8080
|
|
77
71
|
};
|
|
78
72
|
const dev = {
|
|
@@ -80,14 +74,14 @@ export function createDefaultConfig(appContext) {
|
|
|
80
74
|
https: false
|
|
81
75
|
};
|
|
82
76
|
const tools = {
|
|
83
|
-
webpack:
|
|
84
|
-
babel:
|
|
85
|
-
postcss:
|
|
86
|
-
autoprefixer:
|
|
87
|
-
devServer:
|
|
88
|
-
tsLoader:
|
|
89
|
-
terser:
|
|
90
|
-
minifyCss:
|
|
77
|
+
webpack: void 0,
|
|
78
|
+
babel: void 0,
|
|
79
|
+
postcss: void 0,
|
|
80
|
+
autoprefixer: void 0,
|
|
81
|
+
devServer: void 0,
|
|
82
|
+
tsLoader: void 0,
|
|
83
|
+
terser: void 0,
|
|
84
|
+
minifyCss: void 0
|
|
91
85
|
};
|
|
92
86
|
return {
|
|
93
87
|
source,
|
|
@@ -101,57 +95,52 @@ export function createDefaultConfig(appContext) {
|
|
|
101
95
|
runtimeByEntries: {}
|
|
102
96
|
};
|
|
103
97
|
}
|
|
104
|
-
|
|
98
|
+
function createLegacyDefaultConfig(appContext) {
|
|
105
99
|
const defaultAlias = appContext ? {
|
|
106
100
|
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
107
101
|
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
"@": appContext.srcDirectory,
|
|
103
|
+
"@shared": appContext.sharedDirectory
|
|
110
104
|
} : {};
|
|
111
105
|
const sourceDefaults = {
|
|
112
|
-
entries:
|
|
106
|
+
entries: void 0,
|
|
113
107
|
enableAsyncEntry: false,
|
|
114
108
|
disableDefaultEntries: false,
|
|
115
|
-
entriesDir:
|
|
116
|
-
configDir:
|
|
117
|
-
apiDir:
|
|
109
|
+
entriesDir: "./src",
|
|
110
|
+
configDir: "./config",
|
|
111
|
+
apiDir: "./api",
|
|
118
112
|
envVars: [],
|
|
119
|
-
globalVars:
|
|
113
|
+
globalVars: void 0,
|
|
120
114
|
alias: defaultAlias,
|
|
121
|
-
moduleScopes:
|
|
115
|
+
moduleScopes: void 0,
|
|
122
116
|
include: []
|
|
123
117
|
};
|
|
124
118
|
const outputDefaults = {
|
|
125
|
-
assetPrefix:
|
|
126
|
-
htmlPath:
|
|
127
|
-
jsPath:
|
|
128
|
-
cssPath:
|
|
129
|
-
mediaPath:
|
|
130
|
-
path:
|
|
131
|
-
title:
|
|
132
|
-
titleByEntries:
|
|
119
|
+
assetPrefix: "/",
|
|
120
|
+
htmlPath: "html",
|
|
121
|
+
jsPath: "static/js",
|
|
122
|
+
cssPath: "static/css",
|
|
123
|
+
mediaPath: "static/media",
|
|
124
|
+
path: "dist",
|
|
125
|
+
title: "",
|
|
126
|
+
titleByEntries: void 0,
|
|
133
127
|
meta: {
|
|
134
|
-
charset: {
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
renderer: 'webkit',
|
|
143
|
-
layoutmode: 'standard',
|
|
144
|
-
imagemode: 'force',
|
|
145
|
-
'wap-font-scale': 'no',
|
|
146
|
-
'format-detection': 'telephone=no'
|
|
128
|
+
charset: { charset: "utf-8" },
|
|
129
|
+
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
|
130
|
+
"http-equiv": { "http-equiv": "x-ua-compatible", content: "ie=edge" },
|
|
131
|
+
renderer: "webkit",
|
|
132
|
+
layoutmode: "standard",
|
|
133
|
+
imagemode: "force",
|
|
134
|
+
"wap-font-scale": "no",
|
|
135
|
+
"format-detection": "telephone=no"
|
|
147
136
|
},
|
|
148
|
-
metaByEntries:
|
|
149
|
-
inject:
|
|
150
|
-
injectByEntries:
|
|
151
|
-
mountId:
|
|
152
|
-
favicon:
|
|
153
|
-
faviconByEntries:
|
|
154
|
-
copy:
|
|
137
|
+
metaByEntries: void 0,
|
|
138
|
+
inject: "head",
|
|
139
|
+
injectByEntries: void 0,
|
|
140
|
+
mountId: "root",
|
|
141
|
+
favicon: "",
|
|
142
|
+
faviconByEntries: void 0,
|
|
143
|
+
copy: void 0,
|
|
155
144
|
disableHtmlFolder: false,
|
|
156
145
|
disableCssModuleExtension: false,
|
|
157
146
|
disableCssExtract: false,
|
|
@@ -163,37 +152,33 @@ export function createLegacyDefaultConfig(appContext) {
|
|
|
163
152
|
disableInlineRuntimeChunk: false,
|
|
164
153
|
disableAssetsCache: false,
|
|
165
154
|
enableLatestDecorators: false,
|
|
166
|
-
polyfill:
|
|
167
|
-
dataUriLimit:
|
|
155
|
+
polyfill: "entry",
|
|
156
|
+
dataUriLimit: 1e4,
|
|
168
157
|
templateParameters: {},
|
|
169
|
-
templateParametersByEntries:
|
|
170
|
-
cssModuleLocalIdentName:
|
|
171
|
-
enableModernMode: false,
|
|
158
|
+
templateParametersByEntries: void 0,
|
|
159
|
+
cssModuleLocalIdentName: void 0,
|
|
172
160
|
disableNodePolyfill: false,
|
|
173
161
|
enableTsLoader: false
|
|
174
162
|
};
|
|
175
163
|
const serverDefaults = {
|
|
176
|
-
routes:
|
|
177
|
-
publicRoutes:
|
|
178
|
-
ssr:
|
|
179
|
-
ssrByEntries:
|
|
180
|
-
baseUrl:
|
|
164
|
+
routes: void 0,
|
|
165
|
+
publicRoutes: void 0,
|
|
166
|
+
ssr: void 0,
|
|
167
|
+
ssrByEntries: void 0,
|
|
168
|
+
baseUrl: "/",
|
|
181
169
|
port: 8080
|
|
182
170
|
};
|
|
183
|
-
const devDefaults = {
|
|
184
|
-
assetPrefix: false,
|
|
185
|
-
https: false
|
|
186
|
-
};
|
|
171
|
+
const devDefaults = { assetPrefix: false, https: false };
|
|
187
172
|
const toolsDefaults = {
|
|
188
|
-
webpack:
|
|
189
|
-
babel:
|
|
190
|
-
postcss:
|
|
191
|
-
autoprefixer:
|
|
192
|
-
lodash:
|
|
193
|
-
devServer:
|
|
194
|
-
tsLoader:
|
|
195
|
-
terser:
|
|
196
|
-
minifyCss:
|
|
173
|
+
webpack: void 0,
|
|
174
|
+
babel: void 0,
|
|
175
|
+
postcss: void 0,
|
|
176
|
+
autoprefixer: void 0,
|
|
177
|
+
lodash: void 0,
|
|
178
|
+
devServer: void 0,
|
|
179
|
+
tsLoader: void 0,
|
|
180
|
+
terser: void 0,
|
|
181
|
+
minifyCss: void 0
|
|
197
182
|
};
|
|
198
183
|
return {
|
|
199
184
|
source: sourceDefaults,
|
|
@@ -204,4 +189,8 @@ export function createLegacyDefaultConfig(appContext) {
|
|
|
204
189
|
runtime: {},
|
|
205
190
|
runtimeByEntries: {}
|
|
206
191
|
};
|
|
207
|
-
}
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
createDefaultConfig,
|
|
195
|
+
createLegacyDefaultConfig
|
|
196
|
+
};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createDefaultConfig, createLegacyDefaultConfig } from "./default";
|
|
2
|
+
import { initialNormalizedConfig, checkIsLegacyConfig } from "./initial";
|
|
3
|
+
export {
|
|
4
|
+
checkIsLegacyConfig,
|
|
5
|
+
createDefaultConfig,
|
|
6
|
+
createLegacyDefaultConfig,
|
|
7
|
+
initialNormalizedConfig
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function createHtmlConfig(config) {
|
|
2
2
|
const {
|
|
3
3
|
disableHtmlFolder,
|
|
4
4
|
favicon,
|
|
@@ -29,4 +29,7 @@ export function createHtmlConfig(config) {
|
|
|
29
29
|
templateParameters,
|
|
30
30
|
templateParametersByEntries
|
|
31
31
|
};
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createHtmlConfig
|
|
35
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function createOutputConfig(config) {
|
|
2
2
|
const {
|
|
3
3
|
assetPrefix,
|
|
4
4
|
copy,
|
|
@@ -23,7 +23,6 @@ export function createOutputConfig(config) {
|
|
|
23
23
|
enableLatestDecorators,
|
|
24
24
|
disableCssModuleExtension,
|
|
25
25
|
ssg,
|
|
26
|
-
enableModernMode,
|
|
27
26
|
disableNodePolyfill
|
|
28
27
|
} = config.output;
|
|
29
28
|
return {
|
|
@@ -34,11 +33,10 @@ export function createOutputConfig(config) {
|
|
|
34
33
|
css: cssPath,
|
|
35
34
|
js: jsPath,
|
|
36
35
|
html: htmlPath,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
media: mediaPath || 'media'
|
|
36
|
+
svg: mediaPath || "media",
|
|
37
|
+
image: mediaPath || "media",
|
|
38
|
+
font: mediaPath || "media",
|
|
39
|
+
media: mediaPath || "media"
|
|
42
40
|
},
|
|
43
41
|
dataUriLimit: {
|
|
44
42
|
svg: dataUriLimit,
|
|
@@ -62,7 +60,11 @@ export function createOutputConfig(config) {
|
|
|
62
60
|
css: cssModuleLocalIdentName
|
|
63
61
|
},
|
|
64
62
|
ssg,
|
|
65
|
-
|
|
63
|
+
enableAssetFallback: true,
|
|
64
|
+
enableAssetManifest: true,
|
|
66
65
|
disableNodePolyfill
|
|
67
66
|
};
|
|
68
|
-
}
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
createOutputConfig
|
|
70
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function createSourceConfig(config) {
|
|
2
2
|
const {
|
|
3
3
|
alias,
|
|
4
4
|
envVars,
|
|
@@ -29,4 +29,7 @@ export function createSourceConfig(config) {
|
|
|
29
29
|
entriesDir,
|
|
30
30
|
configDir
|
|
31
31
|
};
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createSourceConfig
|
|
35
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function createToolsConfig(config) {
|
|
2
2
|
const {
|
|
3
3
|
autoprefixer,
|
|
4
4
|
babel,
|
|
@@ -17,11 +17,9 @@ export function createToolsConfig(config) {
|
|
|
17
17
|
jest,
|
|
18
18
|
esbuild
|
|
19
19
|
} = config.tools;
|
|
20
|
-
const {
|
|
21
|
-
enableTsLoader
|
|
22
|
-
} = config.output;
|
|
20
|
+
const { enableTsLoader } = config.output;
|
|
23
21
|
return {
|
|
24
|
-
tsLoader: enableTsLoader ? tsLoader :
|
|
22
|
+
tsLoader: enableTsLoader ? tsLoader : void 0,
|
|
25
23
|
autoprefixer,
|
|
26
24
|
babel,
|
|
27
25
|
minifyCss,
|
|
@@ -38,4 +36,7 @@ export function createToolsConfig(config) {
|
|
|
38
36
|
jest,
|
|
39
37
|
esbuild
|
|
40
38
|
};
|
|
41
|
-
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
createToolsConfig
|
|
42
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { transformNormalizedConfig } from "./transformNormalizedConfig";
|
|
3
|
+
function checkIsLegacyConfig(config) {
|
|
4
4
|
return Boolean(config.legacy);
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
function initialNormalizedConfig(config, appContext) {
|
|
7
7
|
initHtmlConfig(config, appContext);
|
|
8
8
|
initSourceConfig(config, appContext);
|
|
9
9
|
initToolsConfig(config);
|
|
10
10
|
return config;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
checkIsLegacyConfig,
|
|
14
|
+
initialNormalizedConfig,
|
|
15
|
+
transformNormalizedConfig
|
|
16
|
+
};
|
|
@@ -1,69 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
import path, { dirname, isAbsolute, posix, sep } from "path";
|
|
21
|
+
import {
|
|
22
|
+
applyOptionsChain,
|
|
23
|
+
findExists,
|
|
24
|
+
findMonorepoRoot,
|
|
25
|
+
globby,
|
|
26
|
+
isModernjsMonorepo
|
|
27
|
+
} from "@modern-js/utils";
|
|
28
|
+
function initHtmlConfig(config, appContext) {
|
|
29
|
+
const ICON_EXTENSIONS = ["png", "jpg", "jpeg", "svg", "ico"];
|
|
8
30
|
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
|
9
31
|
config.html.favicon = createBuilderFavicon(config, appContext);
|
|
10
32
|
return config.html;
|
|
11
|
-
function createBuilderAppIcon(
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
33
|
+
function createBuilderAppIcon(config2, appContext2) {
|
|
34
|
+
const { configDir } = config2.source;
|
|
35
|
+
const appIcon = findExists(
|
|
36
|
+
ICON_EXTENSIONS.map(
|
|
37
|
+
(ext) => path.resolve(
|
|
38
|
+
appContext2.appDirectory,
|
|
39
|
+
configDir || "./config",
|
|
40
|
+
`icon.${ext}`
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
return typeof appIcon === "string" ? appIcon : void 0;
|
|
17
45
|
}
|
|
18
|
-
function createBuilderFavicon(
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
function createBuilderFavicon(config2, appContext2) {
|
|
47
|
+
const { configDir } = config2.source;
|
|
48
|
+
const { favicon } = config2.html;
|
|
49
|
+
const defaultFavicon = findExists(
|
|
50
|
+
ICON_EXTENSIONS.map(
|
|
51
|
+
(ext) => path.resolve(
|
|
52
|
+
appContext2.appDirectory,
|
|
53
|
+
configDir || "./config",
|
|
54
|
+
`favicon.${ext}`
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
return favicon || defaultFavicon || void 0;
|
|
27
59
|
}
|
|
28
60
|
}
|
|
29
|
-
|
|
61
|
+
function initSourceConfig(config, appContext) {
|
|
30
62
|
config.source.include = createBuilderInclude(config, appContext);
|
|
31
63
|
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
32
|
-
function createBuilderInclude(
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (isAbsolute(include)) {
|
|
40
|
-
return include;
|
|
64
|
+
function createBuilderInclude(config2, appContext2) {
|
|
65
|
+
const { include } = config2.source;
|
|
66
|
+
const defaultInclude = [appContext2.internalDirectory];
|
|
67
|
+
const transformInclude = (include || []).map((include2) => {
|
|
68
|
+
if (typeof include2 === "string") {
|
|
69
|
+
if (isAbsolute(include2)) {
|
|
70
|
+
return include2;
|
|
41
71
|
}
|
|
42
|
-
return new RegExp(
|
|
72
|
+
return new RegExp(include2);
|
|
43
73
|
}
|
|
44
|
-
return
|
|
45
|
-
}).concat(defaultInclude);
|
|
46
|
-
|
|
47
|
-
const root = findMonorepoRoot(appContext.appDirectory);
|
|
74
|
+
return include2;
|
|
75
|
+
}).concat(defaultInclude);
|
|
76
|
+
const root = findMonorepoRoot(appContext2.appDirectory);
|
|
48
77
|
if (!root) {
|
|
49
78
|
return transformInclude;
|
|
50
79
|
}
|
|
51
80
|
const modernjsMonorepo = isModernjsMonorepo(root);
|
|
52
81
|
if (modernjsMonorepo) {
|
|
53
|
-
const paths = globby.sync(posix.join(root,
|
|
54
|
-
ignore: [
|
|
55
|
-
}).map(pathname => dirname(pathname) + sep);
|
|
82
|
+
const paths = globby.sync(posix.join(root, "features", "**", "package.json"), {
|
|
83
|
+
ignore: ["**/node_modules/**/*"]
|
|
84
|
+
}).map((pathname) => dirname(pathname) + sep);
|
|
56
85
|
return [...paths, ...transformInclude];
|
|
57
86
|
}
|
|
58
87
|
return transformInclude;
|
|
59
88
|
}
|
|
60
|
-
function createBuilderModuleScope(
|
|
61
|
-
const {
|
|
62
|
-
moduleScopes
|
|
63
|
-
} = config.source;
|
|
89
|
+
function createBuilderModuleScope(config2) {
|
|
90
|
+
const { moduleScopes } = config2.source;
|
|
64
91
|
if (moduleScopes) {
|
|
65
92
|
let builderModuleScope = [];
|
|
66
|
-
const DEFAULT_SCOPES = [
|
|
93
|
+
const DEFAULT_SCOPES = [
|
|
94
|
+
"./src",
|
|
95
|
+
"./shared",
|
|
96
|
+
/node_modules/
|
|
97
|
+
];
|
|
67
98
|
if (Array.isArray(moduleScopes)) {
|
|
68
99
|
if (isPrimitiveScope(moduleScopes)) {
|
|
69
100
|
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
@@ -75,43 +106,48 @@ export function initSourceConfig(config, appContext) {
|
|
|
75
106
|
}
|
|
76
107
|
return builderModuleScope;
|
|
77
108
|
} else {
|
|
78
|
-
return
|
|
109
|
+
return void 0;
|
|
79
110
|
}
|
|
80
111
|
function isPrimitiveScope(items) {
|
|
81
|
-
return items.every(
|
|
112
|
+
return items.every(
|
|
113
|
+
(item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]"
|
|
114
|
+
);
|
|
82
115
|
}
|
|
83
116
|
}
|
|
84
117
|
}
|
|
85
|
-
|
|
118
|
+
function initToolsConfig(config) {
|
|
86
119
|
const defaultTsChecker = {
|
|
87
120
|
issue: {
|
|
88
|
-
include: [{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, {
|
|
94
|
-
file: '**/node_modules/**/*'
|
|
95
|
-
}]
|
|
121
|
+
include: [{ file: "**/src/**/*" }],
|
|
122
|
+
exclude: [
|
|
123
|
+
{ file: "**/*.(spec|test).ts" },
|
|
124
|
+
{ file: "**/node_modules/**/*" }
|
|
125
|
+
]
|
|
96
126
|
}
|
|
97
127
|
};
|
|
98
|
-
const {
|
|
99
|
-
tsChecker,
|
|
100
|
-
tsLoader,
|
|
101
|
-
htmlPlugin
|
|
102
|
-
} = config.tools;
|
|
128
|
+
const { tsChecker, tsLoader, htmlPlugin } = config.tools;
|
|
103
129
|
config.tools.tsChecker = applyOptionsChain(defaultTsChecker, tsChecker);
|
|
104
130
|
tsLoader && (config.tools.tsLoader = (tsLoaderConfig, utils) => {
|
|
105
|
-
applyOptionsChain(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
131
|
+
applyOptionsChain(
|
|
132
|
+
__spreadProps(__spreadValues({}, tsLoaderConfig), {
|
|
133
|
+
transpileOnly: false,
|
|
134
|
+
allowTsInNodeModules: true
|
|
135
|
+
}),
|
|
136
|
+
tsLoader || {},
|
|
137
|
+
utils
|
|
138
|
+
);
|
|
109
139
|
});
|
|
110
|
-
config.tools.htmlPlugin = [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
140
|
+
config.tools.htmlPlugin = [
|
|
141
|
+
(config2) => __spreadProps(__spreadValues({}, config2), {
|
|
142
|
+
minify: typeof config2.minify === "object" ? __spreadProps(__spreadValues({}, config2.minify), {
|
|
143
|
+
removeComments: false
|
|
144
|
+
}) : config2.minify
|
|
145
|
+
}),
|
|
146
|
+
...Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : []
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
initHtmlConfig,
|
|
151
|
+
initSourceConfig,
|
|
152
|
+
initToolsConfig
|
|
153
|
+
};
|