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

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 (279) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/js/modern/analyze/generateCode.js +30 -38
  3. package/dist/js/modern/analyze/getBundleEntry.js +5 -13
  4. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
  6. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
  7. package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
  8. package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
  9. package/dist/js/modern/analyze/getServerRoutes.js +25 -38
  10. package/dist/js/modern/analyze/index.js +90 -48
  11. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
  12. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
  13. package/dist/js/modern/analyze/nestedRoutes.js +8 -33
  14. package/dist/js/modern/analyze/templates.js +22 -37
  15. package/dist/js/modern/analyze/utils.js +0 -7
  16. package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
  17. package/dist/js/modern/builder/index.js +56 -37
  18. package/dist/js/modern/builder/share.js +1 -5
  19. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
  20. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
  21. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
  22. package/dist/js/modern/commands/build.js +12 -46
  23. package/dist/js/modern/commands/dev.js +20 -23
  24. package/dist/js/modern/commands/inspect.js +4 -19
  25. package/dist/js/modern/commands/start.js +1 -2
  26. package/dist/js/modern/config/default.js +207 -0
  27. package/dist/js/modern/config/index.js +2 -0
  28. package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
  29. package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
  30. package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
  31. package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
  32. package/dist/js/modern/config/initial/index.js +11 -0
  33. package/dist/js/modern/config/initial/inits.js +117 -0
  34. package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
  35. package/dist/js/modern/defineConfig.js +12 -0
  36. package/dist/js/modern/hooks.js +23 -19
  37. package/dist/js/modern/index.js +12 -19
  38. package/dist/js/modern/initialize/index.js +72 -0
  39. package/dist/js/modern/schema/Schema.js +39 -0
  40. package/dist/js/modern/schema/index.js +139 -0
  41. package/dist/js/modern/schema/legacy.js +284 -0
  42. package/dist/js/modern/types/config/deploy.js +0 -0
  43. package/dist/js/modern/types/config/dev.js +0 -0
  44. package/dist/js/modern/types/config/experiments.js +0 -0
  45. package/dist/js/modern/types/config/html.js +0 -0
  46. package/dist/js/modern/types/config/index.js +2 -0
  47. package/dist/js/modern/types/config/output.js +0 -0
  48. package/dist/js/modern/types/config/performance.js +0 -0
  49. package/dist/js/modern/types/config/security.js +0 -0
  50. package/dist/js/modern/types/config/source.js +0 -0
  51. package/dist/js/modern/types/config/tools.js +0 -0
  52. package/dist/js/modern/types/hooks.js +0 -0
  53. package/dist/js/modern/types/index.js +4 -0
  54. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  55. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  56. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  57. package/dist/js/modern/types/legacyConfig/output.js +1 -0
  58. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  59. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  60. package/dist/js/modern/utils/config.js +2 -13
  61. package/dist/js/modern/utils/createFileWatcher.js +82 -0
  62. package/dist/js/modern/utils/createServer.js +0 -5
  63. package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
  64. package/dist/js/modern/utils/printInstructions.js +2 -1
  65. package/dist/js/modern/utils/restart.js +17 -0
  66. package/dist/js/modern/utils/routes.js +0 -2
  67. package/dist/js/node/analyze/generateCode.js +30 -61
  68. package/dist/js/node/analyze/getBundleEntry.js +5 -19
  69. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
  70. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
  71. package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
  72. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
  73. package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
  74. package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
  75. package/dist/js/node/analyze/getServerRoutes.js +24 -46
  76. package/dist/js/node/analyze/index.js +91 -70
  77. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
  78. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
  79. package/dist/js/node/analyze/nestedRoutes.js +8 -41
  80. package/dist/js/node/analyze/templates.js +22 -47
  81. package/dist/js/node/analyze/utils.js +0 -20
  82. package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
  83. package/dist/js/node/builder/index.js +57 -51
  84. package/dist/js/node/builder/share.js +1 -13
  85. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
  86. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
  87. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
  88. package/dist/js/node/commands/build.js +10 -57
  89. package/dist/js/node/commands/deploy.js +0 -2
  90. package/dist/js/node/commands/dev.js +19 -34
  91. package/dist/js/node/commands/index.js +0 -6
  92. package/dist/js/node/commands/inspect.js +4 -26
  93. package/dist/js/node/commands/start.js +1 -11
  94. package/dist/js/node/config/default.js +214 -0
  95. package/dist/js/node/config/index.js +31 -0
  96. package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
  97. package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
  98. package/dist/js/node/config/initial/createSourceConfig.js +38 -0
  99. package/dist/js/node/config/initial/createToolsConfig.js +47 -0
  100. package/dist/js/node/config/initial/index.js +24 -0
  101. package/dist/js/node/config/initial/inits.js +127 -0
  102. package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
  103. package/dist/js/node/defineConfig.js +20 -0
  104. package/dist/js/node/exports/server.js +0 -1
  105. package/dist/js/node/hooks.js +23 -30
  106. package/dist/js/node/index.js +35 -48
  107. package/dist/js/node/initialize/index.js +79 -0
  108. package/dist/js/node/locale/index.js +0 -4
  109. package/dist/js/node/schema/Schema.js +46 -0
  110. package/dist/js/node/schema/index.js +152 -0
  111. package/dist/js/node/schema/legacy.js +291 -0
  112. package/dist/js/node/types/config/deploy.js +0 -0
  113. package/dist/js/node/types/config/dev.js +0 -0
  114. package/dist/js/node/types/config/experiments.js +0 -0
  115. package/dist/js/node/types/config/html.js +0 -0
  116. package/dist/js/node/types/config/index.js +16 -0
  117. package/dist/js/node/types/config/output.js +0 -0
  118. package/dist/js/node/types/config/performance.js +0 -0
  119. package/dist/js/node/types/config/security.js +0 -0
  120. package/dist/js/node/types/config/source.js +0 -0
  121. package/dist/js/node/types/config/tools.js +0 -0
  122. package/dist/js/node/types/hooks.js +0 -0
  123. package/dist/js/node/types/index.js +38 -0
  124. package/dist/js/node/types/legacyConfig/deploy.js +0 -0
  125. package/dist/js/node/types/legacyConfig/dev.js +0 -0
  126. package/dist/js/node/types/legacyConfig/index.js +0 -0
  127. package/dist/js/node/types/legacyConfig/output.js +5 -0
  128. package/dist/js/node/types/legacyConfig/source.js +0 -0
  129. package/dist/js/node/types/legacyConfig/tools.js +0 -0
  130. package/dist/js/node/utils/commands.js +0 -2
  131. package/dist/js/node/utils/config.js +2 -26
  132. package/dist/js/node/utils/createFileWatcher.js +90 -0
  133. package/dist/js/node/utils/createServer.js +0 -15
  134. package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
  135. package/dist/js/node/utils/language.js +0 -2
  136. package/dist/js/node/utils/printInstructions.js +2 -5
  137. package/dist/js/node/utils/restart.js +23 -0
  138. package/dist/js/node/utils/routes.js +0 -5
  139. package/dist/js/treeshaking/analyze/generateCode.js +58 -101
  140. package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
  141. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
  142. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
  143. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
  144. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
  145. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
  146. package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
  147. package/dist/js/treeshaking/analyze/index.js +195 -91
  148. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
  149. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
  150. package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
  151. package/dist/js/treeshaking/analyze/templates.js +31 -50
  152. package/dist/js/treeshaking/analyze/utils.js +7 -14
  153. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
  154. package/dist/js/treeshaking/builder/index.js +69 -65
  155. package/dist/js/treeshaking/builder/share.js +1 -5
  156. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
  157. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
  158. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
  159. package/dist/js/treeshaking/commands/build.js +41 -116
  160. package/dist/js/treeshaking/commands/deploy.js +0 -3
  161. package/dist/js/treeshaking/commands/dev.js +38 -46
  162. package/dist/js/treeshaking/commands/inspect.js +9 -27
  163. package/dist/js/treeshaking/commands/start.js +1 -9
  164. package/dist/js/treeshaking/config/default.js +200 -0
  165. package/dist/js/treeshaking/config/index.js +2 -0
  166. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
  167. package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
  168. package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
  169. package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
  170. package/dist/js/treeshaking/config/initial/index.js +11 -0
  171. package/dist/js/treeshaking/config/initial/inits.js +114 -0
  172. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
  173. package/dist/js/treeshaking/defineConfig.js +14 -0
  174. package/dist/js/treeshaking/hooks.js +23 -19
  175. package/dist/js/treeshaking/index.js +8 -43
  176. package/dist/js/treeshaking/initialize/index.js +121 -0
  177. package/dist/js/treeshaking/schema/Schema.js +75 -0
  178. package/dist/js/treeshaking/schema/index.js +138 -0
  179. package/dist/js/treeshaking/schema/legacy.js +273 -0
  180. package/dist/js/treeshaking/types/config/deploy.js +0 -0
  181. package/dist/js/treeshaking/types/config/dev.js +0 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +0 -0
  183. package/dist/js/treeshaking/types/config/html.js +0 -0
  184. package/dist/js/treeshaking/types/config/index.js +2 -0
  185. package/dist/js/treeshaking/types/config/output.js +0 -0
  186. package/dist/js/treeshaking/types/config/performance.js +0 -0
  187. package/dist/js/treeshaking/types/config/security.js +0 -0
  188. package/dist/js/treeshaking/types/config/source.js +0 -0
  189. package/dist/js/treeshaking/types/config/tools.js +0 -0
  190. package/dist/js/treeshaking/types/hooks.js +0 -0
  191. package/dist/js/treeshaking/types/index.js +4 -0
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
  198. package/dist/js/treeshaking/utils/config.js +2 -18
  199. package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
  200. package/dist/js/treeshaking/utils/createServer.js +0 -10
  201. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
  202. package/dist/js/treeshaking/utils/printInstructions.js +0 -5
  203. package/dist/js/treeshaking/utils/restart.js +45 -0
  204. package/dist/js/treeshaking/utils/routes.js +0 -4
  205. package/dist/types/analyze/generateCode.d.ts +3 -2
  206. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  207. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  208. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  209. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  210. package/dist/types/analyze/index.d.ts +3 -42
  211. package/dist/types/analyze/nestedRoutes.d.ts +1 -1
  212. package/dist/types/analyze/templates.d.ts +4 -2
  213. package/dist/types/analyze/utils.d.ts +1 -1
  214. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
  215. package/dist/types/builder/index.d.ts +7 -8
  216. package/dist/types/builder/share.d.ts +2 -2
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
  218. package/dist/types/commands/build.d.ts +2 -2
  219. package/dist/types/commands/deploy.d.ts +2 -2
  220. package/dist/types/commands/dev.d.ts +2 -2
  221. package/dist/types/commands/inspect.d.ts +6 -1
  222. package/dist/types/commands/start.d.ts +2 -2
  223. package/dist/types/config/default.d.ts +3 -0
  224. package/dist/types/config/index.d.ts +2 -0
  225. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  226. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  227. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  228. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  229. package/dist/types/config/initial/index.d.ts +4 -0
  230. package/dist/types/config/initial/inits.d.ts +4 -0
  231. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  232. package/dist/types/defineConfig.d.ts +7 -0
  233. package/dist/types/hooks.d.ts +2 -42
  234. package/dist/types/index.d.ts +5 -7
  235. package/dist/types/initialize/index.d.ts +3 -0
  236. package/dist/types/schema/Schema.d.ts +14 -0
  237. package/dist/types/schema/index.d.ts +4 -0
  238. package/dist/types/schema/legacy.d.ts +3 -0
  239. package/dist/types/types/config/deploy.d.ts +9 -0
  240. package/dist/types/types/config/dev.d.ts +13 -0
  241. package/dist/types/types/config/experiments.d.ts +4 -0
  242. package/dist/types/types/config/html.d.ts +4 -0
  243. package/dist/types/types/config/index.d.ts +62 -0
  244. package/dist/types/types/config/output.d.ts +23 -0
  245. package/dist/types/types/config/performance.d.ts +4 -0
  246. package/dist/types/types/config/security.d.ts +4 -0
  247. package/dist/types/types/config/source.d.ts +22 -0
  248. package/dist/types/types/config/tools.d.ts +15 -0
  249. package/dist/types/types/hooks.d.ts +80 -0
  250. package/dist/types/types/index.d.ts +23 -0
  251. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  252. package/dist/types/types/legacyConfig/dev.d.ts +12 -0
  253. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  254. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  255. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  256. package/dist/types/types/legacyConfig/tools.d.ts +16 -0
  257. package/dist/types/utils/config.d.ts +2 -3
  258. package/dist/types/utils/createFileWatcher.d.ts +3 -0
  259. package/dist/types/utils/printInstructions.d.ts +3 -3
  260. package/dist/types/utils/restart.d.ts +3 -0
  261. package/package.json +26 -25
  262. package/dist/js/modern/builder/createHtmlConfig.js +0 -58
  263. package/dist/js/modern/builder/createSourceConfig.js +0 -85
  264. package/dist/js/modern/builder/createToolsConfig.js +0 -94
  265. package/dist/js/modern/utils/createCompiler.js +0 -58
  266. package/dist/js/node/builder/createHtmlConfig.js +0 -76
  267. package/dist/js/node/builder/createSourceConfig.js +0 -99
  268. package/dist/js/node/builder/createToolsConfig.js +0 -103
  269. package/dist/js/node/utils/createCompiler.js +0 -75
  270. package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
  271. package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
  272. package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
  273. package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
  274. package/dist/js/treeshaking/utils/createCompiler.js +0 -117
  275. package/dist/types/builder/createHtmlConfig.d.ts +0 -6
  276. package/dist/types/builder/createOutputConfig.d.ts +0 -3
  277. package/dist/types/builder/createSourceConfig.d.ts +0 -5
  278. package/dist/types/builder/createToolsConfig.d.ts +0 -13
  279. package/dist/types/utils/createCompiler.d.ts +0 -12
