@modern-js/app-tools 2.0.0-beta.3 → 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 (230) hide show
  1. package/CHANGELOG.md +305 -0
  2. package/bin/modern.js +1 -0
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +38 -18
  5. package/dist/js/modern/analyze/generateCode.js +262 -221
  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 +106 -60
  18. package/dist/js/modern/analyze/templates.js +163 -81
  19. package/dist/js/modern/analyze/utils.js +87 -66
  20. package/dist/js/modern/builder/builderPlugins/compatModern.js +122 -109
  21. package/dist/js/modern/builder/index.js +123 -86
  22. package/dist/js/modern/builder/loaders/routerLoader.js +9 -12
  23. package/dist/js/modern/builder/loaders/serverModuleLoader.js +4 -1
  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 +77 -27
  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 -15
  34. package/dist/js/modern/config/default.js +103 -113
  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 +9 -10
  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 -39
  68. package/dist/js/node/analyze/generateCode.js +282 -239
  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 +137 -75
  81. package/dist/js/node/analyze/templates.js +185 -90
  82. package/dist/js/node/analyze/utils.js +114 -81
  83. package/dist/js/node/builder/builderPlugins/compatModern.js +150 -122
  84. package/dist/js/node/builder/index.js +151 -95
  85. package/dist/js/node/builder/loaders/routerLoader.js +27 -18
  86. package/dist/js/node/builder/loaders/serverModuleLoader.js +22 -7
  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 +99 -41
  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 -26
  97. package/dist/js/node/config/default.js +119 -117
  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 +26 -14
  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 -61
  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 -18
  131. package/dist/js/treeshaking/analyze/generateCode.js +600 -406
  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 -147
  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 +411 -200
  144. package/dist/js/treeshaking/analyze/templates.js +433 -236
  145. package/dist/js/treeshaking/analyze/utils.js +358 -153
  146. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +282 -200
  147. package/dist/js/treeshaking/builder/index.js +371 -165
  148. package/dist/js/treeshaking/builder/loaders/routerLoader.js +11 -12
  149. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +3 -2
  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 -131
  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 -67
  160. package/dist/js/treeshaking/config/default.js +210 -198
  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 -70
  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/index.d.ts +2 -0
  210. package/dist/types/analyze/templates.d.ts +3 -1
  211. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
  212. package/dist/types/builder/index.d.ts +3 -3
  213. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +1 -7
  214. package/dist/types/defineConfig.d.ts +1 -0
  215. package/dist/types/index.d.ts +6 -1
  216. package/dist/types/initialize/index.d.ts +2 -0
  217. package/dist/types/types/config/dev.d.ts +2 -2
  218. package/dist/types/types/config/index.d.ts +1 -0
  219. package/dist/types/types/config/output.d.ts +0 -1
  220. package/dist/types/types/config/source.d.ts +1 -0
  221. package/dist/types/types/config/tools.d.ts +2 -0
  222. package/dist/types/types/hooks.d.ts +5 -0
  223. package/dist/types/types/legacyConfig/dev.d.ts +1 -0
  224. package/dist/types/types/legacyConfig/output.d.ts +1 -1
  225. package/dist/types/types/legacyConfig/source.d.ts +1 -0
  226. package/dist/types/types/legacyConfig/tools.d.ts +1 -0
  227. package/dist/types/utils/config.d.ts +1 -0
  228. package/dist/types/utils/createServer.d.ts +1 -0
  229. package/dist/types/utils/restart.d.ts +1 -1
  230. package/package.json +23 -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,43 +35,38 @@ export function createDefaultConfig(appContext) {
35
35
  disableInlineRuntimeChunk: false,
36
36
  disableFilenameHash: false,
37
37
  enableLatestDecorators: false,
38
- polyfill: 'entry',
39
- cssModuleLocalIdentName: undefined
38
+ polyfill: "entry",
39
+ cssModuleLocalIdentName: void 0
40
40
  };
41
41
  const html = {
42
- title: '',
43
- titleByEntries: undefined,
42
+ title: "",
43
+ titleByEntries: void 0,
44
44
  meta: {
45
- charset: {
46
- charset: 'utf-8'
47
- },
48
- 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',
49
- 'http-equiv': {
50
- 'http-equiv': 'x-ua-compatible',
51
- content: 'ie=edge'
52
- },
53
- renderer: 'webkit',
54
- layoutmode: 'standard',
55
- imagemode: 'force',
56
- 'wap-font-scale': 'no',
57
- '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"
58
53
  },
59
- metaByEntries: undefined,
60
- inject: 'head',
61
- injectByEntries: undefined,
62
- mountId: 'root',
63
- favicon: '',
64
- faviconByEntries: undefined,
54
+ metaByEntries: void 0,
55
+ inject: "head",
56
+ injectByEntries: void 0,
57
+ mountId: "root",
58
+ favicon: "",
59
+ faviconByEntries: void 0,
65
60
  disableHtmlFolder: false,
66
61
  templateParameters: {},
67
- templateParametersByEntries: undefined
62
+ templateParametersByEntries: void 0
68
63
  };
69
64
  const server = {
70
- routes: undefined,
71
- publicRoutes: undefined,
72
- ssr: undefined,
73
- ssrByEntries: undefined,
74
- baseUrl: '/',
65
+ routes: void 0,
66
+ publicRoutes: void 0,
67
+ ssr: void 0,
68
+ ssrByEntries: void 0,
69
+ baseUrl: "/",
75
70
  port: 8080
76
71
  };
