@flatjs/evolve 1.7.2 → 1.8.1-next.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. package/CHANGELOG.md +17 -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 +9 -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 +6 -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/helpers/allow-px2rem-for-module.d.ts +3 -0
  63. package/dist/helpers/allow-px2rem-for-module.js +1 -0
  64. package/dist/helpers/assert-only-single-entry-item.d.ts +7 -0
  65. package/dist/helpers/assert-only-single-entry-item.js +1 -0
  66. package/dist/helpers/enable-bundle-hashname-for-module.d.ts +3 -0
  67. package/dist/helpers/enable-bundle-hashname-for-module.js +1 -0
  68. package/dist/helpers/get-bundle-file-name.d.ts +14 -0
  69. package/dist/helpers/get-bundle-file-name.js +1 -0
  70. package/dist/helpers/get-html-plugin-config.d.ts +12 -0
  71. package/dist/helpers/get-html-plugin-config.js +1 -0
  72. package/dist/helpers/get-pacakge-dir.d.ts +1 -0
  73. package/dist/helpers/get-pacakge-dir.js +1 -0
  74. package/dist/helpers/index.d.ts +14 -0
  75. package/dist/helpers/index.js +1 -0
  76. package/dist/helpers/merge-babel-options.d.ts +4 -0
  77. package/dist/helpers/merge-babel-options.js +1 -0
  78. package/dist/helpers/normalize-entry-map.d.ts +15 -0
  79. package/dist/helpers/normalize-entry-map.js +1 -0
  80. package/dist/helpers/open-page.d.ts +7 -0
  81. package/dist/helpers/open-page.js +1 -0
  82. package/dist/helpers/print-log.d.ts +2 -0
  83. package/dist/helpers/print-log.js +1 -0
  84. package/dist/helpers/refresh-evolve-mock-options.d.ts +3 -0
  85. package/dist/helpers/refresh-evolve-mock-options.js +1 -0
  86. package/dist/helpers/script-injects.d.ts +11 -0
  87. package/dist/helpers/script-injects.js +1 -0
  88. package/dist/helpers/should-enable-react-fast-refresh.d.ts +3 -0
  89. package/dist/helpers/should-enable-react-fast-refresh.js +1 -0
  90. package/dist/helpers/split-to-multi-compiler.d.ts +8 -0
  91. package/dist/helpers/split-to-multi-compiler.js +1 -0
  92. package/dist/index.d.ts +4 -0
  93. package/dist/index.js +1 -0
  94. package/dist/load-config/index.d.ts +1 -0
  95. package/dist/load-config/index.js +1 -0
  96. package/dist/load-config/load-evolve-config.d.ts +9 -0
  97. package/dist/load-config/load-evolve-config.js +1 -0
  98. package/dist/loaders/loader-icon.cjs +33 -0
  99. package/dist/loaders/loader-icon.d.cts +1 -0
  100. package/dist/main/env-verify.d.ts +2 -0
  101. package/dist/main/env-verify.js +1 -0
  102. package/dist/main/index.d.ts +3 -0
  103. package/dist/main/index.js +1 -0
  104. package/dist/main/prepare-build.d.ts +13 -0
  105. package/dist/main/prepare-build.js +1 -0
  106. package/dist/main/prepare-serve.d.ts +9 -0
  107. package/dist/main/prepare-serve.js +1 -0
  108. package/dist/main/prepare-static.d.ts +7 -0
  109. package/dist/main/prepare-static.js +1 -0
  110. package/dist/main/start-build.d.ts +13 -0
  111. package/dist/main/start-build.js +1 -0
  112. package/dist/main/start-serve.d.ts +11 -0
  113. package/dist/main/start-serve.js +1 -0
  114. package/dist/main/start-static.d.ts +10 -0
  115. package/dist/main/start-static.js +1 -0
  116. package/dist/minimizer/create-minimizers.d.ts +3 -0
  117. package/dist/minimizer/create-minimizers.js +1 -0
  118. package/dist/minimizer/default-options.d.ts +2 -0
  119. package/dist/minimizer/default-options.js +1 -0
  120. package/dist/minimizer/image-minimizer.d.ts +7 -0
  121. package/dist/minimizer/image-minimizer.js +1 -0
  122. package/dist/minimizer/index.d.ts +1 -0
  123. package/dist/minimizer/index.js +1 -0
  124. package/dist/minimizer/terser-minimizer.d.ts +6 -0
  125. package/dist/minimizer/terser-minimizer.js +3 -0
  126. package/dist/minimizer/types.d.ts +2 -0
  127. package/dist/minimizer/types.js +1 -0
  128. package/dist/plugins/clean-webpack/clean-webpack-plugin.d.ts +67 -0
  129. package/dist/plugins/clean-webpack/clean-webpack-plugin.js +1 -0
  130. package/dist/plugins/clean-webpack/index.d.ts +9 -0
  131. package/dist/plugins/clean-webpack/index.js +1 -0
  132. package/dist/plugins/html-inject-scripts/plugin-html-inject-script.d.ts +8 -0
  133. package/dist/plugins/html-inject-scripts/plugin-html-inject-script.js +1 -0
  134. package/dist/plugins/module-federation/external-template-remotes.d.ts +4 -0
  135. package/dist/plugins/module-federation/external-template-remotes.js +1 -0
  136. package/dist/plugins/module-federation/index.d.ts +1 -0
  137. package/dist/plugins/module-federation/index.js +1 -0
  138. package/dist/plugins/module-federation/module-federation.d.ts +4 -0
  139. package/dist/plugins/module-federation/module-federation.js +1 -0
  140. package/dist/plugins/multi-html/index.d.ts +4 -0
  141. package/dist/plugins/multi-html/index.js +1 -0
  142. package/dist/plugins/multi-html/multi-html-cdn-plugin.d.ts +17 -0
  143. package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -0
  144. package/dist/plugins/multi-html/multi-html-plugin.d.ts +11 -0
  145. package/dist/plugins/multi-html/multi-html-plugin.js +1 -0
  146. package/dist/types/index.d.ts +8 -0
  147. package/dist/types/index.js +1 -0
  148. package/dist/types/types-dev-server.d.ts +51 -0
  149. package/dist/types/types-dev-server.js +1 -0
  150. package/dist/types/types-entry-map.d.ts +66 -0
  151. package/dist/types/types-entry-map.js +1 -0
  152. package/dist/types/types-federation.d.ts +120 -0
  153. package/dist/types/types-federation.js +1 -0
  154. package/dist/types/types-loader-options.d.ts +61 -0
  155. package/dist/types/types-loader-options.js +1 -0
  156. package/dist/types/types-modular-import.d.ts +38 -0
  157. package/dist/types/types-modular-import.js +1 -0
  158. package/dist/types/types-multi-html.d.ts +74 -0
  159. package/dist/types/types-multi-html.js +1 -0
  160. package/dist/types/types-options.d.ts +98 -0
  161. package/dist/types/types-options.js +1 -0
  162. package/dist/types/types-webpack.d.ts +70 -0
  163. package/dist/types/types-webpack.js +1 -0
  164. package/index.js +1 -4
  165. package/package.json +107 -59
  166. package/templates/html-plugin/index-dev.html +34 -50
  167. package/templates/html-plugin/index-inte.html +34 -50
  168. package/templates/html-plugin/index-inte2.html +34 -50
  169. package/templates/html-plugin/index-inte3.html +34 -50
  170. package/templates/html-plugin/index-inte4.html +34 -50
  171. package/templates/html-plugin/index-me.html +34 -50
  172. package/templates/html-plugin/index-prod.html +34 -50
  173. package/templates/html-plugin/index-rc.html +33 -50
  174. package/templates/html-plugin/index-uat.html +34 -50
  175. package/templates/main.html +2 -2
  176. package/templates/module-404.html +4 -2
  177. package/templates/module.html +51 -66
  178. package/cjs/index.js +0 -4
  179. package/cjs/loader-icon.js +0 -2
  180. package/index.d.ts +0 -713
