@flatjs/evolve 1.7.4 → 1.8.1-next.101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/CHANGELOG.md +781 -0
  2. package/LICENSE +21 -0
  3. package/README.md +10 -46
  4. package/dist/constants.d.ts +15 -0
  5. package/dist/constants.js +1 -0
  6. package/dist/create-webpack/create-externals.d.ts +4 -0
  7. package/dist/create-webpack/create-externals.js +1 -0
  8. package/dist/create-webpack/create-optimization.d.ts +3 -0
  9. package/dist/create-webpack/create-optimization.js +1 -0
  10. package/dist/create-webpack/create-output.d.ts +3 -0
  11. package/dist/create-webpack/create-output.js +1 -0
  12. package/dist/create-webpack/create-performance.d.ts +2 -0
  13. package/dist/create-webpack/create-performance.js +1 -0
  14. package/dist/create-webpack/create-plugins.d.ts +4 -0
  15. package/dist/create-webpack/create-plugins.js +1 -0
  16. package/dist/create-webpack/create-resolve.d.ts +2 -0
  17. package/dist/create-webpack/create-resolve.js +1 -0
  18. package/dist/create-webpack/create-rule-sets.d.ts +4 -0
  19. package/dist/create-webpack/create-rule-sets.js +1 -0
  20. package/dist/create-webpack/load-webpack-config.d.ts +10 -0
  21. package/dist/create-webpack/load-webpack-config.js +1 -0
  22. package/dist/create-webpack/rule-sets/constants.d.ts +3 -0
  23. package/dist/create-webpack/rule-sets/constants.js +1 -0
  24. package/dist/create-webpack/rule-sets/rule-assets.d.ts +10 -0
  25. package/dist/create-webpack/rule-sets/rule-assets.js +1 -0
  26. package/dist/create-webpack/rule-sets/rule-css.d.ts +11 -0
  27. package/dist/create-webpack/rule-sets/rule-css.js +1 -0
  28. package/dist/create-webpack/rule-sets/rule-less.d.ts +26 -0
  29. package/dist/create-webpack/rule-sets/rule-less.js +1 -0
  30. package/dist/create-webpack/rule-sets/rule-scripts.d.ts +3 -0
  31. package/dist/create-webpack/rule-sets/rule-scripts.js +1 -0
  32. package/dist/create-webpack/rule-sets/rule-svg-icon.d.ts +6 -0
  33. package/dist/create-webpack/rule-sets/rule-svg-icon.js +1 -0
  34. package/dist/create-webpack/rule-sets/rule-utils.d.ts +7 -0
  35. package/dist/create-webpack/rule-sets/rule-utils.js +1 -0
  36. package/dist/create-webpack/types.d.ts +2 -0
  37. package/dist/create-webpack/types.js +1 -0
  38. package/dist/default-options.d.ts +2 -0
  39. package/dist/default-options.js +1 -0
  40. package/dist/define-config/define-config.d.ts +24 -0
  41. package/dist/define-config/define-config.js +1 -0
  42. package/dist/define-config/index.d.ts +1 -0
  43. package/dist/define-config/index.js +1 -0
  44. package/dist/dev-server/add-compiler-to-dev-server.d.ts +10 -0
  45. package/dist/dev-server/add-compiler-to-dev-server.js +1 -0
  46. package/dist/dev-server/create-app-page-route.d.ts +7 -0
  47. package/dist/dev-server/create-app-page-route.js +1 -0
  48. package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +3 -0
  49. package/dist/dev-server/create-dev-server-compiler-tasks.js +1 -0
  50. package/dist/dev-server/create-dev-server-entries.d.ts +4 -0
  51. package/dist/dev-server/create-dev-server-entries.js +1 -0
  52. package/dist/dev-server/create-dev-server.d.ts +6 -0
  53. package/dist/dev-server/create-dev-server.js +1 -0
  54. package/dist/dev-server/index.d.ts +6 -0
  55. package/dist/dev-server/index.js +1 -0
  56. package/dist/dev-server/middlewares/create-page-middleware.d.ts +37 -0
  57. package/dist/dev-server/middlewares/create-page-middleware.js +1 -0
  58. package/dist/dev-server/middlewares/create-public-assets-middleware.d.ts +2 -0
  59. package/dist/dev-server/middlewares/create-public-assets-middleware.js +1 -0
  60. package/dist/dev-server/middlewares/index.d.ts +2 -0
  61. package/dist/dev-server/middlewares/index.js +1 -0
  62. package/dist/errors/evolve-build-error.d.ts +4 -0
  63. package/dist/errors/evolve-build-error.js +1 -0
  64. package/dist/helpers/allow-px2rem-for-module.d.ts +3 -0
  65. package/dist/helpers/allow-px2rem-for-module.js +1 -0
  66. package/dist/helpers/assert-only-single-entry-item.d.ts +7 -0
  67. package/dist/helpers/assert-only-single-entry-item.js +1 -0
  68. package/dist/helpers/chunk-entry-map.d.ts +7 -0
  69. package/dist/helpers/chunk-entry-map.js +1 -0
  70. package/dist/helpers/enable-bundle-hashname-for-module.d.ts +3 -0
  71. package/dist/helpers/enable-bundle-hashname-for-module.js +1 -0
  72. package/dist/helpers/filter-actived-entries.d.ts +16 -0
  73. package/dist/helpers/filter-actived-entries.js +1 -0
  74. package/dist/helpers/get-bundle-file-name.d.ts +14 -0
  75. package/dist/helpers/get-bundle-file-name.js +1 -0
  76. package/dist/helpers/get-git-root.d.ts +1 -0
  77. package/dist/helpers/get-git-root.js +1 -0
  78. package/dist/helpers/get-html-plugin-config.d.ts +20 -0
  79. package/dist/helpers/get-html-plugin-config.js +1 -0
  80. package/dist/helpers/get-max-process-tasks.d.ts +1 -0
  81. package/dist/helpers/get-max-process-tasks.js +1 -0
  82. package/dist/helpers/get-pacakge-dir.d.ts +1 -0
  83. package/dist/helpers/get-pacakge-dir.js +1 -0
  84. package/dist/helpers/index.d.ts +17 -0
  85. package/dist/helpers/index.js +1 -0
  86. package/dist/helpers/json-serializer.d.ts +7 -0
  87. package/dist/helpers/json-serializer.js +1 -0
  88. package/dist/helpers/merge-babel-options.d.ts +4 -0
  89. package/dist/helpers/merge-babel-options.js +1 -0
  90. package/dist/helpers/normalize-entry-map.d.ts +15 -0
  91. package/dist/helpers/normalize-entry-map.js +1 -0
  92. package/dist/helpers/normalize-resolve-alias.d.ts +1 -0
  93. package/dist/helpers/normalize-resolve-alias.js +1 -0
  94. package/dist/helpers/open-page.d.ts +7 -0
  95. package/dist/helpers/open-page.js +1 -0
  96. package/dist/helpers/print-log.d.ts +8 -0
  97. package/dist/helpers/print-log.js +1 -0
  98. package/dist/helpers/refresh-evolve-mock-options.d.ts +3 -0
  99. package/dist/helpers/refresh-evolve-mock-options.js +1 -0
  100. package/dist/helpers/resolve-entry-map-input-files.d.ts +8 -0
  101. package/dist/helpers/resolve-entry-map-input-files.js +1 -0
  102. package/dist/helpers/script-injects.d.ts +11 -0
  103. package/dist/helpers/script-injects.js +1 -0
  104. package/dist/helpers/should-enable-react-fast-refresh.d.ts +3 -0
  105. package/dist/helpers/should-enable-react-fast-refresh.js +1 -0
  106. package/dist/helpers/split-to-multi-compiler.d.ts +8 -0
  107. package/dist/helpers/split-to-multi-compiler.js +1 -0
  108. package/dist/index.d.ts +5 -0
  109. package/dist/index.js +1 -0
  110. package/dist/load-config/index.d.ts +1 -0
  111. package/dist/load-config/index.js +1 -0
  112. package/dist/load-config/load-evolve-config.d.ts +11 -0
  113. package/dist/load-config/load-evolve-config.js +1 -0
  114. package/dist/loaders/loader-icon.cjs +33 -0
  115. package/dist/loaders/loader-icon.d.cts +1 -0
  116. package/dist/main/env-verify.d.ts +2 -0
  117. package/dist/main/env-verify.js +1 -0
  118. package/dist/main/get-worker-path.d.ts +1 -0
  119. package/dist/main/get-worker-path.js +1 -0
  120. package/dist/main/index.d.ts +4 -0
  121. package/dist/main/index.js +1 -0
  122. package/dist/main/prepare-build.d.ts +9 -0
  123. package/dist/main/prepare-build.js +1 -0
  124. package/dist/main/prepare-serve.d.ts +9 -0
  125. package/dist/main/prepare-serve.js +1 -0
  126. package/dist/main/prepare-static.d.ts +7 -0
  127. package/dist/main/prepare-static.js +1 -0
  128. package/dist/main/start-build-dynamic.d.ts +20 -0
  129. package/dist/main/start-build-dynamic.js +1 -0
  130. package/dist/main/start-build-worker.d.ts +12 -0
  131. package/dist/main/start-build-worker.js +1 -0
  132. package/dist/main/start-build.d.ts +5 -0
  133. package/dist/main/start-build.js +1 -0
  134. package/dist/main/start-one-entry-build.d.ts +13 -0
  135. package/dist/main/start-one-entry-build.js +1 -0
  136. package/dist/main/start-serve.d.ts +11 -0
  137. package/dist/main/start-serve.js +1 -0
  138. package/dist/main/start-static.d.ts +10 -0
  139. package/dist/main/start-static.js +1 -0
  140. package/dist/minimizer/create-minimizers.d.ts +3 -0
  141. package/dist/minimizer/create-minimizers.js +1 -0
  142. package/dist/minimizer/default-options.d.ts +2 -0
  143. package/dist/minimizer/default-options.js +1 -0
  144. package/dist/minimizer/image-minimizer.d.ts +16 -0
  145. package/dist/minimizer/image-minimizer.js +1 -0
  146. package/dist/minimizer/index.d.ts +1 -0
  147. package/dist/minimizer/index.js +1 -0
  148. package/dist/minimizer/terser-minimizer.d.ts +6 -0
  149. package/dist/minimizer/terser-minimizer.js +3 -0
  150. package/dist/minimizer/types.d.ts +2 -0
  151. package/dist/minimizer/types.js +1 -0
  152. package/dist/plugins/circular-dependency/circular-dependency-plugin.d.ts +54 -0
  153. package/dist/plugins/circular-dependency/circular-dependency-plugin.js +1 -0
  154. package/dist/plugins/circular-dependency/index.d.ts +7 -0
  155. package/dist/plugins/circular-dependency/index.js +1 -0
  156. package/dist/plugins/clean-webpack/clean-webpack-plugin.d.ts +67 -0
  157. package/dist/plugins/clean-webpack/clean-webpack-plugin.js +1 -0
  158. package/dist/plugins/clean-webpack/index.d.ts +9 -0
  159. package/dist/plugins/clean-webpack/index.js +1 -0
  160. package/dist/plugins/define-variable/define-variable-plugin.d.ts +14 -0
  161. package/dist/plugins/define-variable/define-variable-plugin.js +1 -0
  162. package/dist/plugins/define-variable/index.d.ts +1 -0
  163. package/dist/plugins/define-variable/index.js +1 -0
  164. package/dist/plugins/html-inject-scripts/plugin-html-inject-script.d.ts +8 -0
  165. package/dist/plugins/html-inject-scripts/plugin-html-inject-script.js +1 -0
  166. package/dist/plugins/module-federation/external-template-remotes.d.ts +4 -0
  167. package/dist/plugins/module-federation/external-template-remotes.js +1 -0
  168. package/dist/plugins/module-federation/index.d.ts +1 -0
  169. package/dist/plugins/module-federation/index.js +1 -0
  170. package/dist/plugins/module-federation/module-federation.d.ts +4 -0
  171. package/dist/plugins/module-federation/module-federation.js +1 -0
  172. package/dist/plugins/multi-html/index.d.ts +4 -0
  173. package/dist/plugins/multi-html/index.js +1 -0
  174. package/dist/plugins/multi-html/multi-html-cdn-plugin.d.ts +17 -0
  175. package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -0
  176. package/dist/plugins/multi-html/multi-html-plugin.d.ts +11 -0
  177. package/dist/plugins/multi-html/multi-html-plugin.js +1 -0
  178. package/dist/types/index.d.ts +8 -0
  179. package/dist/types/index.js +1 -0
  180. package/dist/types/types-ci.d.ts +23 -0
  181. package/dist/types/types-ci.js +1 -0
  182. package/dist/types/types-dev-server.d.ts +65 -0
  183. package/dist/types/types-dev-server.js +1 -0
  184. package/dist/types/types-entry-map.d.ts +71 -0
  185. package/dist/types/types-entry-map.js +1 -0
  186. package/dist/types/types-federation.d.ts +120 -0
  187. package/dist/types/types-federation.js +1 -0
  188. package/dist/types/types-loader-options.d.ts +76 -0
  189. package/dist/types/types-loader-options.js +1 -0
  190. package/dist/types/types-modular-import.d.ts +38 -0
  191. package/dist/types/types-modular-import.js +1 -0
  192. package/dist/types/types-multi-html.d.ts +75 -0
  193. package/dist/types/types-multi-html.js +1 -0
  194. package/dist/types/types-options.d.ts +117 -0
  195. package/dist/types/types-options.js +1 -0
  196. package/dist/types/types-plugin-options.d.ts +7 -0
  197. package/dist/types/types-plugin-options.js +1 -0
  198. package/dist/types/types-webpack.d.ts +96 -0
  199. package/dist/types/types-webpack.js +1 -0
  200. package/index.js +1 -4
  201. package/package.json +118 -61
  202. package/templates/html-plugin/index-dev.html +23 -46
  203. package/templates/html-plugin/index-inte.html +23 -46
  204. package/templates/html-plugin/index-inte2.html +23 -46
  205. package/templates/html-plugin/index-inte3.html +23 -46
  206. package/templates/html-plugin/index-inte4.html +23 -46
  207. package/templates/html-plugin/index-me.html +23 -46
  208. package/templates/html-plugin/index-prod.html +23 -46
  209. package/templates/html-plugin/index-rc.html +22 -46
  210. package/templates/html-plugin/index-uat.html +23 -46
  211. package/templates/main.html +2 -2
  212. package/templates/module-404.html +4 -2
  213. package/templates/module.html +31 -61
  214. package/cjs/index.js +0 -4
  215. package/cjs/loader-icon.js +0 -2
  216. package/index.d.ts +0 -721
