@modern-js/app-tools 2.0.0-beta.2 → 2.0.0-beta.4

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.
Files changed (236) hide show
  1. package/CHANGELOG.md +556 -0
  2. package/bin/modern.js +11 -1
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +38 -16
  5. package/dist/js/modern/analyze/generateCode.js +272 -211
  6. package/dist/js/modern/analyze/getBundleEntry.js +34 -32
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +93 -49
  8. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +89 -47
  9. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -2
  10. package/dist/js/modern/analyze/getClientRoutes/utils.js +23 -10
  11. package/dist/js/modern/analyze/getFileSystemEntry.js +43 -22
  12. package/dist/js/modern/analyze/getHtmlTemplate.js +89 -49
  13. package/dist/js/modern/analyze/getServerRoutes.js +122 -126
  14. package/dist/js/modern/analyze/index.js +201 -160
  15. package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -16
  16. package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -11
  17. package/dist/js/modern/analyze/nestedRoutes.js +110 -53
  18. package/dist/js/modern/analyze/templates.js +191 -77
  19. package/dist/js/modern/analyze/utils.js +98 -51
  20. package/dist/js/modern/builder/builderPlugins/compatModern.js +125 -107
  21. package/dist/js/modern/builder/index.js +124 -89
  22. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  23. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  24. package/dist/js/modern/builder/share.js +23 -21
  25. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +23 -22
  26. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +31 -27
  27. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +100 -84
  28. package/dist/js/modern/commands/build.js +67 -42
  29. package/dist/js/modern/commands/deploy.js +27 -4
  30. package/dist/js/modern/commands/dev.js +93 -47
  31. package/dist/js/modern/commands/index.js +1 -1
  32. package/dist/js/modern/commands/inspect.js +30 -5
  33. package/dist/js/modern/commands/start.js +37 -16
  34. package/dist/js/modern/config/default.js +103 -114
  35. package/dist/js/modern/config/index.js +8 -2
  36. package/dist/js/modern/config/initial/createHtmlConfig.js +5 -2
  37. package/dist/js/modern/config/initial/createOutputConfig.js +11 -9
  38. package/dist/js/modern/config/initial/createSourceConfig.js +5 -2
  39. package/dist/js/modern/config/initial/createToolsConfig.js +7 -6
  40. package/dist/js/modern/config/initial/index.js +9 -4
  41. package/dist/js/modern/config/initial/inits.js +109 -73
  42. package/dist/js/modern/config/initial/transformNormalizedConfig.js +6 -3
  43. package/dist/js/modern/defineConfig.js +26 -11
  44. package/dist/js/modern/exports/server.js +4 -1
  45. package/dist/js/modern/hooks.js +15 -4
  46. package/dist/js/modern/index.js +178 -90
  47. package/dist/js/modern/initialize/index.js +98 -51
  48. package/dist/js/modern/locale/en.js +20 -21
  49. package/dist/js/modern/locale/index.js +6 -6
  50. package/dist/js/modern/locale/zh.js +21 -22
  51. package/dist/js/modern/schema/Schema.js +6 -5
  52. package/dist/js/modern/schema/index.js +51 -100
  53. package/dist/js/modern/schema/legacy.js +96 -231
  54. package/dist/js/modern/types/config/index.js +0 -1
  55. package/dist/js/modern/types/index.js +0 -1
  56. package/dist/js/modern/types/legacyConfig/output.js +0 -1
  57. package/dist/js/modern/utils/commands.js +5 -2
  58. package/dist/js/modern/utils/config.js +102 -41
  59. package/dist/js/modern/utils/createFileWatcher.js +84 -51
  60. package/dist/js/modern/utils/createServer.js +63 -17
  61. package/dist/js/modern/utils/getSpecifiedEntries.js +46 -19
  62. package/dist/js/modern/utils/language.js +6 -3
  63. package/dist/js/modern/utils/printInstructions.js +27 -8
  64. package/dist/js/modern/utils/restart.js +43 -16
  65. package/dist/js/modern/utils/routes.js +29 -12
  66. package/dist/js/node/analyze/Builder.js +58 -0
  67. package/dist/js/node/analyze/constants.js +54 -35
  68. package/dist/js/node/analyze/generateCode.js +291 -228
  69. package/dist/js/node/analyze/getBundleEntry.js +58 -44
  70. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +132 -76
  71. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +128 -74
  72. package/dist/js/node/analyze/getClientRoutes/index.js +23 -17
  73. package/dist/js/node/analyze/getClientRoutes/utils.js +44 -21
  74. package/dist/js/node/analyze/getFileSystemEntry.js +70 -39
  75. package/dist/js/node/analyze/getHtmlTemplate.js +116 -61
  76. package/dist/js/node/analyze/getServerRoutes.js +143 -137
  77. package/dist/js/node/analyze/index.js +247 -174
  78. package/dist/js/node/analyze/isDefaultExportFunction.js +55 -26
  79. package/dist/js/node/analyze/makeLegalIdentifier.js +27 -15
  80. package/dist/js/node/analyze/nestedRoutes.js +140 -67
  81. package/dist/js/node/analyze/templates.js +212 -84
  82. package/dist/js/node/analyze/utils.js +123 -62
  83. package/dist/js/node/builder/builderPlugins/compatModern.js +153 -120
  84. package/dist/js/node/builder/index.js +152 -98
  85. package/dist/js/node/builder/loaders/routerLoader.js +36 -0
  86. package/dist/js/node/builder/loaders/serverModuleLoader.js +26 -0
  87. package/dist/js/node/builder/share.js +46 -26
  88. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +39 -26
  89. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +47 -31
  90. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +118 -90
  91. package/dist/js/node/commands/build.js +89 -52
  92. package/dist/js/node/commands/deploy.js +45 -10
  93. package/dist/js/node/commands/dev.js +115 -61
  94. package/dist/js/node/commands/index.js +19 -38
  95. package/dist/js/node/commands/inspect.js +48 -11
  96. package/dist/js/node/commands/start.js +65 -27
  97. package/dist/js/node/config/default.js +119 -118
  98. package/dist/js/node/config/index.js +25 -29
  99. package/dist/js/node/config/initial/createHtmlConfig.js +22 -6
  100. package/dist/js/node/config/initial/createOutputConfig.js +28 -13
  101. package/dist/js/node/config/initial/createSourceConfig.js +22 -6
  102. package/dist/js/node/config/initial/createToolsConfig.js +24 -10
  103. package/dist/js/node/config/initial/index.js +28 -17
  104. package/dist/js/node/config/initial/inits.js +126 -81
  105. package/dist/js/node/config/initial/transformNormalizedConfig.js +31 -15
  106. package/dist/js/node/defineConfig.js +43 -17
  107. package/dist/js/node/exports/server.js +21 -10
  108. package/dist/js/node/hooks.js +48 -29
  109. package/dist/js/node/index.js +225 -128
  110. package/dist/js/node/initialize/index.js +116 -61
  111. package/dist/js/node/locale/en.js +36 -25
  112. package/dist/js/node/locale/index.js +27 -15
  113. package/dist/js/node/locale/zh.js +37 -26
  114. package/dist/js/node/schema/Schema.js +23 -10
  115. package/dist/js/node/schema/index.js +77 -114
  116. package/dist/js/node/schema/legacy.js +117 -240
  117. package/dist/js/node/types/config/index.js +17 -16
  118. package/dist/js/node/types/index.js +19 -38
  119. package/dist/js/node/types/legacyConfig/output.js +0 -5
  120. package/dist/js/node/utils/commands.js +21 -6
  121. package/dist/js/node/utils/config.js +120 -51
  122. package/dist/js/node/utils/createFileWatcher.js +104 -60
  123. package/dist/js/node/utils/createServer.js +86 -25
  124. package/dist/js/node/utils/getSpecifiedEntries.js +64 -25
  125. package/dist/js/node/utils/language.js +24 -8
  126. package/dist/js/node/utils/printInstructions.js +47 -16
  127. package/dist/js/node/utils/restart.js +61 -21
  128. package/dist/js/node/utils/routes.js +53 -18
  129. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  130. package/dist/js/treeshaking/analyze/constants.js +28 -16
  131. package/dist/js/treeshaking/analyze/generateCode.js +605 -355
  132. package/dist/js/treeshaking/analyze/getBundleEntry.js +55 -63
  133. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +214 -168
  134. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +215 -169
  135. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -2
  136. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +19 -20
  137. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +89 -86
  138. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +298 -125
  139. package/dist/js/treeshaking/analyze/getServerRoutes.js +210 -146
  140. package/dist/js/treeshaking/analyze/index.js +571 -304
  141. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +45 -26
  142. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -16
  143. package/dist/js/treeshaking/analyze/nestedRoutes.js +414 -160
  144. package/dist/js/treeshaking/analyze/templates.js +432 -161
  145. package/dist/js/treeshaking/analyze/utils.js +361 -80
  146. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +282 -195
  147. package/dist/js/treeshaking/builder/index.js +371 -167
  148. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  149. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  150. package/dist/js/treeshaking/builder/share.js +38 -44
  151. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +108 -44
  152. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +70 -39
  153. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +334 -112
  154. package/dist/js/treeshaking/commands/build.js +286 -88
  155. package/dist/js/treeshaking/commands/deploy.js +153 -25
  156. package/dist/js/treeshaking/commands/dev.js +318 -132
  157. package/dist/js/treeshaking/commands/index.js +1 -1
  158. package/dist/js/treeshaking/commands/inspect.js +147 -32
  159. package/dist/js/treeshaking/commands/start.js +190 -68
  160. package/dist/js/treeshaking/config/default.js +210 -199
  161. package/dist/js/treeshaking/config/index.js +3 -2
  162. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -31
  163. package/dist/js/treeshaking/config/initial/createOutputConfig.js +43 -67
  164. package/dist/js/treeshaking/config/initial/createSourceConfig.js +37 -40
  165. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -38
  166. package/dist/js/treeshaking/config/initial/index.js +10 -9
  167. package/dist/js/treeshaking/config/initial/inits.js +205 -106
  168. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +27 -34
  169. package/dist/js/treeshaking/defineConfig.js +60 -13
  170. package/dist/js/treeshaking/exports/server.js +2 -1
  171. package/dist/js/treeshaking/hooks.js +30 -25
  172. package/dist/js/treeshaking/index.js +681 -256
  173. package/dist/js/treeshaking/initialize/index.js +290 -112
  174. package/dist/js/treeshaking/locale/en.js +34 -33
  175. package/dist/js/treeshaking/locale/index.js +5 -5
  176. package/dist/js/treeshaking/locale/zh.js +34 -33
  177. package/dist/js/treeshaking/schema/Schema.js +267 -69
  178. package/dist/js/treeshaking/schema/index.js +165 -121
  179. package/dist/js/treeshaking/schema/legacy.js +323 -256
  180. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  181. package/dist/js/treeshaking/types/config/dev.js +1 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  183. package/dist/js/treeshaking/types/config/html.js +1 -0
  184. package/dist/js/treeshaking/types/config/index.js +0 -1
  185. package/dist/js/treeshaking/types/config/output.js +1 -0
  186. package/dist/js/treeshaking/types/config/performance.js +1 -0
  187. package/dist/js/treeshaking/types/config/security.js +1 -0
  188. package/dist/js/treeshaking/types/config/source.js +1 -0
  189. package/dist/js/treeshaking/types/config/tools.js +1 -0
  190. package/dist/js/treeshaking/types/hooks.js +1 -0
  191. package/dist/js/treeshaking/types/index.js +0 -1
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -1
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  198. package/dist/js/treeshaking/utils/commands.js +6 -5
  199. package/dist/js/treeshaking/utils/config.js +295 -117
  200. package/dist/js/treeshaking/utils/createFileWatcher.js +278 -118
  201. package/dist/js/treeshaking/utils/createServer.js +252 -67
  202. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +182 -55
  203. package/dist/js/treeshaking/utils/language.js +6 -5
  204. package/dist/js/treeshaking/utils/printInstructions.js +151 -29
  205. package/dist/js/treeshaking/utils/restart.js +184 -42
  206. package/dist/js/treeshaking/utils/routes.js +151 -27
  207. package/dist/js/treeshaking/utils/types.js +1 -0
  208. package/dist/types/analyze/Builder.d.ts +8 -0
  209. package/dist/types/analyze/constants.d.ts +2 -0
  210. package/dist/types/analyze/index.d.ts +2 -0
  211. package/dist/types/analyze/templates.d.ts +10 -7
  212. package/dist/types/analyze/utils.d.ts +9 -1
  213. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
  214. package/dist/types/builder/index.d.ts +3 -3
  215. package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
  216. package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +1 -7
  218. package/dist/types/defineConfig.d.ts +1 -0
  219. package/dist/types/index.d.ts +6 -1
  220. package/dist/types/initialize/index.d.ts +2 -0
  221. package/dist/types/types/config/dev.d.ts +2 -2
  222. package/dist/types/types/config/index.d.ts +1 -0
  223. package/dist/types/types/config/output.d.ts +0 -1
  224. package/dist/types/types/config/source.d.ts +1 -0
  225. package/dist/types/types/config/tools.d.ts +10 -1
  226. package/dist/types/types/hooks.d.ts +7 -1
  227. package/dist/types/types/legacyConfig/dev.d.ts +1 -0
  228. package/dist/types/types/legacyConfig/output.d.ts +1 -1
  229. package/dist/types/types/legacyConfig/source.d.ts +1 -0
  230. package/dist/types/types/legacyConfig/tools.d.ts +1 -0
  231. package/dist/types/utils/config.d.ts +1 -0
  232. package/dist/types/utils/createFileWatcher.d.ts +2 -1
  233. package/dist/types/utils/createServer.d.ts +1 -0
  234. package/dist/types/utils/restart.d.ts +1 -1
  235. package/lib/types.d.ts +1 -1
  236. package/package.json +26 -22