@@ -0,0 +1,66 @@
1
+ import { type ModuleFederationOptions } from './types-federation.js';
2
+ import { type MultiHtmlCDNEntryItem } from './types-multi-html.js';
3
+ /**
4
+ * The configuration options for each entry item.
5
+ */
6
+ export interface EvolveEntryItemOption extends MultiHtmlCDNEntryItem {
7
+ /**
8
+ * The value indicates if we need to Px convert to rem.
9
+ * @default entryItemOption?.allowPx2rem ?? pluginLoaderOptions?.pixelOptions?.enabled
10
+ */
11
+ allowPx2rem?: boolean;
12
+ /**
13
+ * 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`.
14
+ * Note It will merged with globall externals configuration and apply for current entry compiler
15
+ */
16
+ externals?: Record<string, string>;
17
+ /**
18
+ * If all we use `contenthash` bundle name.
19
+ * @default true
20
+ */
21
+ enableBundleHashName?: boolean;
22
+ /**
23
+ * Allow customized module `link` on `/pages`
24
+ * @default undefined
25
+ */
26
+ servePageMainLinkFn?: (link: string, options: {
27
+ entryName: string;
28
+ hostUri: string;
29
+ virtualPath: string;
30
+ }) => string;
31
+ /**
32
+ * For `serve`
33
+ * Customized module template to proxy the modules template.
34
+ * If providered, it must be an absolute path. path.join(__dirname, `templates/module.html`)
35
+ * Normally it will find file `${projectCwd}/templates/module.html` automatically
36
+ */
37
+ serveModuleTemplate?: string;
38
+ /**
39
+ * For `serve`
40
+ * Attach fixed global data for specificed entry.
41
+ * Will merged into `window.GLOBAL = {...globalData}`
42
+ * @default {}
43
+ */
44
+ serveGlobalData?: Record<string, unknown>;
45
+ /**
46
+ * Multiple separate builds should form a single application.
47
+ * This is often known as Micro-Frontends, but is not limited to that.
48
+ */
49
+ moduleFederation?: ModuleFederationOptions;
50
+ /**
51
+ * The value indicates if we need to build relative asset public path?
52
+ * @default false
53
+ */
54
+ useRelativeAssetPath?: boolean;
55
+ }
56
+ export type EvolveEntryMapContent = {
57
+ entry: [string, ...string[]];
58
+ options?: EvolveEntryItemOption;
59
+ };
60
+ export interface EvolveEntryMap {
61
+ /**
62
+ * <entryChunkName>: {}
63
+ */
64
+ [entryName: string]: EvolveEntryMapContent;
65
+ }
66
+ export type EntryMapItem = [string, EvolveEntryMapContent];
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,120 @@
1
+ import { type LibraryOptions } from 'webpack';
2
+ /**
3
+ * Advanced configuration for modules that should be shared in the share scope.
4
+ */
5
+ interface SharedConfig {
6
+ /**
7
+ * 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.
8
+ */
9
+ eager?: boolean;
10
+ /**
11
+ * 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.
12
+ */
13
+ import?: string | false;
14
+ /**
15
+ * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
16
+ */
17
+ packageName?: string;
18
+ /**
19
+ * Version requirement from module in share scope.
20
+ */
21
+ requiredVersion?: string | false;
22
+ /**
23
+ * Module is looked up under this key from the share scope.
24
+ */
25
+ shareKey?: string;
26
+ /**
27
+ * Share scope name.
28
+ */
29
+ shareScope?: string;
30
+ /**
31
+ * Allow only a single version of the shared module in share scope (disabled by default).
32
+ */
33
+ singleton?: boolean;
34
+ /**
35
+ * 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).
36
+ */
37
+ strictVersion?: boolean;
38
+ /**
39
+ * Version of the provided module. Will replace lower matching versions, but not higher.
40
+ */
41
+ version?: string | false;
42
+ }
43
+ interface SharedObject {
44
+ [index: string]: string | SharedConfig;
45
+ }
46
+ /**
47
+ * Advanced configuration for modules that should be exposed by this container.
48
+ */
49
+ export interface ExposesConfig {
50
+ /**
51
+ * Request to a module that should be exposed by this container.
52
+ * @example `import: './src/home/widget.tsx'`
53
+ */
54
+ import: string | string[];
55
+ /**
56
+ * Custom chunk name for the exposed module.
57
+ * Do not include `normalizedEntryName` e.g.(`flatjs/evolve/home`)
58
+ * @example `exposed-micro-module-home-widget` => `flatjs/evolve/home/exposed-micro-module-home-widget`
59
+ */
60
+ name: string;
61
+ }
62
+ /**
63
+ * Modules that should be exposed by this container. Property names are used as public paths.
64
+ */
65
+ export interface ExposesObject {
66
+ /**
67
+ * @example `'./Widget': { name, import }`
68
+ */
69
+ [index: string]: ExposesConfig;
70
+ }
71
+ export interface ModuleFederationRemote {
72
+ /**
73
+ * Normally it can be the entryPath like `${projectVirtualPath}/home`
74
+ * it will formatted into `evolve_demo_home`
75
+ * Note: We need to config `declare module 'evolve_demo_home/Widget` in `global.d.ts`;
76
+ * @example `home`
77
+ */
78
+ name: string;
79
+ /**
80
+ * The remote app resouce endpoint base path with prefix of `projectVirtualPath`
81
+ * Normally This is only required when an external project module as remote widget.
82
+ */
83
+ endpoint?: (entryName: string, normalizedEntryName: string) => string;
84
+ }
85
+ /**
86
+ * Multiple separate builds should form a single application.
87
+ * This is often known as Micro-Frontends, but is not limited to that.
88
+ */
89
+ export type ModuleFederationOptions = {
90
+ /**
91
+ * 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.
92
+ * {`${projectVirtualPath}/home`,`${projectVirtualPath}/mine`}
93
+ */
94
+ remotes?: Array<ModuleFederationRemote>;
95
+ /**
96
+ * Options for library.
97
+ */
98
+ library?: LibraryOptions;
99
+ /**
100
+ * The external type of the remote containers.
101
+ */
102
+ remoteType?: 'import' | 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'script' | 'node-commonjs';
103
+ /**
104
+ * 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.
105
+ */
106
+ exposes?: ExposesObject[] | ExposesObject;
107
+ /**
108
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
109
+ */
110
+ runtime?: string | false;
111
+ /**
112
+ * Share scope name used for all shared modules (defaults to 'default').
113
+ */
114
+ shareScope?: string;
115
+ /**
116
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
117
+ */
118
+ shared?: (string | SharedObject)[] | SharedObject;
119
+ };
120
+ export {};
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,61 @@
1
+ import { type TransformOptions } from '@babel/core';
2
+ import { type PostcssPluginPixelOptions } from '@flatjs/forge-postcss-plugin-pixel';
3
+ import { type Options } from 'cssnano';
4
+ import { type ModularImportOption } from './types-modular-import.js';
5
+ export type BabelInputOptions = Pick<TransformOptions, 'presets' | 'plugins'>;
6
+ /**
7
+ * Builtin babel options, provider default `builin` presets.
8
+ * can be override by customized `presets` & `plugins`
9
+ */
10
+ export type BuiltinBabelOptions = BabelInputOptions & {
11
+ /**
12
+ * extra babel `plugins` or `presets`
13
+ * @default `react`
14
+ */
15
+ usePreset?: 'react' | 'vue';
16
+ };
17
+ /**
18
+ * The configurations for `builtin` rule set options
19
+ */
20
+ export interface RuleSetLoaderOptions {
21
+ /**
22
+ * Now webpack will automatically choose between resource and inline by following
23
+ * a default condition: a file with size less than 8kb will be treated as a inline module type and resource module type otherwise.
24
+ * @default `4 * 1024` (4KB)
25
+ */
26
+ assetDataUrlMaxSize?: number;
27
+ /**
28
+ * The config for `Less`
29
+ */
30
+ lessOptions?: Record<string, unknown>;
31
+ /**
32
+ * Modular import plugin for babel, compatible with antd, antd-mobile, lodash, material-ui, and so on.
33
+ * https://github.com/ant-design/babel-plugin-import
34
+ * @default []
35
+ */
36
+ modularImports?: ModularImportOption[];
37
+ /**
38
+ * The value indicates whether runs typescript type checker and linter on separate process.
39
+ * @default true
40
+ */
41
+ runTsChecker?: boolean;
42
+ /**
43
+ * The overrided configurations of `cssnano-preset-default`
44
+ * sometimes we need to disabled some rules for `default cssnano preset`
45
+ * @example
46
+ * diable `postcss-minify-font-values` rule to avoid transitions from `font-weight:bold` to `font-weight:700`
47
+ * ```json
48
+ * cssnanoOptions: { minifyFontValues: false }
49
+ * ```
50
+ */
51
+ cssnanoOptions?: Options;
52
+ /**
53
+ * The babel options for `babel-loader`
54
+ */
55
+ babelOptions?: BuiltinBabelOptions;
56
+ /**
57
+ * The config options fro `@flatjs/forge-postcss-plugin-plugin`
58
+ * If provider it will use default options of `forgePostcssPluginPixel`
59
+ */
60
+ pixelOptions?: false | Partial<PostcssPluginPixelOptions>;
61
+ }
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Buildin plugin `babel-plugin-import` configurations
3
+ */
4
+ export type ModularImportOption = {
5
+ /**
6
+ * @example `antd`, `lodash`, `material-ui`, `@flatjs`, `@dimjs`, `@fabric`, `@wine`
7
+ */
8
+ libraryName: string;
9
+ /**
10
+ * Set this option to false if your module does not have a default export.
11
+ * @default false
12
+ */
13
+ transformToDefaultImport?: boolean;
14
+ /**
15
+ * @default: `esm`
16
+ */
17
+ libraryDirectory?: string;
18
+ /**
19
+ * The value will append to `${libraryDirectory}/${transformedMethodName}/${fileName}`
20
+ * e.g. `@scope/app/esm/{moduleName}/index`
21
+ * @default ""
22
+ */
23
+ fileName?: string;
24
+ /**
25
+ * We can use customName to customize import file path.
26
+ * @example `esm/modal`
27
+ */
28
+ customName?: (transformedMethodName: string, file: any) => string;
29
+ /**
30
+ * @default: true
31
+ */
32
+ camel2DashComponentName?: boolean;
33
+ /**
34
+ * @default false
35
+ * @example (name) => `${name}/style/2x` | `boolean` }
36
+ */
37
+ style?: true | 'css' | ((name: string, file: Record<string, unknown>) => string | boolean);
38
+ };
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,74 @@
1
+ export declare type EvolveMultiCdnEnvType = 'me' | 'dev' | 'uat' | 'inte' | 'inte2' | 'inte3' | 'inte4' | 'rc' | 'prod' | 'ntv';
2
+ export type EvolveMultiCDNConfig = {
3
+ [key in EvolveMultiCdnEnvType]?: string[];
4
+ };
5
+ /**
6
+ * Allow us customized to resolve current runtime environment.
7
+ */
8
+ export type EvolveMultiCDNEnvResolver = (url: string) => EvolveMultiCdnEnvType | undefined;
9
+ /**
10
+ * The html plugin configuration for each entry item
11
+ */
12
+ export declare type MultiHtmlCDNEntryItem = {
13
+ /**
14
+ * The title to use for the generated HTML document
15
+ * @default ''
16
+ */
17
+ title?: string;
18
+ /**
19
+ * The favicon url to use for the generated HTML document
20
+ */
21
+ favicon?: string;
22
+ /**
23
+ * webpack relative or absolute path to the template.
24
+ * It must be an absolute path. `path.join(__dirname, `templates/index-{0}.html`)`
25
+ * @default join(evolveRoot, `/templates/html-plugin/index-{0}.html`)
26
+ */
27
+ templatePath?: string;
28
+ /**
29
+ * Indicates if we need to minify html.
30
+ * @default true
31
+ */
32
+ htmlMinify?: boolean;
33
+ /**
34
+ * Support inject viewport scripts in each modules
35
+ * It only available while `allowPx2rem` = true
36
+ * @default ''
37
+ */
38
+ viewport?: string;
39
+ /**
40
+ * Allow us customized inline scripts into compiled html template.
41
+ * @default []
42
+ */
43
+ inlineScripts?: string[];
44
+ /**
45
+ * The customized html tags should be inject to `<header />`
46
+ */
47
+ headBeforeHtmlTags?: string[];
48
+ /**
49
+ * The ordered styles will be injected start of html head.
50
+ * @default []
51
+ */
52
+ headBeforeStyles?: string[];
53
+ /**
54
+ * The ordered scripts will be injected before html head.
55
+ * @default [
56
+ * `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`,
57
+ * `https://unpkg.com/react@17.0.2/umd/react.production.min.js`,
58
+ * `https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js`,
59
+ * `https://unpkg.com/react-router-dom@5.2.0/umd/react-router-dom.min.js`
60
+ * ]
61
+ */
62
+ headBeforeScripts?: string[];
63
+ /**
64
+ * The ordered scripts will be injected end of html body.
65
+ * @default []
66
+ */
67
+ bodyAfterScripts?: string[];
68
+ /**
69
+ * Give `env` list to exclude from `multi-cdn` plugin.
70
+ * Normally for `me`, `dev`,`uat`, `ntv` env we should use relative assets path instead cdn.
71
+ * @default ['dev', 'ntv']
72
+ */
73
+ excludeCdnEnvs?: EvolveMultiCdnEnvType[];
74
+ };
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,98 @@
1
+ import { type VerifyPackagePattern } from '@armit/package';
2
+ import { type FlatEvolveDevServerOptions } from './types-dev-server.js';
3
+ import { type EvolveEntryMap } from './types-entry-map.js';
4
+ import { type RuleSetLoaderOptions } from './types-loader-options.js';
5
+ import { type EvolveMultiCDNEnvResolver, type EvolveMultiCDNConfig } from './types-multi-html.js';
6
+ import { type FlatEvolveWebpackOptions } from './types-webpack.js';
7
+ /**
8
+ * Detect locally installed dependencies that have correctly installed from `package.json` declared version `dependencies`
9
+ */
10
+ export type PackageInstallChecker = {
11
+ /**
12
+ * @default false
13
+ */
14
+ enabled?: boolean;
15
+ /**
16
+ * Stop program if we have detect unexpected error.
17
+ * @default false
18
+ */
19
+ throwError?: boolean;
20
+ /**
21
+ * Flat indicates if we need to print all install module graph
22
+ * @default false
23
+ */
24
+ showAllInstalledGraph?: boolean;
25
+ /**
26
+ * Package module name, or module expression. [`^babel-`,`@dimjs/*`]
27
+ * @defalt ['@dimjs/*']
28
+ */
29
+ detectModules?: string[];
30
+ };
31
+ export interface FlatEvolveOptions {
32
+ /**
33
+ * The project workspace directory.
34
+ */
35
+ projectCwd: string;
36
+ /**
37
+ * The virtual path for current `project`
38
+ * e.g. `evolve/test`
39
+ */
40
+ projectVirtualPath: string;
41
+ /**
42
+ * The configurations of `webpack`
43
+ */
44
+ webpack?: FlatEvolveWebpackOptions;
45
+ /**
46
+ * The config options of all rule set loaders.
47
+ */
48
+ loaderOptions: RuleSetLoaderOptions;
49
+ /**
50
+ * The configurations of `dev-server`.
51
+ */
52
+ devServer?: FlatEvolveDevServerOptions;
53
+ /**
54
+ * The plugin for `@flatjs/evolve-multi-html-cdn-plugin`
55
+ */
56
+ multiHtmlCdn: EvolveMultiCDNConfig;
57
+ /**
58
+ * Allow us customized to resolve current runtime environment.
59
+ * ignore resolver if return undefined, otherwise use it to match environment.
60
+ * NOTE: Don't using arrow function, because we will inject `envResolver` string to html.
61
+ * @example
62
+ * ```ts
63
+ * //
64
+ * function envResolver(url) {
65
+ * const env = /.*\.(qa|t)\.*\/.exec('//fex.qa.tcshuke.com/')[1];
66
+ * switch(env) {
67
+ * case 't':
68
+ * return 'rc'
69
+ * case 'qa':
70
+ * return 'inte'
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ multiHtmlCdnEnvResolver?: EvolveMultiCDNEnvResolver;
76
+ /**
77
+ * The regexp patterns to filter dependencies(will be verified) from package.json
78
+ * @default {}
79
+ */
80
+ needVerifyPackages?: false | VerifyPackagePattern;
81
+ /**
82
+ * Detect locally installed dependencies that have correctly installed from `package.json`
83
+ */
84
+ packageInstallChecker?: false | PackageInstallChecker;
85
+ /**
86
+ * All webpack entries configuration
87
+ */
88
+ entryMap: EvolveEntryMap;
89
+ /**
90
+ * Visualize size of webpack output files with an interactive zoomable treemap.
91
+ */
92
+ analyzer?: Record<string, unknown>;
93
+ /**
94
+ * For `production` mode, the value indicates if we interrupt compilation process while received "warnings" while evolve `build`
95
+ * @default false
96
+ */
97
+ rejectWarnings?: boolean;
98
+ }
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,70 @@
1
+ import { type RuleSetRule, type Configuration } from 'webpack';
2
+ import { type WebpackPlugin } from '../create-webpack/types.js';
3
+ import { type TerserMinimizerOptions } from '../minimizer/types.js';
4
+ /**
5
+ * The webpack entry configuration.
6
+ */
7
+ export interface WebpackEntryObject {
8
+ [index: string]: string | [string, ...string[]];
9
+ }
10
+ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'performance' | 'stats' | 'infrastructureLogging' | 'resolve'> {
11
+ /**
12
+ * @default
13
+ * ```json
14
+ * {
15
+ * vue: 'Vue',
16
+ * react: 'React',
17
+ * 'react-dom': 'ReactDOM',
18
+ * }
19
+ * ```
20
+ */
21
+ externals?: Record<string, string>;
22
+ /**
23
+ * output.publicPath defaults to 'auto' with web and web-worker targets
24
+ * @default 'auto'
25
+ */
26
+ publicPath?: string;
27
+ /**
28
+ *
29
+ * Note if we build `node` using webpack, in order to ignore built-in modules like path, fs, etc.
30
+ * maybe we need to use `webpack-node-externals'` to configuration `externals`
31
+ * Now webpack-dev-server have not follow webpack@5 `browserslist` changes
32
+ * Environment to build for. An array of environments to build for all of them when possible.
33
+ * @default ['web', 'es5'],
34
+ */
35
+ target?: string | false | string[];
36
+ /**
37
+ * Minimizer(s) to use for minimizing the output. for `serve` mode, `minimize` always `false`.
38
+ * @default `terser` minimizer has been enabled fro `production`
39
+ */
40
+ minimizer?: false | {
41
+ terserOptions?: TerserMinimizerOptions;
42
+ /**
43
+ * @default true
44
+ */
45
+ imageMin?: boolean;
46
+ };
47
+ /**
48
+ * A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
49
+ * https://webpack.js.org/configuration/devtool/
50
+ * Only works on production mode , `source-map` Recommended choice for production builds with high quality SourceMaps.
51
+ * Note: the `sourceMap` only focus on javascript bundle,invalid for other `loaders` e.g. less-loader, css-loader.
52
+ * @default `false`
53
+ */
54
+ sourceMap?: string | false;
55
+ /**
56
+ * The rule sets loaders config options
57
+ */
58
+ ruleSets?: Array<Omit<RuleSetRule, 'test'> & {
59
+ test?: string | RegExp | ((value: string) => boolean);
60
+ }>;
61
+ /**
62
+ * The plugins config options
63
+ */
64
+ plugins?: WebpackPlugin[];
65
+ /**
66
+ * `contentehash` bundle file name.
67
+ * @default true
68
+ */
69
+ enableBundleHashName?: boolean;
70
+ }
@@ -0,0 +1 @@
1
+ export{};
package/index.js CHANGED
@@ -1,4 +1 @@
1
- 'use strict';
2
-
3
- module.exports = require('./cjs/index.js');
4
- module.exports.default = module.exports;
1
+ export * from './dist/index.js';