package/index.d.ts DELETED
@@ -1,721 +0,0 @@
1
- import { DeepPartial, Json, RecordAny, TypeAny, VerifyPackagePattern } from '@flatjs/common';
2
- import { PixelOptions } from '@flatjs/forge-plugin-postcss-pixel';
3
- import { FlatMockOptions, MockRequestHandler } from '@flatjs/mock';
4
- import { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
5
-
6
- declare const defaultHtmlPluginConfig: Required<MultiHtmlCDNEntryItem>;
7
- export type HtmlPluginConfigConfigData = {
8
- mode: "development" | "production";
9
- /**
10
- * The random `cdn` for config via `env` template
11
- */
12
- envCdn: string;
13
- };
14
- export type HtmlPluginConfigTokenType<T extends Json> = T | ((configData: HtmlPluginConfigConfigData) => T);
15
- /**
16
- * 获取html plugin 模版相关定义字段.
17
- * @param preferredValue 用户首选的值, 如果返回为undefined, 将使用默认值
18
- * @returns
19
- */
20
- export declare const getHtmlPluginConfig: <T extends Json>(key: keyof typeof defaultHtmlPluginConfig, configData: HtmlPluginConfigConfigData, preferredValue?: HtmlPluginConfigTokenType<T> | undefined) => T;
21
- /**
22
- * Advanced configuration for modules that should be shared in the share scope.
23
- */
24
- export interface SharedConfig {
25
- /**
26
- * Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
27
- */
28
- eager?: boolean;
29
- /**
30
- * Provided module that should be provided to share scope. Also acts as fallback module if no shared module is found in share scope or version isn't valid. Defaults to the property name.
31
- */
32
- import?: string | false;
33
- /**
34
- * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
35
- */
36
- packageName?: string;
37
- /**
38
- * Version requirement from module in share scope.
39
- */
40
- requiredVersion?: string | false;
41
- /**
42
- * Module is looked up under this key from the share scope.
43
- */
44
- shareKey?: string;
45
- /**
46
- * Share scope name.
47
- */
48
- shareScope?: string;
49
- /**
50
- * Allow only a single version of the shared module in share scope (disabled by default).
51
- */
52
- singleton?: boolean;
53
- /**
54
- * Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).
55
- */
56
- strictVersion?: boolean;
57
- /**
58
- * Version of the provided module. Will replace lower matching versions, but not higher.
59
- */
60
- version?: string | false;
61
- }
62
- export interface SharedObject {
63
- [index: string]: string | SharedConfig;
64
- }
65
- /**
66
- * Advanced configuration for modules that should be exposed by this container.
67
- */
68
- export interface ExposesConfig {
69
- /**
70
- * Request to a module that should be exposed by this container.
71
- */
72
- import: string | string[];
73
- /**
74
- * Custom chunk name for the exposed module.
75
- */
76
- name?: string;
77
- }
78
- /**
79
- * Modules that should be exposed by this container. Property names are used as public paths.
80
- */
81
- export interface ExposesObject {
82
- [index: string]: string | ExposesConfig | string[];
83
- }
84
- /**
85
- * Multiple separate builds should form a single application.
86
- * This is often known as Micro-Frontends, but is not limited to that.
87
- */
88
- export type ModuleFederationOptions = {
89
- /**
90
- * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
91
- * {`${projectVirtualPath}/home`,`${projectVirtualPath}/mine`}
92
- */
93
- remotes?: Array<{
94
- /**
95
- * Normally it can be the entryPath like `${projectVirtualPath}/home`
96
- * it will formatted into `evolve_demo_home`
97
- * Note: We need to config `declare module 'evolve_react_demo_home/Widget` in `global.d.ts`;
98
- */
99
- name: string;
100
- /**
101
- * The remote app resouce endpoint base path.
102
- * Normally This is only required when an external project module as remote widget.
103
- */
104
- endpoint?: (entryPath: string) => string;
105
- }>;
106
- /**
107
- * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
108
- */
109
- exposes?: (string | ExposesObject)[] | ExposesObject;
110
- /**
111
- * Share scope name used for all shared modules (defaults to 'default').
112
- */
113
- shareScope?: string;
114
- /**
115
- * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
116
- */
117
- shared?: (string | SharedObject)[] | SharedObject;
118
- };
119
- /**
120
- * The webpack entry configuration.
121
- */
122
- export interface WebpackEntryObject {
123
- [index: string]: string | [
124
- string,
125
- ...string[]
126
- ];
127
- }
128
- export declare type MultiCdnEnvType = "me" | "dev" | "uat" | "inte" | "inte2" | "inte3" | "inte4" | "rc" | "prod" | "ntv";
129
- export type FlatMultiCDNConfig = {
130
- [key in MultiCdnEnvType]?: string[];
131
- };
132
- /**
133
- * Allow us customized to resolve current runtime environment.
134
- */
135
- export type FlatMultiCDNConfigResolver = (url: string) => MultiCdnEnvType | undefined;
136
- /**
137
- * The html plugin configuration for each entry item
138
- */
139
- export declare type MultiHtmlCDNEntryItem = {
140
- /**
141
- * The title to use for the generated HTML document
142
- * @default ''
143
- */
144
- title?: string;
145
- /**
146
- * The favicon url to use for the generated HTML document
147
- */
148
- favicon?: string;
149
- /**
150
- * webpack relative or absolute path to the template.
151
- * By default it will use src/index.ejs if it exists.
152
- * e.g. It must be an absolute path. path.join(__dirname, `templates/index-{0}.html`)
153
- */
154
- template?: string;
155
- /**
156
- * Indicates if we need to minify html.
157
- * @default true
158
- */
159
- minify?: boolean;
160
- /**
161
- * Support inject viewport scripts in each modules
162
- * It only available while `allowPx2rem` = true
163
- * @default ''
164
- */
165
- viewport?: string;
166
- /**
167
- * Allow us customized inline scripts into compiled html template.
168
- * @default []
169
- */
170
- inlineScripts?: HtmlPluginConfigTokenType<string[]>;
171
- /**
172
- * The ordered styles will be injected start of html head.
173
- * @default []
174
- */
175
- headBeforeStyles?: HtmlPluginConfigTokenType<string[]>;
176
- /**
177
- * The ordered scripts will be injected before html head.
178
- * @default [
179
- * `https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CArray.isArray%2CArray.of%2CArray.prototype.entries%2CArray.prototype.every%2CArray.prototype.fill%2CArray.prototype.filter%2CArray.prototype.find%2CArray.prototype.findIndex%2CArray.prototype.flat%2CArray.prototype.forEach%2CArray.prototype.flatMap%2CArray.prototype.keys%2CArray.prototype.indexOf%2CArray.prototype.includes%2CArray.prototype.lastIndexOf%2CArray.prototype.map%2CArray.prototype.reduce%2CArray.prototype.reduceRight%2CArray.prototype.some%2CArray.prototype.sort%2CArray.prototype.values%2CArrayBuffer%2CBlob%2CDataView%2CDate.now%2CObject.assign%2CObject.create%2CObject.defineProperties%2CObject.defineProperty%2CObject.entries%2CObject.freeze%2CObject.fromEntries%2CObject.getOwnPropertySymbols%2CObject.getOwnPropertyNames%2CObject.getOwnPropertyDescriptors%2CObject.getOwnPropertyDescriptor%2CObject.getPrototypeOf%2CObject.is%2CObject.isExtensible%2CObject.isFrozen%2CObject.isSealed%2CObject.keys%2CObject.values%2CObject.setPrototypeOf%2CPromise%2CPromise.prototype.finally%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.getPrototypeOf%2CReflect.getOwnPropertyDescriptor%2CReflect.get%2CReflect.ownKeys%2CReflect.isExtensible%2CReflect.has%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf%2CSet%2CString.prototype.trimStart%2CString.prototype.trimEnd%2CString.prototype.trim%2CString.prototype.startsWith%2CString.prototype.repeat%2CString.prototype.replaceAll%2CString.prototype.padStart%2CString.prototype.padEnd%2CMap%2CObject.seal%2Cconsole.groupEnd%2Cconsole.group`,
180
- * `https://unpkg.com/react@17.0.2/umd/react.production.min.js`,
181
- * `https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js`,
182
- * `https://unpkg.com/react-router-dom@5.2.0/umd/react-router-dom.min.js`
183
- * ]
184
- */
185
- headBeforeScripts?: HtmlPluginConfigTokenType<string[]>;
186
- /**
187
- * The ordered scripts will be injected end of html body.
188
- * @default []
189
- */
190
- bodyAfterScripts?: HtmlPluginConfigTokenType<string[]>;
191
- /**
192
- * Give `env` list to exclude from `multi-cdn` plugin.
193
- * Normally for `me`, `dev`,`uat`, `ntv` env we should use relative assets path instead cdn.
194
- * @default ['dev', 'ntv']
195
- */
196
- excludeCdnEnvs?: MultiCdnEnvType[];
197
- };
198
- /**
199
- * The configuration options for each entry item.
200
- */
201
- export interface EvolveEntryItemOption extends MultiHtmlCDNEntryItem {
202
- /**
203
- * The value indicates if we need to Px convert to rem.
204
- * @default entryItemOption?.allowPx2rem ?? pluginLoaderOptions?.pixelOptions?.enabled
205
- */
206
- allowPx2rem?: boolean;
207
- /**
208
- * If all we use `contenthash` bundle name.
209
- * @default true
210
- */
211
- enableBundleHashName?: boolean;
212
- /**
213
- * Allow customized module `link` on `/pages`
214
- * @default undefined
215
- */
216
- servePageMainLinkFn?: (link: string, options: {
217
- entryName: string;
218
- hostUri: string;
219
- virtualPath: string;
220
- }) => string;
221
- /**
222
- * For `serve`
223
- * Customized module template to proxy the modules template.
224
- * If providered, it must be an absolute path. path.join(__dirname, `templates/module.html`)
225
- * Normally it will find file `${projectCwd}/templates/module.html` automatically
226
- */
227
- serveModuleTemplate?: string;
228
- /**
229
- * For `serve`
230
- * Attach fixed global data for specificed entry.
231
- * Will merged into `window.GLOBAL = {...globalData}`
232
- * @default {}
233
- */
234
- serveGlobalData?: RecordAny;
235
- /**
236
- * Multiple separate builds should form a single application.
237
- * This is often known as Micro-Frontends, but is not limited to that.
238
- */
239
- moduleFederation?: ModuleFederationOptions;
240
- /**
241
- * The value indicates if we need to build relative asset public path?
242
- * @default false
243
- */
244
- useRelativeAssetPath?: boolean;
245
- /**
246
- * Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
247
- * Note It will merged with globall externals configuration and apply for current entry compiler
248
- */
249
- externals?: Record<string, string> | ((serveMode: boolean) => Record<string, string>);
250
- }
251
- export type EvolveEntryMapContent = {
252
- entry: [
253
- string,
254
- ...string[]
255
- ];
256
- options?: EvolveEntryItemOption;
257
- };
258
- export interface EvolveEntryMap {
259
- /**
260
- * <entryChunkName>: {}
261
- */
262
- [entryName: string]: EvolveEntryMapContent;
263
- }
264
- /**
265
- * Builtin babel options, provider default `builin` presets.
266
- * `react`, `vue`, can be override by customized `presets` & `plugins`
267
- */
268
- export type BuiltinBabelOptions = Partial<Record<"presets" | "plugins", Array<string | [
269
- string,
270
- RecordAny
271
- ] | [
272
- string,
273
- RecordAny,
274
- string
275
- ]>>> & {
276
- /**
277
- * @default `react`
278
- */
279
- usePreset?: "react" | "vue" | "inferno";
280
- };
281
- /**
282
- * Buildin plugin `babel-plugin-import` configurations
283
- */
284
- export type ModularImportOption = {
285
- /**
286
- * @example `antd`, `lodash`, `material-ui`, `@flatjs`, `@dimjs`, `@wine`,`@fabric`
287
- */
288
- libraryName: string;
289
- /**
290
- * Set this option to false if your module does not have a default export.
291
- * @default false
292
- */
293
- transformToDefaultImport?: boolean;
294
- /**
295
- * @default: `esm`
296
- */
297
- libraryDirectory?: string;
298
- /**
299
- * The value will append to `${libraryDirectory}/${transformedMethodName}/${fileName}`
300
- * e.g. `@scope/app/esm/{moduleName}/index`
301
- * @default ""
302
- */
303
- fileName?: string;
304
- /**
305
- * We can use customName to customize import file path.
306
- * @example `esm/modal`
307
- */
308
- customName?: (transformedMethodName: string, file: any) => string;
309
- /**
310
- * @default: true
311
- */
312
- camel2DashComponentName?: boolean;
313
- /**
314
- * @default false
315
- * @example (name) => `${name}/style/2x` }
316
- */
317
- style?: true | "css" | ((name: string, file: Record<string, unknown>) => string);
318
- };
319
- /**
320
- * `forge` Pixel plugin configuration
321
- */
322
- export type BuiltinPixelOptions = Partial<PixelOptions> & {
323
- /**
324
- * @default true
325
- */
326
- enabled?: boolean;
327
- };
328
- /**
329
- * The configurations for `builtin` loaders
330
- */
331
- export interface PluginLoaderOptions {
332
- /**
333
- * The config for `Less`
334
- */
335
- lessOptions?: TypeAny;
336
- /**
337
- * The babel options for `babel-loader`
338
- */
339
- babelOptions?: BuiltinBabelOptions | ((serveMode: boolean) => BuiltinBabelOptions);
340
- /**
341
- * `contentehash` bundle file name.
342
- * @default true
343
- */
344
- enableBundleHashName?: boolean;
345
- /**
346
- * The config options fro `@flatjs/forge-plugin-postcss-plugin`
347
- * If provider it will use default options of `forgePluginPostcssPixel`
348
- */
349
- pixelOptions?: BuiltinPixelOptions;
350
- /**
351
- * The overrided configurations of `cssnano-preset-default`
352
- * sometimes we need to disabled some rules for `default cssnano preset`
353
- * @example
354
- * diable `postcss-minify-font-values` rule to avoid transitions from `font-weight:bold` to `font-weight:700`
355
- * ```json
356
- * cssnanoOptions: { minifyFontValues: false }
357
- * ```
358
- */
359
- cssnanoOptions?: Record<string, unknown>;
360
- /**
361
- * Modular import plugin for babel, compatible with antd, antd-mobile, lodash, material-ui, and so on.
362
- * https://github.com/ant-design/babel-plugin-import
363
- */
364
- modularImports?: ModularImportOption[] | ((serveMode: boolean) => ModularImportOption[]);
365
- }
366
- export interface WebpackWatchOptions {
367
- /**
368
- * Delay the rebuilt after the first change. Value is a time in ms.
369
- */
370
- aggregateTimeout?: number;
371
- /**
372
- * Resolve symlinks and watch symlink and real file. This is usually not needed as webpack already resolves symlinks ('resolve.symlinks').
373
- */
374
- followSymlinks?: boolean;
375
- /**
376
- * Ignore some files from watching (glob pattern or regexp).
377
- */
378
- ignored?: string | RegExp | string[];
379
- /**
380
- * Enable polling mode for watching.
381
- */
382
- poll?: number | boolean;
383
- }
384
- export type analyzerPluginOptions = {};
385
- /**
386
- * Detect locally installed dependencies that have correctly installed from `package.json` declared version `dependencies`
387
- */
388
- export type PackageInstallChecker = {
389
- /**
390
- * @default false
391
- */
392
- enabled?: boolean;
393
- /**
394
- * Stop program if we have detect unexpected error.
395
- * @default false
396
- */
397
- throwError?: boolean;
398
- /**
399
- * Flat indicates if we need to print all install module graph
400
- * @default false
401
- */
402
- showAllinstalledGraph?: boolean;
403
- /**
404
- * Package module name, or module expression. [`^babel-`,`@dimjs/*`]
405
- * @defalt ['@dimjs/*']
406
- */
407
- detectModules?: string[];
408
- };
409
- export interface FlatEvolveOptions extends Partial<Pick<Configuration, "performance">> {
410
- /**
411
- * Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
412
- * Note It's globally external configurations for all entries, if we need to specificed externals for each entry.
413
- * Simply move it into entry options.
414
- * @default
415
- * ``` ts
416
- * vue: 'Vue',
417
- * react: 'React',
418
- * 'react-dom': 'ReactDOM',
419
- * 'react-router': 'ReactRouter',
420
- * 'react-router-dom': 'ReactRouterDOM',
421
- * ```
422
- */
423
- externals?: Record<string, string> | ((serveMode: boolean) => Record<string, string>);
424
- /**
425
- * Indicates current we use `hot` mode for `webpack-dev-server` hot reload true.
426
- * @default false
427
- */
428
- liveReload?: boolean;
429
- /**
430
- * Environment to build for. An array of environments to build for all of them when possible.
431
- */
432
- target?: string | false | string[];
433
- /**
434
- * The project workspace directory.
435
- */
436
- projectCwd: string;
437
- /**
438
- * The virtual path for current `project`
439
- * e.g. `evolve/test`
440
- */
441
- projectVirtualPath: string;
442
- /**
443
- * The plugin for `@flatjs/evolve-multi-html-cdn-plugin`
444
- */
445
- multiHtmlCdn: FlatMultiCDNConfig;
446
- /**
447
- * Allow us customized to resolve current runtime environment.
448
- * ignore resolver if return undefined, otherwise use it to match environment.
449
- * @example
450
- * ```ts
451
- * (url)=> {
452
- * const env = /.*\.(qa|t)\.*\/.exec('//fex.qa.tcshuke.com/')[1];
453
- * switch(env) {
454
- * case 't':
455
- * return 'rc'
456
- * case 'qa':
457
- * return 'inte'
458
- * }
459
- * }
460
- * ```
461
- */
462
- multiHtmlCdnResolver?: FlatMultiCDNConfigResolver;
463
- /**
464
- * The regexp patterns to filter dependencies(will be verified) from package.json
465
- * @default []
466
- */
467
- needVerifyPackages: VerifyPackagePattern;
468
- /**
469
- * Detect locally installed dependencies that have correctly installed from `package.json`
470
- */
471
- packageInstallChecker?: PackageInstallChecker;
472
- /**
473
- * All webpack entries configuration
474
- */
475
- entryMap: EvolveEntryMap;
476
- /**
477
- * Visualize size of webpack output files with an interactive zoomable treemap.
478
- */
479
- analyzer?: Record<string, unknown>;
480
- /**
481
- * Indicates if we need to minimize scripts while `production` using `TerserPlugin`
482
- * @default true
483
- */
484
- minimize?: boolean;
485
- /**
486
- * A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
487
- * https://webpack.js.org/configuration/devtool/
488
- *
489
- * `source-map` Recommended choice for production builds with high quality SourceMaps.
490
- */
491
- productionSourceMap?: string | false;
492
- /**
493
- * The terser minimizer plugin configurations.
494
- */
495
- minimizeTerserOptions?: RecordAny;
496
- /**
497
- * Redirect module requests. resolve `alias`
498
- * @example
499
- * ```ts
500
- * "compilerOptions": {
501
- * "baseUrl": "./",
502
- * "paths": {
503
- * "@/*": ["src/*"]
504
- * },
505
- * }
506
- * }
507
- * ```
508
- * Configd resolve alias as below.
509
- * ---
510
- * ```ts
511
- * {
512
- * resolveAlias: {
513
- * '@': require('path').join(__dirname, './src'),
514
- * }
515
- * }
516
- *
517
- * ```
518
- */
519
- resolveAlias?: {
520
- [index: string]: string;
521
- } | ((serveMode: boolean) => {
522
- [index: string]: string;
523
- });
524
- /**
525
- * Turn on watch mode. This means that after the initial build, webpack will continue to watch for changes in any of the resolved files.
526
- * In webpack-dev-server watch mode is enabled by default.
527
- * This configuration will be merged into `webpack-dev-server`
528
- */
529
- watchOptions?: WebpackWatchOptions;
530
- /**
531
- * The loader/plugin configurations for all `builtin` loaders or plugins.
532
- */
533
- pluginLoaderOptions?: PluginLoaderOptions;
534
- /**
535
- * The loaders we have defined by myself.
536
- */
537
- extraLoaders?: RuleSetRule[] | ((serveMode: boolean) => RuleSetRule[]);
538
- /**
539
- * The plugins we have defined by myself.
540
- */
541
- extraPlugins?: WebpackPluginInstance[] | ((serveMode: boolean) => WebpackPluginInstance[]);
542
- /**
543
- * Provide your own certificate using the https option
544
- */
545
- https?: {
546
- /**
547
- * The privateKey
548
- */
549
- key: string;
550
- /**
551
- * The certificate
552
- */
553
- cert: string;
554
- };
555
- /**
556
- * The all configurations defined for `serve` (development) mode
557
- */
558
- forServe: {
559
- /**
560
- * Allow us provider customized middlewares for `page`, `modules`
561
- */
562
- pageMiddlewares?: MockRequestHandler[];
563
- /**
564
- * Allow us costomized global serve data injected into `window.GLOBAL = {...globalData}`
565
- */
566
- defaultServeGlobalData?: (entryItem: EvolveEntryMapContent, hostUrl: string) => Record<string, unknown>;
567
- };
568
- /**
569
- * The all configurations defined for `build` (production) mode
570
- */
571
- forBuild: {
572
- /**
573
- * The value indicates if we interrupt compilation process while received "warnings" while evolve `build`
574
- * @default false
575
- */
576
- rejectWarnings?: boolean;
577
- };
578
- }
579
- /**
580
- * this interface designed to manager shortcut configurations for @flatjs/evolve
581
- * 1. write your configs to flatjs.evolve.js
582
- * 2. write you configs to `flatjsEvolve` node of package.json
583
- */
584
- export interface FlatjsConfig {
585
- /**
586
- * the main configuration node:
587
- */
588
- flatjsEvolve: FlatEvolveOptions;
589
- }
590
- export type FlatjsPartialConfig = {
591
- flatjsEvolve: DeepPartial<FlatEvolveOptions>;
592
- };
593
- export declare const flatBabelOptions: (babelOptions?: BuiltinBabelOptions, modularImports?: ModularImportOption[]) => RecordAny;
594
- /**
595
- * https://polyfill.io
596
- */
597
- export declare const polyfill: string[];
598
- export type CDNConfig = {
599
- /**
600
- * react development
601
- */
602
- reactDev: string[];
603
- /**
604
- * react production
605
- */
606
- reactProd: string[];
607
- };
608
- /**
609
- * https://unpkg.com/
610
- */
611
- export declare const cdnUnpkg: CDNConfig;
612
- /**
613
- * https://www.jsdelivr.com/
614
- */
615
- export declare const cdnJsDelivr: CDNConfig;
616
- /**
617
- * https://www.bootcdn.cn/
618
- */
619
- export declare const cdnBoot: CDNConfig;
620
- export declare const defaultFlatjsConfig: FlatjsPartialConfig;
621
- export declare const flatExternalOptions: (serveMode: boolean, globalExternals: FlatEvolveOptions["externals"], singleEntryItem: [
622
- string,
623
- EvolveEntryMapContent
624
- ]) => Record<string, string>;
625
- /**
626
- * Normalize less-loader options.
627
- * @param serveMode The value indicates if we are in `built` or `serve` mode.
628
- * @param lessOptions The configurations of `less`
629
- */
630
- export declare const flatLessLoaderOptions: (serveMode: boolean, lessOptions: RecordAny) => RecordAny;
631
- /**
632
- * Normalize postcss-loader options.
633
- * @param serveMode The value indicates if we are in `built` or `serve` mode.
634
- * @param postcssPixelOptions The pixel options of `postcss` plugin
635
- * @param cssnanoOptions The configuration rules for `cssnano`
636
- */
637
- export declare const flatPostcssLoaderOptions: (serveMode: boolean, postcssPixelOptions?: BuiltinPixelOptions, cssnanoOptions?: Record<string, unknown>) => RecordAny;
638
- export declare const flatPerformanceOptions: (serveMode: boolean, performanceOptions?: {}) => RecordAny;
639
- /**
640
- * https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
641
- * @param newOptions
642
- */
643
- export declare const terserOptions: (terserOption?: RecordAny) => RecordAny;
644
- /**
645
- * `viewport.js` 用来支持当前移动端rem转换自适应方案.
646
- * 如果开启动态在html-plugin最前面动态插入 viewport代码
647
- */
648
- export declare const viewportScripts = "(function(d){var j;var b=1;var i=1;var h=750;var c=100;function e(s,o){var q=d.document;var l=q.documentElement;var k=navigator.userAgent;var m=k.toLowerCase().indexOf(\"android\")>-1;i=d.devicePixelRatio||1;if(i>3){i=3}if(m){i=1}console.log(\"current devicePixelRatio:\",i);l.setAttribute(\"data-dpr\",i.toString());var p=q.querySelector('meta[name=\"viewport\"]');if(!p){b=1/i;p=q.createElement(\"meta\");p.setAttribute(\"name\",\"viewport\");q.head.appendChild(p);p.setAttribute([\"content\",\"width=device-width,user-scalable=no,initial-scale=\",b,\",maximum-scale=\",b,\",minimum-scale=\",b].join(\"\"))}function n(){var t=document.documentElement.clientWidth;j=t/o*(s/i)*i;q.documentElement.style.fontSize=String(j)+\"px\"}var r;d.addEventListener(\"resize\",function(){clearTimeout(r);r=setTimeout(n,300)},false);d.addEventListener(\"onload\",n,false);n()}e(c,h);window.fabricViewport={currRem:j,currDpr:i,currScale:b,dpiPX2px:function f(k){return parseFloat(k.toString())/j*100+\"px\"},px2DPIpx:function a(k){return parseFloat(k.toString())/100*j+\"px\"},px2rem:function g(k){return parseFloat(k.toString())/100+\"rem\"}}})(window);";
649
- export type EvolveBuildResult = {
650
- name?: string;
651
- warningStats?: TypeAny;
652
- };
653
- /**
654
- * Normalize flatjs.evolve entry map definition data.
655
- * Merge default entry item configuration values.
656
- * @param activedEntries actived entries
657
- * @param definedEntries defined entries in flatjs.evolve.js
658
- */
659
- export declare const normalizeEntries: (activedEntries?: EvolveEntryMap, definedEntries?: EvolveEntryMap) => EvolveEntryMap;
660
- /**
661
- * The main entry to start an evolve `build`
662
- * @param projectCwd The Root directory (workspace) of this project.
663
- * @param buildEntries All webpack entries we prepare to build.
664
- * @param evolveOptions FlatEvolveOptions
665
- * @param clearCache The value indicates if we need to clear webpack cache resources.
666
- */
667
- export declare const evolveBuild: (projectCwd: string, buildEntries: EvolveEntryMap, evolveOptions?: DeepPartial<FlatEvolveOptions>) => Promise<EvolveBuildResult[]>;
668
- /**
669
- * The main entry to start evolve serve
670
- * @param projectCwd The Root directory (workspace) of this project.
671
- * @param servedEntries All webpack entries we have served.
672
- * @param evolveOptions FlatEvolveOptions
673
- * @param mockOptions FlatMockOptions
674
- */
675
- export declare const evolveServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions?: DeepPartial<FlatEvolveOptions>, mockOptions?: DeepPartial<FlatMockOptions>) => Promise<boolean>;
676
- /**
677
- * The main entry to start evolve static server to proxy all modules of `production` build
678
- * @param projectCwd The Root directory (workspace) of this project.
679
- * @param evolveOptions FlatEvolveOptions
680
- * @param mockOptions FlatMockOptions
681
- */
682
- export declare const evolveStatic: (projectCwd: string, evolveOptions?: DeepPartial<FlatEvolveOptions>, mockOptions?: DeepPartial<FlatMockOptions>) => Promise<boolean>;
683
- /**
684
- * Try to load flatjs evolve configurations from `flatjs.evolve.js`
685
- * @param projectCwd The workspace for project
686
- * @param overrideOptions The configuration for this project.
687
- */
688
- export declare const loadEvolveConfiguration: (projectCwd: string | undefined, overrideOptions: DeepPartial<FlatEvolveOptions>) => FlatEvolveOptions;
689
- /**
690
- * Provider tool to dynamic require node module without `cache`
691
- * if you need to ts support please manully run `registerTsNode` from `@flatjs/mock`
692
- * @param moduleId
693
- * @param refresh
694
- */
695
- export declare const loadModule: <T>(moduleId: string, refresh?: boolean) => T;
696
- export type EvolveDevServerEntryMap = {
697
- [entryName: string]: {
698
- /**
699
- * dev server port number
700
- */
701
- devServerPort: number;
702
- /**
703
- * dev server host uri.
704
- */
705
- devServerHostUri: string;
706
- };
707
- };
708
- /**
709
- * A middleware to proxy the page modules template.
710
- * @example `http://dev.flatjs.com:3001/pages`
711
- * @param mode The mode of this dev server instance.
712
- * @param hostUri The main host base url.
713
- * @param apiContext apiBase e.g. `api`
714
- * @param servedDevServerEntries The served webpack entries
715
- * @param forPageMiddlewares Allow us provider customized middlewares for `page`, `modules`
716
- * @param options The evolve config options
717
- */
718
- export declare const createPageMiddleware: (mode: "development" | "production", hostUri: string, apiContext: string, servedDevServerEntries: EvolveDevServerEntryMap, options: FlatEvolveOptions) => MockRequestHandler[];
719
- export declare const createPublicAssetsMiddleware: (projectCwd: string) => MockRequestHandler;
720
-
721
- export {};