@@ -1,31 +1,31 @@
1
- export function createDefaultConfig(appContext) {
1
+ function createDefaultConfig(appContext) {
2
2
  const defaultAlias = appContext ? {
3
3
  [appContext.internalDirAlias]: appContext.internalDirectory,
4
4
  [appContext.internalSrcAlias]: appContext.srcDirectory,
5
- '@': appContext.srcDirectory,
6
- '@shared': appContext.sharedDirectory
5
+ "@": appContext.srcDirectory,
6
+ "@shared": appContext.sharedDirectory
7
7
  } : {};
8
8
  const source = {
9
- entries: undefined,
9
+ entries: void 0,
10
10
  enableAsyncEntry: false,
11
11
  disableDefaultEntries: false,
12
- entriesDir: './src',
13
- configDir: './config',
14
- globalVars: undefined,
15
- moduleScopes: undefined,
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: 'html',
23
- js: 'static/js',
24
- css: 'static/css',
25
- media: 'static/media',
26
- root: 'dist'
22
+ html: "html",
23
+ js: "static/js",
24
+ css: "static/css",
25
+ media: "static/media",
26
+ root: "dist"
27
27
  },
28
- copy: undefined,
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: 'entry',
39
- dataUriLimit: 10000,
40
- cssModuleLocalIdentName: undefined
38
+ polyfill: "entry",
39
+ cssModuleLocalIdentName: void 0
41
40
  };
42
41
  const html = {
43
- title: '',
44
- titleByEntries: undefined,
42
+ title: "",
43
+ titleByEntries: void 0,
45
44
  meta: {
46
- charset: {
47
- charset: 'utf-8'
48
- },
49
- 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',
50
- 'http-equiv': {
51
- 'http-equiv': 'x-ua-compatible',
52
- content: 'ie=edge'
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: undefined,
61
- inject: 'head',
62
- injectByEntries: undefined,
63
- mountId: 'root',
64
- favicon: '',
65
- faviconByEntries: undefined,
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: undefined
62
+ templateParametersByEntries: void 0
69
63
  };
70
64
  const server = {
71
- routes: undefined,
72
- publicRoutes: undefined,
73
- ssr: undefined,
74
- ssrByEntries: undefined,
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: undefined,
84
- babel: undefined,
85
- postcss: undefined,
86
- autoprefixer: undefined,
87
- devServer: undefined,
88
- tsLoader: undefined,
89
- terser: undefined,
90
- minifyCss: undefined
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
- export function createLegacyDefaultConfig(appContext) {
98
+ function createLegacyDefaultConfig(appContext) {
105
99
  const defaultAlias = appContext ? {
106
100
  [appContext.internalDirAlias]: appContext.internalDirectory,
107
101
  [appContext.internalSrcAlias]: appContext.srcDirectory,
108
- '@': appContext.srcDirectory,
109
- '@shared': appContext.sharedDirectory
102
+ "@": appContext.srcDirectory,
103
+ "@shared": appContext.sharedDirectory
110
104
  } : {};
111
105
  const sourceDefaults = {
112
- entries: undefined,
106
+ entries: void 0,
113
107
  enableAsyncEntry: false,
114
108
  disableDefaultEntries: false,
115
- entriesDir: './src',
116
- configDir: './config',
117
- apiDir: './api',
109
+ entriesDir: "./src",
110
+ configDir: "./config",
111
+ apiDir: "./api",
118
112
  envVars: [],
119
- globalVars: undefined,
113
+ globalVars: void 0,
120
114
  alias: defaultAlias,
121
- moduleScopes: undefined,
115
+ moduleScopes: void 0,
122
116
  include: []
123
117
  };
124
118
  const outputDefaults = {
125
- assetPrefix: '/',
126
- htmlPath: 'html',
127
- jsPath: 'static/js',
128
- cssPath: 'static/css',
129
- mediaPath: 'static/media',
130
- path: 'dist',
131
- title: '',
132
- titleByEntries: undefined,
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
- charset: 'utf-8'
136
- },
137
- 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',
138
- 'http-equiv': {
139
- 'http-equiv': 'x-ua-compatible',
140
- content: 'ie=edge'
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: undefined,
149
- inject: 'head',
150
- injectByEntries: undefined,
151
- mountId: 'root',
152
- favicon: '',
153
- faviconByEntries: undefined,
154
- copy: undefined,
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: 'entry',
167
- dataUriLimit: 10000,
155
+ polyfill: "entry",
156
+ dataUriLimit: 1e4,
168
157
  templateParameters: {},
169
- templateParametersByEntries: undefined,
170
- cssModuleLocalIdentName: undefined,
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: undefined,
177
- publicRoutes: undefined,
178
- ssr: undefined,
179
- ssrByEntries: undefined,
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: undefined,
189
- babel: undefined,
190
- postcss: undefined,
191
- autoprefixer: undefined,
192
- lodash: undefined,
193
- devServer: undefined,
194
- tsLoader: undefined,
195
- terser: undefined,
196
- minifyCss: undefined
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
- export { createDefaultConfig, createLegacyDefaultConfig } from "./default";
2
- export { initialNormalizedConfig, checkIsLegacyConfig } from "./initial";
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
- export function createHtmlConfig(config) {
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
- export function createOutputConfig(config) {
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
- // `@modern-js/webpack` output all media files to `dist/media` by default
38
- svg: mediaPath || 'media',
39
- image: mediaPath || 'media',
40
- font: mediaPath || 'media',
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
- enableModernMode,
63
+ enableAssetFallback: true,
64
+ enableAssetManifest: true,
66
65
  disableNodePolyfill
67
66
  };
68
- }
67
+ }
68
+ export {
69
+ createOutputConfig
70
+ };
@@ -1,4 +1,4 @@
1
- export function createSourceConfig(config) {
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
- export function createToolsConfig(config) {
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 : undefined,
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
- export { transformNormalizedConfig } from "./transformNormalizedConfig";
3
- export function checkIsLegacyConfig(config) {
2
+ import { transformNormalizedConfig } from "./transformNormalizedConfig";
3
+ function checkIsLegacyConfig(config) {
4
4
  return Boolean(config.legacy);
5
5
  }
6
- export function initialNormalizedConfig(config, appContext) {
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- import path, { dirname, isAbsolute, posix, sep } from 'path';
5
- import { applyOptionsChain, findExists, findMonorepoRoot, globby, isModernjsMonorepo } from '@modern-js/utils';
6
- export function initHtmlConfig(config, appContext) {
7
- const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
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(config, appContext) {
12
- const {
13
- configDir
14
- } = config.source;
15
- const appIcon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir || './config', `icon.${ext}`)));
16
- return typeof appIcon === 'string' ? appIcon : undefined;
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(config, appContext) {
19
- const {
20
- configDir
21
- } = config.source;
22
- const {
23
- favicon
24
- } = config.html;
25
- const defaultFavicon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir || './config', `favicon.${ext}`)));
26
- return favicon || defaultFavicon || undefined;
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
- export function initSourceConfig(config, appContext) {
61
+ function initSourceConfig(config, appContext) {
30
62
  config.source.include = createBuilderInclude(config, appContext);
31
63
  config.source.moduleScopes = createBuilderModuleScope(config);
32
- function createBuilderInclude(config, appContext) {
33
- const {
34
- include
35
- } = config.source;
36
- const defaultInclude = [appContext.internalDirectory];
37
- const transformInclude = (include || []).map(include => {
38
- if (typeof include === 'string') {
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(include);
72
+ return new RegExp(include2);
43
73
  }
44
- return include;
45
- }).concat(defaultInclude); // concat default Include
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, 'features', '**', 'package.json'), {
54
- ignore: ['**/node_modules/**/*']
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(config) {
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 = ['./src', './shared', /node_modules/];
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 undefined;
109
+ return void 0;
79
110
  }
80
111
  function isPrimitiveScope(items) {
81
- return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
112
+ return items.every(
113
+ (item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]"
114
+ );
82
115
  }
83
116
  }
84
117
  }
85
- export function initToolsConfig(config) {
118
+ function initToolsConfig(config) {
86
119
  const defaultTsChecker = {
87
120
  issue: {
88
- include: [{
89
- file: '**/src/**/*'
90
- }],
91
- exclude: [{
92
- file: '**/*.(spec|test).ts'
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(_objectSpread(_objectSpread({}, tsLoaderConfig), {}, {
106
- transpileOnly: false,
107
- allowTsInNodeModules: true
108
- }), tsLoader || {}, utils);
131
+ applyOptionsChain(
132
+ __spreadProps(__spreadValues({}, tsLoaderConfig), {
133
+ transpileOnly: false,
134
+ allowTsInNodeModules: true
135
+ }),
136
+ tsLoader || {},
137
+ utils
138
+ );
109
139
  });
110
- config.tools.htmlPlugin = [config => _objectSpread(_objectSpread({}, config), {}, {
111
- minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
112
- removeComments: false
113
- }) : config.minify
114
- }),
115
- // eslint-disable-next-line no-nested-ternary
116
- ...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])];
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
+ };