77
72
  const dev = {
@@ -79,14 +74,14 @@ export function createDefaultConfig(appContext) {
79
74
  https: false
80
75
  };
81
76
  const tools = {
82
- webpack: undefined,
83
- babel: undefined,
84
- postcss: undefined,
85
- autoprefixer: undefined,
86
- devServer: undefined,
87
- tsLoader: undefined,
88
- terser: undefined,
89
- 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
90
85
  };
91
86
  return {
92
87
  source,
@@ -100,57 +95,52 @@ export function createDefaultConfig(appContext) {
100
95
  runtimeByEntries: {}
101
96
  };
102
97
  }
103
- export function createLegacyDefaultConfig(appContext) {
98
+ function createLegacyDefaultConfig(appContext) {
104
99
  const defaultAlias = appContext ? {
105
100
  [appContext.internalDirAlias]: appContext.internalDirectory,
106
101
  [appContext.internalSrcAlias]: appContext.srcDirectory,
107
- '@': appContext.srcDirectory,
108
- '@shared': appContext.sharedDirectory
102
+ "@": appContext.srcDirectory,
103
+ "@shared": appContext.sharedDirectory
109
104
  } : {};
110
105
  const sourceDefaults = {
111
- entries: undefined,
106
+ entries: void 0,
112
107
  enableAsyncEntry: false,
113
108
  disableDefaultEntries: false,
114
- entriesDir: './src',
115
- configDir: './config',
116
- apiDir: './api',
109
+ entriesDir: "./src",
110
+ configDir: "./config",
111
+ apiDir: "./api",
117
112
  envVars: [],
118
- globalVars: undefined,
113
+ globalVars: void 0,
119
114
  alias: defaultAlias,
120
- moduleScopes: undefined,
115
+ moduleScopes: void 0,
121
116
  include: []
122
117
  };
123
118
  const outputDefaults = {
124
- assetPrefix: '/',
125
- htmlPath: 'html',
126
- jsPath: 'static/js',
127
- cssPath: 'static/css',
128
- mediaPath: 'static/media',
129
- path: 'dist',
130
- title: '',
131
- 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,
132
127
  meta: {
133
- charset: {
134
- charset: 'utf-8'
135
- },
136
- 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',
137
- 'http-equiv': {
138
- 'http-equiv': 'x-ua-compatible',
139
- content: 'ie=edge'
140
- },
141
- renderer: 'webkit',
142
- layoutmode: 'standard',
143
- imagemode: 'force',
144
- 'wap-font-scale': 'no',
145
- '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"
146
136
  },
147
- metaByEntries: undefined,
148
- inject: 'head',
149
- injectByEntries: undefined,
150
- mountId: 'root',
151
- favicon: '',
152
- faviconByEntries: undefined,
153
- 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,
154
144
  disableHtmlFolder: false,
155
145
  disableCssModuleExtension: false,
156
146
  disableCssExtract: false,
@@ -162,37 +152,33 @@ export function createLegacyDefaultConfig(appContext) {
162
152
  disableInlineRuntimeChunk: false,
163
153
  disableAssetsCache: false,
164
154
  enableLatestDecorators: false,
165
- polyfill: 'entry',
166
- dataUriLimit: 10000,
155
+ polyfill: "entry",
156
+ dataUriLimit: 1e4,
167
157
  templateParameters: {},
168
- templateParametersByEntries: undefined,
169
- cssModuleLocalIdentName: undefined,
170
- enableModernMode: false,
158
+ templateParametersByEntries: void 0,
159
+ cssModuleLocalIdentName: void 0,
171
160
  disableNodePolyfill: false,
172
161
  enableTsLoader: false
173
162
  };
174
163
  const serverDefaults = {
175
- routes: undefined,
176
- publicRoutes: undefined,
177
- ssr: undefined,
178
- ssrByEntries: undefined,
179
- baseUrl: '/',
164
+ routes: void 0,
165
+ publicRoutes: void 0,
166
+ ssr: void 0,
167
+ ssrByEntries: void 0,
168
+ baseUrl: "/",
180
169
  port: 8080
181
170
  };
182
- const devDefaults = {
183
- assetPrefix: false,
184
- https: false
185
- };
171
+ const devDefaults = { assetPrefix: false, https: false };
186
172
  const toolsDefaults = {
187
- webpack: undefined,
188
- babel: undefined,
189
- postcss: undefined,
190
- autoprefixer: undefined,
191
- lodash: undefined,
192
- devServer: undefined,
193
- tsLoader: undefined,
194
- terser: undefined,
195
- 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
196
182
  };
197
183
  return {
198
184
  source: sourceDefaults,
@@ -203,4 +189,8 @@ export function createLegacyDefaultConfig(appContext) {
203
189
  runtime: {},
204
190
  runtimeByEntries: {}
205
191
  };
206
- }
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,10 +60,11 @@ export function createOutputConfig(config) {
62
60
  css: cssModuleLocalIdentName
63
61
  },
64
62
  ssg,
65
- // set `true`, only in legacy config
66
63
  enableAssetFallback: true,
67
64
  enableAssetManifest: true,
68
- enableModernMode,
69
65
  disableNodePolyfill
70
66
  };
71
- }
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
+ };