@@ -0,0 +1,4 @@
1
+ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
+ export declare type BuilderSecurityConfig = Required<BuilderConfig>['security'];
3
+ export declare type SecurityUserConfig = BuilderSecurityConfig;
4
+ export declare type SecurityNormalizedConfig = SecurityUserConfig;
@@ -0,0 +1,22 @@
1
+ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
+ export declare type BuilderSourceConfig = Required<BuilderConfig>['source'];
3
+ export declare type Entry = string | {
4
+ entry: string;
5
+ enableFileSystemRoutes?: boolean;
6
+ disableMount?: boolean;
7
+ };
8
+ export declare type Entries = Record<string, Entry>;
9
+ export interface SourceUserConfig extends BuilderSourceConfig {
10
+ entries?: Entries;
11
+ enableAsyncEntry?: boolean;
12
+ disableDefaultEntries?: boolean;
13
+ entriesDir?: string;
14
+ configDir?: string;
15
+ /**
16
+ * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
17
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
18
+ * @requires `tailwindcss` plugin
19
+ */
20
+ designSystem?: Record<string, any>;
21
+ }
22
+ export declare type SourceNormalizedConfig = SourceUserConfig;
@@ -0,0 +1,15 @@
1
+ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
+ import type { JestConfig } from '@modern-js/core';
3
+ export declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
4
+ /**
5
+ * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
6
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
7
+ * @requires `tailwindcss` plugin
8
+ */
9
+ export declare type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
10
+ export interface ToolsUserConfig extends BuilderToolsConfig {
11
+ tailwindcss?: Tailwindcss;
12
+ jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
13
+ esbuild?: Record<string, unknown>;
14
+ }
15
+ export declare type ToolsNormalizedConfig = ToolsUserConfig;
@@ -0,0 +1,80 @@
1
+ import type { webpack } from '@modern-js/builder-webpack-provider';
2
+ import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
3
+ import type { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
4
+ export interface ImportSpecifier {
5
+ local?: string;
6
+ imported?: string;
7
+ }
8
+ export interface ImportStatement {
9
+ specifiers: ImportSpecifier[];
10
+ value: string;
11
+ initialize?: string;
12
+ }
13
+ export interface RuntimePlugin {
14
+ name: string;
15
+ options: string;
16
+ args?: string;
17
+ }
18
+ export declare type AppToolsHooks = {
19
+ modifyEntryExport: AsyncWaterfall<{
20
+ entrypoint: Entrypoint;
21
+ exportStatement: string;
22
+ }>;
23
+ modifyEntryImports: AsyncWaterfall<{
24
+ imports: ImportStatement[];
25
+ entrypoint: Entrypoint;
26
+ }>;
27
+ modifyEntryRuntimePlugins: AsyncWaterfall<{
28
+ entrypoint: Entrypoint;
29
+ plugins: RuntimePlugin[];
30
+ }>;
31
+ modifyEntryRenderFunction: AsyncWaterfall<{
32
+ entrypoint: Entrypoint;
33
+ code: string;
34
+ }>;
35
+ modifyAsyncEntry: AsyncWaterfall<{
36
+ entrypoint: Entrypoint;
37
+ code: string;
38
+ }>;
39
+ modifyFileSystemRoutes: AsyncWaterfall<{
40
+ entrypoint: Entrypoint;
41
+ routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
42
+ }>;
43
+ modifyServerRoutes: AsyncWaterfall<{
44
+ routes: ServerRoute[];
45
+ }>;
46
+ htmlPartials: AsyncWaterfall<{
47
+ entrypoint: Entrypoint;
48
+ partials: HtmlPartials;
49
+ }>;
50
+ beforeGenerateRoutes: AsyncWaterfall<{
51
+ entrypoint: Entrypoint;
52
+ code: string;
53
+ }>;
54
+ addDefineTypes: AsyncWaterfall<void>;
55
+ beforeDev: AsyncWorkflow<void, unknown>;
56
+ afterDev: AsyncWorkflow<void, unknown>;
57
+ beforeCreateCompiler: AsyncWorkflow<{
58
+ bundlerConfigs: webpack.Configuration[];
59
+ }, unknown>;
60
+ afterCreateCompiler: AsyncWorkflow<{
61
+ compiler?: webpack.Compiler | webpack.MultiCompiler;
62
+ }, unknown>;
63
+ beforePrintInstructions: AsyncWaterfall<{
64
+ instructions: string;
65
+ }>;
66
+ beforeBuild: AsyncWorkflow<{
67
+ bundlerConfigs?: webpack.Configuration[];
68
+ }, unknown>;
69
+ afterBuild: AsyncWorkflow<{
70
+ stats?: webpack.Stats | webpack.MultiStats;
71
+ }, unknown>;
72
+ beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
73
+ afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
74
+ watchFiles: ParallelWorkflow<void>;
75
+ fileChange: AsyncWorkflow<{
76
+ filename: string;
77
+ eventType: 'add' | 'change' | 'unlink';
78
+ }, void>;
79
+ beforeRestart: AsyncWorkflow<void, void>;
80
+ };
@@ -0,0 +1,23 @@
1
+ import type { NormalizedConfig, UserConfig } from '@modern-js/core';
2
+ import type { AppToolsUserConfig, AppToolsNormalizedConfig } from './config';
3
+ import type { AppToolsHooks } from './hooks';
4
+ import type { AppToolsLegacyUserConfig, AppToolsLegacyNormalizedConfig } from './legacyConfig';
5
+ export * from './hooks';
6
+ export * from './config';
7
+ export * from './legacyConfig';
8
+ export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig, SSR, SSRByEntries } from '@modern-js/server-core';
9
+ export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig } from '@modern-js/core';
10
+ export declare type AppTools = {
11
+ hooks: AppToolsHooks;
12
+ userConfig: AppToolsUserConfig;
13
+ normalizedConfig: AppToolsNormalizedConfig;
14
+ };
15
+ export declare type LegacyAppTools = {
16
+ hooks: AppToolsHooks;
17
+ userConfig: AppToolsLegacyUserConfig;
18
+ normalizedConfig: AppToolsLegacyNormalizedConfig;
19
+ };
20
+ export declare type AppNormalizedConfig = NormalizedConfig<AppTools>;
21
+ export declare type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
22
+ export declare type AppUserConfig = UserConfig<AppTools>;
23
+ export declare type AppLegacyUserConfig = UserConfig<LegacyAppTools>;
@@ -0,0 +1,8 @@
1
+ export interface MicroFrontend {
2
+ enableHtmlEntry?: boolean;
3
+ externalBasicLibrary?: boolean;
4
+ moduleApp?: string;
5
+ }
6
+ export declare type DeployLegacyUserConfig = {
7
+ microFrontend?: boolean | MicroFrontend;
8
+ };
@@ -0,0 +1,12 @@
1
+ import type { DevServerHttpsOptions } from '@modern-js/types';
2
+ export declare type DevProxyOptions = string | Record<string, string>;
3
+ export declare type DevUserLegacyConfig = {
4
+ assetPrefix?: string | boolean;
5
+ https?: DevServerHttpsOptions;
6
+ /**
7
+ * The configuration of `dev.proxy` is provided by `proxy` plugin.
8
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
9
+ * @requires `proxy` plugin
10
+ */
11
+ proxy?: DevProxyOptions;
12
+ };
@@ -0,0 +1,33 @@
1
+ import type { ServerUserConfig as LegacyServerUserConfig, BffUserConfig as LegacyBffUserConfig } from '@modern-js/server-core';
2
+ import type { DevUserLegacyConfig } from './dev';
3
+ import type { OutputLegacyUserConfig } from './output';
4
+ import type { SourceLegacyUserConfig } from './source';
5
+ import type { DeployLegacyUserConfig } from './deploy';
6
+ import type { ToolsLegacyUserConfig } from './tools';
7
+ export type { DevUserLegacyConfig } from './dev';
8
+ export type { OutputLegacyUserConfig } from './output';
9
+ export type { DeployLegacyUserConfig } from './deploy';
10
+ export type { SourceLegacyUserConfig } from './source';
11
+ export type { ToolsLegacyUserConfig } from './tools';
12
+ export interface RuntimeLegacyConfig {
13
+ [name: string]: any;
14
+ }
15
+ export interface RuntimeByEntriesLegacyConfig {
16
+ [name: string]: RuntimeLegacyConfig;
17
+ }
18
+ export declare type AppToolsLegacyUserConfig = {
19
+ source?: SourceLegacyUserConfig;
20
+ output?: OutputLegacyUserConfig;
21
+ server?: LegacyServerUserConfig;
22
+ dev?: DevUserLegacyConfig;
23
+ deploy?: DeployLegacyUserConfig;
24
+ tools?: ToolsLegacyUserConfig;
25
+ runtime?: RuntimeLegacyConfig;
26
+ runtimeByEntries?: RuntimeByEntriesLegacyConfig;
27
+ bff?: LegacyBffUserConfig;
28
+ legacy?: boolean;
29
+ };
30
+ export interface AppToolsLegacyNormalizedConfig extends Required<AppToolsLegacyUserConfig> {
31
+ cliOptions?: Record<string, any>;
32
+ _raw: AppToolsLegacyUserConfig;
33
+ }
@@ -0,0 +1,51 @@
1
+ import { MetaOptions } from '@modern-js/utils';
2
+ import { SSGConfig } from '../config';
3
+ declare type CrossOrigin = 'anonymous' | 'use-credentials';
4
+ export declare type OutputLegacyUserConfig = {
5
+ assetPrefix?: string;
6
+ htmlPath?: string;
7
+ jsPath?: string;
8
+ cssPath?: string;
9
+ mediaPath?: string;
10
+ path?: string;
11
+ title?: string;
12
+ titleByEntries?: Record<string, string>;
13
+ meta?: MetaOptions;
14
+ metaByEntries?: Record<string, MetaOptions>;
15
+ inject?: 'body' | 'head' | boolean;
16
+ injectByEntries?: Record<string, 'body' | 'head' | boolean>;
17
+ mountId?: string;
18
+ favicon?: string;
19
+ faviconByEntries?: Record<string, string | undefined>;
20
+ copy?: Array<Record<string, unknown> & {
21
+ from: string;
22
+ }>;
23
+ disableTsChecker?: boolean;
24
+ disableHtmlFolder?: boolean;
25
+ disableCssModuleExtension?: boolean;
26
+ disableCssExtract?: boolean;
27
+ enableCssModuleTSDeclaration?: boolean;
28
+ disableMinimize?: boolean;
29
+ enableInlineStyles?: boolean;
30
+ enableInlineScripts?: boolean;
31
+ disableSourceMap?: boolean;
32
+ disableInlineRuntimeChunk?: boolean;
33
+ disableAssetsCache?: boolean;
34
+ enableLatestDecorators?: boolean;
35
+ polyfill?: 'off' | 'usage' | 'entry' | 'ua';
36
+ dataUriLimit?: number;
37
+ templateParameters?: Record<string, unknown>;
38
+ templateParametersByEntries?: Record<string, Record<string, unknown>>;
39
+ crossorigin?: boolean | CrossOrigin;
40
+ cssModuleLocalIdentName?: string;
41
+ enableModernMode?: boolean;
42
+ disableNodePolyfill?: boolean;
43
+ enableTsLoader?: boolean;
44
+ /**
45
+ * The configuration of `output.ssg` is provided by `ssg` plugin.
46
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
47
+ * @requires `ssg` plugin
48
+ */
49
+ ssg?: SSGConfig;
50
+ };
51
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { AliasOption } from '@modern-js/utils';
2
+ export declare type SourceLegacyUserConfig = {
3
+ alias?: AliasOption;
4
+ entries?: Record<string, string | {
5
+ entry: string;
6
+ enableFileSystemRoutes?: boolean;
7
+ disableMount?: boolean;
8
+ }>;
9
+ preEntry?: string | string[];
10
+ enableAsyncEntry?: boolean;
11
+ disableDefaultEntries?: boolean;
12
+ entriesDir?: string;
13
+ configDir?: string;
14
+ apiDir?: string;
15
+ envVars?: Array<string>;
16
+ globalVars?: Record<string, string>;
17
+ moduleScopes?: Array<string | RegExp> | (((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>))[] | ((scopes: Array<string | RegExp>) => Array<string | RegExp>) | ((scopes: Array<string | RegExp>) => void);
18
+ include?: Array<string | RegExp>;
19
+ /**
20
+ * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
21
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
22
+ * @requires `tailwindcss` plugin
23
+ */
24
+ designSystem?: Record<string, any>;
25
+ };
@@ -0,0 +1,16 @@
1
+ import type { DevServerOptions } from '@modern-js/types';
2
+ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
3
+ import type { JestConfig } from '@modern-js/core';
4
+ declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
5
+ export declare type ToolsLegacyUserConfig = BuilderToolsConfig & {
6
+ esbuild?: Record<string, unknown>;
7
+ devServer?: DevServerOptions;
8
+ /**
9
+ * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
10
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
11
+ * @requires `tailwindcss` plugin
12
+ */
13
+ tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
14
+ jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
15
+ };
16
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { bundle } from '@modern-js/node-bundle-require';
2
- import type { NormalizedConfig } from '@modern-js/core';
3
2
  import type { ServerConfig } from '@modern-js/server-core';
3
+ import type { AppNormalizedConfig } from '../types';
4
4
  export declare const defineServerConfig: (config: ServerConfig) => ServerConfig;
5
5
  export declare const buildServerConfig: ({
6
6
  appDirectory,
@@ -17,6 +17,5 @@ export declare const buildServerConfig: ({
17
17
  *
18
18
  * 处理循环引用的 replacer
19
19
  */
20
-
21
20
  export declare const safeReplacer: () => (key: string, value: unknown) => unknown;
22
- export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: NormalizedConfig) => Promise<void>;
21
+ export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: AppNormalizedConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { IAppContext, ToRunners } from '@modern-js/core';
2
+ import { AppToolsHooks } from '../types/hooks';
3
+ export declare const createFileWatcher: (appContext: IAppContext, configDir: string | undefined, hooksRunner: ToRunners<AppToolsHooks>) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -1,3 +1,3 @@
1
- import type { IAppContext, NormalizedConfig, ToRunners } from '@modern-js/core';
2
- import type { AppHooks } from '../hooks';
3
- export declare const printInstructions: (hookRunners: ToRunners<AppHooks>, appContext: IAppContext, config: NormalizedConfig) => Promise<void>;
1
+ import type { IAppContext, CliHooksRunner } from '@modern-js/core';
2
+ import type { AppNormalizedConfig, AppTools } from '../types';
3
+ export declare const printInstructions: (hookRunners: CliHooksRunner<AppTools>, appContext: IAppContext, config: AppNormalizedConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { ToRunners } from '@modern-js/core';
2
+ import { AppToolsHooks } from '../types/hooks';
3
+ export declare function restart(hooksRunner: ToRunners<AppToolsHooks>): Promise<void>;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.0",
14
+ "version": "2.0.0-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -59,33 +59,34 @@
59
59
  "@babel/runtime": "^7.18.0",
60
60
  "@babel/traverse": "^7.18.0",
61
61
  "@babel/types": "^7.18.0",
62
- "@modern-js/core": "2.0.0-beta.0",
63
- "@modern-js/new-action": "2.0.0-beta.0",
64
- "@modern-js/node-bundle-require": "2.0.0-beta.0",
65
- "@modern-js/plugin": "2.0.0-beta.0",
66
- "@modern-js/plugin-data-loader": "2.0.0-beta.0",
67
- "@modern-js/plugin-i18n": "2.0.0-beta.0",
68
- "@modern-js/plugin-jarvis": "2.0.0-beta.0",
69
- "@modern-js/prod-server": "2.0.0-beta.0",
70
- "@modern-js/server": "2.0.0-beta.0",
71
- "@modern-js/types": "2.0.0-beta.0",
72
- "@modern-js/upgrade": "2.0.0-beta.0",
73
- "@modern-js/utils": "2.0.0-beta.0",
74
- "@modern-js/builder": "2.0.0-beta.0",
75
- "@modern-js/builder-shared": "2.0.0-beta.0",
76
- "@modern-js/builder-webpack-provider": "2.0.0-beta.0",
77
- "@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.0",
78
- "@modern-js/builder-plugin-esbuild": "2.0.0-beta.0"
62
+ "@modern-js/builder": "2.0.0-beta.2",
63
+ "@modern-js/builder-plugin-esbuild": "2.0.0-beta.2",
64
+ "@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.2",
65
+ "@modern-js/builder-shared": "2.0.0-beta.2",
66
+ "@modern-js/builder-webpack-provider": "2.0.0-beta.2",
67
+ "@modern-js/core": "2.0.0-beta.2",
68
+ "@modern-js/new-action": "2.0.0-beta.2",
69
+ "@modern-js/node-bundle-require": "2.0.0-beta.2",
70
+ "@modern-js/plugin": "2.0.0-beta.2",
71
+ "@modern-js/plugin-data-loader": "2.0.0-beta.2",
72
+ "@modern-js/plugin-i18n": "2.0.0-beta.2",
73
+ "@modern-js/plugin-lint": "2.0.0-beta.2",
74
+ "@modern-js/prod-server": "2.0.0-beta.2",
75
+ "@modern-js/server": "2.0.0-beta.2",
76
+ "@modern-js/types": "2.0.0-beta.2",
77
+ "@modern-js/upgrade": "2.0.0-beta.2",
78
+ "@modern-js/utils": "2.0.0-beta.2"
79
79
  },
80
80
  "devDependencies": {
81
- "@modern-js/server-core": "2.0.0-beta.0",
82
- "@scripts/build": "2.0.0-beta.0",
83
- "@scripts/jest-config": "2.0.0-beta.0",
84
81
  "@types/babel__traverse": "^7.14.2",
85
82
  "@types/jest": "^27",
86
83
  "@types/node": "^14",
87
84
  "jest": "^27",
88
- "typescript": "^4"
85
+ "typescript": "^4",
86
+ "webpack": "^5.75.0",
87
+ "@modern-js/server-core": "2.0.0-beta.2",
88
+ "@scripts/build": "2.0.0-beta.2",
89
+ "@scripts/jest-config": "2.0.0-beta.2"
89
90
  },
90
91
  "sideEffects": false,
91
92
  "publishConfig": {
@@ -93,9 +94,9 @@
93
94
  "access": "public"
94
95
  },
95
96
  "scripts": {
96
- "new": "modern new",
97
- "dev": "modern build --watch",
98
- "build": "modern build",
97
+ "new": "modern-lib new",
98
+ "dev": "modern-lib build --watch",
99
+ "build": "modern-lib build",
99
100
  "test": "jest --passWithNoTests"
100
101
  }
101
102
  }
@@ -1,58 +0,0 @@
1
- import path from 'path';
2
- import { findExists } from '@modern-js/utils';
3
- export function createHtmlConfig(normalizedConfig, appContext) {
4
- const {
5
- disableHtmlFolder,
6
- favicon,
7
- faviconByEntries,
8
- inject,
9
- injectByEntries,
10
- meta,
11
- metaByEntries,
12
- mountId,
13
- title,
14
- titleByEntries,
15
- scriptExt,
16
- templateParameters,
17
- templateParametersByEntries
18
- } = normalizedConfig.output;
19
- const {
20
- configDir
21
- } = normalizedConfig.source; // transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
22
-
23
- const builderCrossorigin = createBuilderCrossorigin(scriptExt);
24
- const builderAppIcon = createBuilderAppIcon(configDir, appContext);
25
- const builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
26
- return {
27
- appIcon: builderAppIcon,
28
- disableHtmlFolder,
29
- favicon: builderFavicon,
30
- faviconByEntries,
31
- inject,
32
- injectByEntries,
33
- meta,
34
- metaByEntries,
35
- mountId,
36
- title,
37
- titleByEntries,
38
- crossorigin: builderCrossorigin,
39
- templateByEntries: appContext.htmlTemplates,
40
- templateParameters,
41
- templateParametersByEntries: templateParametersByEntries
42
- };
43
- }
44
- const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
45
- export function createBuilderAppIcon(configDir, appContext) {
46
- const appIcon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir, `icon.${ext}`)));
47
- return typeof appIcon === 'string' ? appIcon : undefined;
48
- }
49
- export function createBuilderCrossorigin(scriptExt) {
50
- var _scriptExtCustomConfi;
51
-
52
- const scriptExtCustomConfig = scriptExt === null || scriptExt === void 0 ? void 0 : scriptExt.custom;
53
- return scriptExtCustomConfig !== null && scriptExtCustomConfig !== void 0 && (_scriptExtCustomConfi = scriptExtCustomConfig.test) !== null && _scriptExtCustomConfi !== void 0 && _scriptExtCustomConfi.test('.js') && (scriptExtCustomConfig === null || scriptExtCustomConfig === void 0 ? void 0 : scriptExtCustomConfig.attribute) === 'crossorigin' ? scriptExtCustomConfig.value : undefined;
54
- }
55
- export function createBuilderFavicon(favicon, configDir, appContext) {
56
- const defaultFavicon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir, `favicon.${ext}`)));
57
- return favicon || defaultFavicon || undefined;
58
- }
@@ -1,85 +0,0 @@
1
- import { dirname, isAbsolute, posix, sep } from 'path';
2
- import { globby, mergeAlias, findMonorepoRoot, isModernjsMonorepo } from '@modern-js/utils';
3
- export function createSourceConfig(normalizedConfig, appContext) {
4
- const {
5
- alias,
6
- envVars,
7
- globalVars,
8
- include,
9
- moduleScopes,
10
- preEntry
11
- } = normalizedConfig.source;
12
- const builderGlobalVars = globalVars || {};
13
-
14
- for (const envVar of envVars || []) {
15
- const envVarValue = process.env[envVar];
16
- envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
17
- }
18
-
19
- const builderModuleScope = createBuilderModuleScope(moduleScopes);
20
- const builderInclude = createBuilderInclude(include, appContext);
21
- return {
22
- alias: mergeAlias(alias),
23
- moduleScopes: builderModuleScope,
24
- globalVars: builderGlobalVars,
25
- include: builderInclude,
26
- preEntry,
27
- // ensure resolve.extensions same as before
28
- resolveExtensionPrefix: '.web'
29
- };
30
- }
31
- export function createBuilderInclude(include, appContext) {
32
- const defaultInclude = [appContext.internalDirectory];
33
- const transformInclude = (include || []).map(include => {
34
- if (typeof include === 'string') {
35
- if (isAbsolute(include)) {
36
- return include;
37
- }
38
-
39
- return new RegExp(include);
40
- }
41
-
42
- return include;
43
- }).concat(defaultInclude); // concat default Include
44
-
45
- const root = findMonorepoRoot(appContext.appDirectory);
46
-
47
- if (!root) {
48
- return transformInclude;
49
- }
50
-
51
- const modernjsMonorepo = isModernjsMonorepo(root);
52
-
53
- if (modernjsMonorepo) {
54
- const paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
55
- ignore: ['**/node_modules/**/*']
56
- }).map(pathname => dirname(pathname) + sep);
57
- return [...paths, ...transformInclude];
58
- }
59
-
60
- return transformInclude;
61
- }
62
- export function createBuilderModuleScope(moduleScopes) {
63
- if (moduleScopes) {
64
- let builderModuleScope = [];
65
- const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
66
-
67
- if (Array.isArray(moduleScopes)) {
68
- if (isPrimitiveScope(moduleScopes)) {
69
- builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
70
- } else {
71
- builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
72
- }
73
- } else {
74
- builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
75
- }
76
-
77
- return builderModuleScope;
78
- } else {
79
- return undefined;
80
- }
81
-
82
- function isPrimitiveScope(items) {
83
- return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
84
- }
85
- }
@@ -1,94 +0,0 @@
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
-
3
- 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; }
4
-
5
- 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; }
6
-
7
- import { applyOptionsChain } from '@modern-js/utils';
8
- export function createToolsConfig(normalizedConfig) {
9
- const {
10
- disableCssExtract,
11
- enableTsLoader
12
- } = normalizedConfig.output;
13
- const {
14
- autoprefixer,
15
- babel,
16
- minifyCss,
17
- terser,
18
- webpack,
19
- webpackChain,
20
- tsLoader,
21
- styledComponents,
22
- sass,
23
- postcss,
24
- less,
25
- htmlPlugin,
26
- // TODO: remove modernjs tools.lodash config
27
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
- lodash
29
- } = normalizedConfig.tools;
30
- const builderTsLoader = createBuilderTsLoader(tsLoader, enableTsLoader);
31
- const builderTsChecker = createBuilderTsChecker(normalizedConfig.output);
32
- return {
33
- tsChecker: builderTsChecker,
34
- styleLoader: disableCssExtract ? {} : undefined,
35
- cssExtract: disableCssExtract ? false : undefined,
36
- autoprefixer,
37
- babel,
38
- minifyCss,
39
- terser,
40
- webpack,
41
- webpackChain: webpackChain,
42
- tsLoader: builderTsLoader,
43
- styledComponents: styledComponents,
44
- sass: sass,
45
- postcss: postcss,
46
- less: less,
47
- // can't remove comment in html minify.
48
- // some html template insert by using those comments.
49
- htmlPlugin: [config => _objectSpread(_objectSpread({}, config), {}, {
50
- minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
51
- removeComments: false
52
- }) : config.minify
53
- }), // eslint-disable-next-line no-nested-ternary
54
- ...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])]
55
- };
56
- }
57
-
58
- function createBuilderTsLoader(tsLoader, enableTsLoader) {
59
- const useTsLoader = Boolean(enableTsLoader);
60
-
61
- if (!useTsLoader) {
62
- return undefined;
63
- }
64
-
65
- const defaultTsLoader = {
66
- compilerOptions: {
67
- target: 'es5',
68
- module: 'ESNext'
69
- },
70
- transpileOnly: false,
71
- allowTsInNodeModules: true
72
- };
73
- return (_, utils) => applyOptionsChain(defaultTsLoader, tsLoader, utils);
74
- }
75
-
76
- export function createBuilderTsChecker(output) {
77
- if (output.enableTsLoader || output.disableTsChecker) {
78
- return false;
79
- }
80
-
81
- const defaultTsChecker = {
82
- issue: {
83
- include: [{
84
- file: '**/src/**/*'
85
- }],
86
- exclude: [{
87
- file: '**/*.(spec|test).ts'
88
- }, {
89
- file: '**/node_modules/**/*'
90
- }]
91
- }
92
- };
93
- return defaultTsChecker;
94
- }