@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.
- package/CHANGELOG.md +781 -0
- package/LICENSE +21 -0
- package/README.md +10 -46
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +1 -0
- package/dist/create-webpack/create-externals.d.ts +4 -0
- package/dist/create-webpack/create-externals.js +1 -0
- package/dist/create-webpack/create-optimization.d.ts +3 -0
- package/dist/create-webpack/create-optimization.js +1 -0
- package/dist/create-webpack/create-output.d.ts +3 -0
- package/dist/create-webpack/create-output.js +1 -0
- package/dist/create-webpack/create-performance.d.ts +2 -0
- package/dist/create-webpack/create-performance.js +1 -0
- package/dist/create-webpack/create-plugins.d.ts +4 -0
- package/dist/create-webpack/create-plugins.js +1 -0
- package/dist/create-webpack/create-resolve.d.ts +2 -0
- package/dist/create-webpack/create-resolve.js +1 -0
- package/dist/create-webpack/create-rule-sets.d.ts +4 -0
- package/dist/create-webpack/create-rule-sets.js +1 -0
- package/dist/create-webpack/load-webpack-config.d.ts +10 -0
- package/dist/create-webpack/load-webpack-config.js +1 -0
- package/dist/create-webpack/rule-sets/constants.d.ts +3 -0
- package/dist/create-webpack/rule-sets/constants.js +1 -0
- package/dist/create-webpack/rule-sets/rule-assets.d.ts +10 -0
- package/dist/create-webpack/rule-sets/rule-assets.js +1 -0
- package/dist/create-webpack/rule-sets/rule-css.d.ts +11 -0
- package/dist/create-webpack/rule-sets/rule-css.js +1 -0
- package/dist/create-webpack/rule-sets/rule-less.d.ts +26 -0
- package/dist/create-webpack/rule-sets/rule-less.js +1 -0
- package/dist/create-webpack/rule-sets/rule-scripts.d.ts +3 -0
- package/dist/create-webpack/rule-sets/rule-scripts.js +1 -0
- package/dist/create-webpack/rule-sets/rule-svg-icon.d.ts +6 -0
- package/dist/create-webpack/rule-sets/rule-svg-icon.js +1 -0
- package/dist/create-webpack/rule-sets/rule-utils.d.ts +7 -0
- package/dist/create-webpack/rule-sets/rule-utils.js +1 -0
- package/dist/create-webpack/types.d.ts +2 -0
- package/dist/create-webpack/types.js +1 -0
- package/dist/default-options.d.ts +2 -0
- package/dist/default-options.js +1 -0
- package/dist/define-config/define-config.d.ts +24 -0
- package/dist/define-config/define-config.js +1 -0
- package/dist/define-config/index.d.ts +1 -0
- package/dist/define-config/index.js +1 -0
- package/dist/dev-server/add-compiler-to-dev-server.d.ts +10 -0
- package/dist/dev-server/add-compiler-to-dev-server.js +1 -0
- package/dist/dev-server/create-app-page-route.d.ts +7 -0
- package/dist/dev-server/create-app-page-route.js +1 -0
- package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +3 -0
- package/dist/dev-server/create-dev-server-compiler-tasks.js +1 -0
- package/dist/dev-server/create-dev-server-entries.d.ts +4 -0
- package/dist/dev-server/create-dev-server-entries.js +1 -0
- package/dist/dev-server/create-dev-server.d.ts +6 -0
- package/dist/dev-server/create-dev-server.js +1 -0
- package/dist/dev-server/index.d.ts +6 -0
- package/dist/dev-server/index.js +1 -0
- package/dist/dev-server/middlewares/create-page-middleware.d.ts +37 -0
- package/dist/dev-server/middlewares/create-page-middleware.js +1 -0
- package/dist/dev-server/middlewares/create-public-assets-middleware.d.ts +2 -0
- package/dist/dev-server/middlewares/create-public-assets-middleware.js +1 -0
- package/dist/dev-server/middlewares/index.d.ts +2 -0
- package/dist/dev-server/middlewares/index.js +1 -0
- package/dist/errors/evolve-build-error.d.ts +4 -0
- package/dist/errors/evolve-build-error.js +1 -0
- package/dist/helpers/allow-px2rem-for-module.d.ts +3 -0
- package/dist/helpers/allow-px2rem-for-module.js +1 -0
- package/dist/helpers/assert-only-single-entry-item.d.ts +7 -0
- package/dist/helpers/assert-only-single-entry-item.js +1 -0
- package/dist/helpers/chunk-entry-map.d.ts +7 -0
- package/dist/helpers/chunk-entry-map.js +1 -0
- package/dist/helpers/enable-bundle-hashname-for-module.d.ts +3 -0
- package/dist/helpers/enable-bundle-hashname-for-module.js +1 -0
- package/dist/helpers/filter-actived-entries.d.ts +16 -0
- package/dist/helpers/filter-actived-entries.js +1 -0
- package/dist/helpers/get-bundle-file-name.d.ts +14 -0
- package/dist/helpers/get-bundle-file-name.js +1 -0
- package/dist/helpers/get-git-root.d.ts +1 -0
- package/dist/helpers/get-git-root.js +1 -0
- package/dist/helpers/get-html-plugin-config.d.ts +20 -0
- package/dist/helpers/get-html-plugin-config.js +1 -0
- package/dist/helpers/get-max-process-tasks.d.ts +1 -0
- package/dist/helpers/get-max-process-tasks.js +1 -0
- package/dist/helpers/get-pacakge-dir.d.ts +1 -0
- package/dist/helpers/get-pacakge-dir.js +1 -0
- package/dist/helpers/index.d.ts +17 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/json-serializer.d.ts +7 -0
- package/dist/helpers/json-serializer.js +1 -0
- package/dist/helpers/merge-babel-options.d.ts +4 -0
- package/dist/helpers/merge-babel-options.js +1 -0
- package/dist/helpers/normalize-entry-map.d.ts +15 -0
- package/dist/helpers/normalize-entry-map.js +1 -0
- package/dist/helpers/normalize-resolve-alias.d.ts +1 -0
- package/dist/helpers/normalize-resolve-alias.js +1 -0
- package/dist/helpers/open-page.d.ts +7 -0
- package/dist/helpers/open-page.js +1 -0
- package/dist/helpers/print-log.d.ts +8 -0
- package/dist/helpers/print-log.js +1 -0
- package/dist/helpers/refresh-evolve-mock-options.d.ts +3 -0
- package/dist/helpers/refresh-evolve-mock-options.js +1 -0
- package/dist/helpers/resolve-entry-map-input-files.d.ts +8 -0
- package/dist/helpers/resolve-entry-map-input-files.js +1 -0
- package/dist/helpers/script-injects.d.ts +11 -0
- package/dist/helpers/script-injects.js +1 -0
- package/dist/helpers/should-enable-react-fast-refresh.d.ts +3 -0
- package/dist/helpers/should-enable-react-fast-refresh.js +1 -0
- package/dist/helpers/split-to-multi-compiler.d.ts +8 -0
- package/dist/helpers/split-to-multi-compiler.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/load-config/index.d.ts +1 -0
- package/dist/load-config/index.js +1 -0
- package/dist/load-config/load-evolve-config.d.ts +11 -0
- package/dist/load-config/load-evolve-config.js +1 -0
- package/dist/loaders/loader-icon.cjs +33 -0
- package/dist/loaders/loader-icon.d.cts +1 -0
- package/dist/main/env-verify.d.ts +2 -0
- package/dist/main/env-verify.js +1 -0
- package/dist/main/get-worker-path.d.ts +1 -0
- package/dist/main/get-worker-path.js +1 -0
- package/dist/main/index.d.ts +4 -0
- package/dist/main/index.js +1 -0
- package/dist/main/prepare-build.d.ts +9 -0
- package/dist/main/prepare-build.js +1 -0
- package/dist/main/prepare-serve.d.ts +9 -0
- package/dist/main/prepare-serve.js +1 -0
- package/dist/main/prepare-static.d.ts +7 -0
- package/dist/main/prepare-static.js +1 -0
- package/dist/main/start-build-dynamic.d.ts +20 -0
- package/dist/main/start-build-dynamic.js +1 -0
- package/dist/main/start-build-worker.d.ts +12 -0
- package/dist/main/start-build-worker.js +1 -0
- package/dist/main/start-build.d.ts +5 -0
- package/dist/main/start-build.js +1 -0
- package/dist/main/start-one-entry-build.d.ts +13 -0
- package/dist/main/start-one-entry-build.js +1 -0
- package/dist/main/start-serve.d.ts +11 -0
- package/dist/main/start-serve.js +1 -0
- package/dist/main/start-static.d.ts +10 -0
- package/dist/main/start-static.js +1 -0
- package/dist/minimizer/create-minimizers.d.ts +3 -0
- package/dist/minimizer/create-minimizers.js +1 -0
- package/dist/minimizer/default-options.d.ts +2 -0
- package/dist/minimizer/default-options.js +1 -0
- package/dist/minimizer/image-minimizer.d.ts +16 -0
- package/dist/minimizer/image-minimizer.js +1 -0
- package/dist/minimizer/index.d.ts +1 -0
- package/dist/minimizer/index.js +1 -0
- package/dist/minimizer/terser-minimizer.d.ts +6 -0
- package/dist/minimizer/terser-minimizer.js +3 -0
- package/dist/minimizer/types.d.ts +2 -0
- package/dist/minimizer/types.js +1 -0
- package/dist/plugins/circular-dependency/circular-dependency-plugin.d.ts +54 -0
- package/dist/plugins/circular-dependency/circular-dependency-plugin.js +1 -0
- package/dist/plugins/circular-dependency/index.d.ts +7 -0
- package/dist/plugins/circular-dependency/index.js +1 -0
- package/dist/plugins/clean-webpack/clean-webpack-plugin.d.ts +67 -0
- package/dist/plugins/clean-webpack/clean-webpack-plugin.js +1 -0
- package/dist/plugins/clean-webpack/index.d.ts +9 -0
- package/dist/plugins/clean-webpack/index.js +1 -0
- package/dist/plugins/define-variable/define-variable-plugin.d.ts +14 -0
- package/dist/plugins/define-variable/define-variable-plugin.js +1 -0
- package/dist/plugins/define-variable/index.d.ts +1 -0
- package/dist/plugins/define-variable/index.js +1 -0
- package/dist/plugins/html-inject-scripts/plugin-html-inject-script.d.ts +8 -0
- package/dist/plugins/html-inject-scripts/plugin-html-inject-script.js +1 -0
- package/dist/plugins/module-federation/external-template-remotes.d.ts +4 -0
- package/dist/plugins/module-federation/external-template-remotes.js +1 -0
- package/dist/plugins/module-federation/index.d.ts +1 -0
- package/dist/plugins/module-federation/index.js +1 -0
- package/dist/plugins/module-federation/module-federation.d.ts +4 -0
- package/dist/plugins/module-federation/module-federation.js +1 -0
- package/dist/plugins/multi-html/index.d.ts +4 -0
- package/dist/plugins/multi-html/index.js +1 -0
- package/dist/plugins/multi-html/multi-html-cdn-plugin.d.ts +17 -0
- package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -0
- package/dist/plugins/multi-html/multi-html-plugin.d.ts +11 -0
- package/dist/plugins/multi-html/multi-html-plugin.js +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +1 -0
- package/dist/types/types-ci.d.ts +23 -0
- package/dist/types/types-ci.js +1 -0
- package/dist/types/types-dev-server.d.ts +65 -0
- package/dist/types/types-dev-server.js +1 -0
- package/dist/types/types-entry-map.d.ts +71 -0
- package/dist/types/types-entry-map.js +1 -0
- package/dist/types/types-federation.d.ts +120 -0
- package/dist/types/types-federation.js +1 -0
- package/dist/types/types-loader-options.d.ts +76 -0
- package/dist/types/types-loader-options.js +1 -0
- package/dist/types/types-modular-import.d.ts +38 -0
- package/dist/types/types-modular-import.js +1 -0
- package/dist/types/types-multi-html.d.ts +75 -0
- package/dist/types/types-multi-html.js +1 -0
- package/dist/types/types-options.d.ts +117 -0
- package/dist/types/types-options.js +1 -0
- package/dist/types/types-plugin-options.d.ts +7 -0
- package/dist/types/types-plugin-options.js +1 -0
- package/dist/types/types-webpack.d.ts +96 -0
- package/dist/types/types-webpack.js +1 -0
- package/index.js +1 -4
- package/package.json +118 -61
- package/templates/html-plugin/index-dev.html +23 -46
- package/templates/html-plugin/index-inte.html +23 -46
- package/templates/html-plugin/index-inte2.html +23 -46
- package/templates/html-plugin/index-inte3.html +23 -46
- package/templates/html-plugin/index-inte4.html +23 -46
- package/templates/html-plugin/index-me.html +23 -46
- package/templates/html-plugin/index-prod.html +23 -46
- package/templates/html-plugin/index-rc.html +22 -46
- package/templates/html-plugin/index-uat.html +23 -46
- package/templates/main.html +2 -2
- package/templates/module-404.html +4 -2
- package/templates/module.html +31 -61
- package/cjs/index.js +0 -4
- package/cjs/loader-icon.js +0 -2
- package/index.d.ts +0 -721
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020-2021 Yingchun Tian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
@@ -1,54 +1,18 @@
|
|
1
1
|
# @flatjs/evolve
|
2
2
|
|
3
|
-
|
3
|
+
## Note: because below configuration of `tsconfig.json `
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
```sh
|
8
|
-
npm i @flatjs/evolve
|
9
|
-
```
|
10
|
-
|
11
|
-
Need production assets optimization
|
12
|
-
|
13
|
-
```sh
|
14
|
-
brew install libpng
|
15
|
-
brew install gifsicle
|
16
|
-
npm install imagemin-gifsicle -D
|
17
|
-
npm install imagemin-jpegtran -D
|
18
|
-
npm install imagemin-pngquant -D
|
19
|
-
npm install imagemin-svgo -D
|
5
|
+
```json
|
6
|
+
{ "baseUrl": "./src" }
|
20
7
|
```
|
21
8
|
|
22
|
-
|
9
|
+
We should not create folder name like `webpack` in `src/webpack`;
|
23
10
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- Support multi html template file output `index.html`, `index-dev.html`, `index-rc.html`, `index-ntv.html`
|
28
|
-
- Support `express` to proxy all `serve` `static` page `modules`.
|
29
|
-
- Support us filter dynamic import using `import()`
|
30
|
-
- Allow us attach customized `middleware` to handle page render.
|
31
|
-
- Allow individual define some configuration for each `entry item`.
|
32
|
-
- Builtin `parallel` build for production `build`
|
33
|
-
- Allow us specified extra `babel` presets or plugins to handle your webapp.
|
34
|
-
- Builtin loaders `icon` `babel` `css` `less` `image` `svg` `font`
|
35
|
-
- Split `mock` and `evolve` configuration into `flatjs.mock.js`, `flatjs.evolve.js`.
|
11
|
+
1. while we use `import { moduleX } from webpack`; it will resolve `moduleX` from `src/webpack` instead import from `node_modules`
|
12
|
+
2. while use `vitest` it may broken cause of wrong `webpack` imported.
|
13
|
+
3. change `src/webpack` to `src/create-webpack` is ok.
|
36
14
|
|
37
|
-
|
15
|
+
### Notes: cause of `esm`
|
38
16
|
|
39
|
-
|
40
|
-
|
41
|
-
1. update `flatjs.dts.js` add `followSymlinks: false,`
|
42
|
-
2. remove `paths:{}` from `compilerOptions` of tsconfig.json
|
43
|
-
3. SEE: ([monorepo will be inlined?](https://github.com/timocov/dts-bundle-generator/issues/91))
|
44
|
-
4. Cause of `webpack@5` there are some typings issue for `plugins`, we remove these typings from `devDependencies` e.g. `mini-css-extract`, `webpack-dev-server`, `clean-webpack-plugin`
|
45
|
-
5. 注意一旦使用 antd 作为 externals, 此处要去掉 `antd` modularImports `flatjs.evolve.js`
|
46
|
-
|
47
|
-
```json
|
48
|
-
{
|
49
|
-
libraryName: 'antd',
|
50
|
-
libraryDirectory: 'es',
|
51
|
-
style: true,
|
52
|
-
transformToDefaultImport: true,
|
53
|
-
},
|
54
|
-
```
|
17
|
+
1. `import { webpack } from 'webpack'` should be change to `import webpack from 'webpack'`
|
18
|
+
2. `import { merge } from 'lodash'` should be change to `import _ from 'lodash'`
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export declare const moduleName = "@flatjs/evolve";
|
2
|
+
/**
|
3
|
+
* the configuration file of `flat-evolve`
|
4
|
+
* flatjs-evolve.config.ts,.mjs,.mts
|
5
|
+
*/
|
6
|
+
export declare const configFileName = "flatjs-evolve";
|
7
|
+
/**
|
8
|
+
* `viewport.js`, Used to support the mobile `rem` adaptive solution.
|
9
|
+
* The viewport code is dynamically inserted to `html` file via `html-plugin`
|
10
|
+
*/
|
11
|
+
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);";
|
12
|
+
/**
|
13
|
+
* https://polyfill.io
|
14
|
+
*/
|
15
|
+
export declare const polyfill: string[];
|
@@ -0,0 +1 @@
|
|
1
|
+
export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export 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);';export const polyfill=["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"];
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { type Configuration } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
|
4
|
+
export declare const createExternals: (externals: FlatEvolveWebpackOptions['externals'], entryItem: EntryMapItem) => Configuration['externals'];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{mergeOptions}from"@flatjs/common";export const createExternals=(t={},e)=>{const o=e[1],r=o.options?.externals||{};return mergeOptions(t,r)};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{createMinimizers}from"../minimizer/index.js";export const createOptimization=(e,i)=>({nodeEnv:e?"development":"production",chunkIds:"named",moduleIds:"named",minimize:!1!==i?.minimizer&&!e,minimizer:createMinimizers(e,i),splitChunks:{name:!1,chunks:"all",minSize:25e5,cacheGroups:{default:!1,defaultVendors:!1}}});
|
@@ -0,0 +1 @@
|
|
1
|
+
import{join}from"node:path";import{ensureSlash}from"@flatjs/common";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";export const createOutput=async(e,t)=>{const{projectCwd:a,webpack:n}=t;let o="auto";n?.publicPath&&"auto"!==n.publicPath&&(o=ensureSlash(n.publicPath,!0));const u="function"==typeof n?.outputDir?await n.outputDir():n?.outputDir||"public";return{devtoolModuleFilenameTemplate:({namespace:e,resourcePath:t})=>`webpack:///${join(e,t)}`,environment:{},pathinfo:!1,path:join(a,u),publicPath:o,filename:`[name]/${getBundleFileName("js",e,n?.enableBundleHashName)}`,chunkFilename:"[id].[contenthash].js"}};
|
@@ -0,0 +1 @@
|
|
1
|
+
export const createPerformance=(n,e={})=>{const r={hints:!n&&"warning"};return Object.assign(r,e)};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { type EntryMapItem } from '../types/types-entry-map.js';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
|
4
|
+
export declare const createPlugins: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<FlatEvolveWebpackOptions['plugins']>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";import{enableBundleHashNameForModule}from"../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createCircularDependencyPlugin}from"../plugins/circular-dependency/index.js";import{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createBuiltinDefineVariables}from"../plugins/define-variable/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";export const createPlugins=async(e,n,a)=>{const[r,i]=n,l=enableBundleHashNameForModule(a,i?.options),t=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyPlugin(e,a),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,l)}`,chunkFilename:"[id].[contenthash].css"}),...await createBuiltinDefineVariables(e,a),...createCleanWebpackPlugin(e,n,a),...createModuleFederationPlugin(e,n,a),...createHtmlPlugins(e,n,a)],{analyzer:s,loaderOptions:o}=a,c=(n[1].entry||[]).find((e=>/.vue$/.test(e)));o.runTsChecker&&!c&&t.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:a.projectCwd,memoryLimit:8192}})),s&&t.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...s}));const u=shouldEnableReactFastRefresh(e,n,a);u&&t.push(new ReactRefreshWebpackPlugin({overlay:!1})),!u&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${r}"\``));const p=a.webpack?.plugins||[];return t.concat(p)};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{join}from"node:path";import{mergeOptions}from"@flatjs/common";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";export const createResolve=(s,o)=>{const n={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js",".jsx"]})]};return mergeOptions(n,o?.resolve||{})};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { type RuleSetRule } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
|
+
export declare const createRuleSets: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{ruleAssets}from"./rule-sets/rule-assets.js";import{ruleCss}from"./rule-sets/rule-css.js";import{ruleLess}from"./rule-sets/rule-less.js";import{ruleScripts}from"./rule-sets/rule-scripts.js";import{ruleSvgIcon}from"./rule-sets/rule-svg-icon.js";export const createRuleSets=(s,e,r)=>{const t=[ruleSvgIcon(),ruleAssets(e,r),ruleCss(s,e,r),ruleLess(s,e,r),ruleScripts(s,e,r)],l=r.webpack?.ruleSets||[];return t.concat(l)};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { type Configuration } from 'webpack';
|
2
|
+
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Try to organization the configuraiton object of `webpack`
|
6
|
+
* @param mode Enable production optimizations or development hints.
|
7
|
+
* @param entryMap The only single one `servedEntry` or `toBuildEntry`
|
8
|
+
* @param overrideOptions The manually override configuration options for flatjsEvolve
|
9
|
+
*/
|
10
|
+
export declare const loadWebpackConfig: (mode: 'production' | 'development', entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Omit<Configuration, 'entry'>>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{assertOnlySingleEntryItem}from"../helpers/assert-only-single-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createOutput}from"./create-output.js";import{createPerformance}from"./create-performance.js";import{createPlugins}from"./create-plugins.js";import{createResolve}from"./create-resolve.js";import{createRuleSets}from"./create-rule-sets.js";export const loadWebpackConfig=async(e,t,r)=>{const a="development"===e,{projectCwd:o,webpack:s,devServer:n}=r,c=n?.watchOptions,i=assertOnlySingleEntryItem(t,r),m=createRuleSets(a,i,r);return{mode:e,plugins:await createPlugins(a,i,r),watchOptions:c,output:await createOutput(a,r),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:m},devtool:a?"eval-source-map":s?.sourceMap||!1,externals:createExternals(s?.externals,i),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,s),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
|
@@ -0,0 +1 @@
|
|
1
|
+
export const ICON_PATH_REGEX=/svg-icons\//;export const IMAGE_PATH_REGEX=/\.(?:jpe?g|png|gif|svg)$/;export const FONT_PATH_REGEX=/\.(?:ttf|eot|woff|woff2)(?:\?.+)?$/;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { type RuleSetRule } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Preparing image loader for normal pictures except stored in folder `icons`
|
6
|
+
* Webpack@5 don't need `file-loader`, `raw-loader`, `url-loader` provider us `asset-modules`
|
7
|
+
* https://webpack.js.org/guides/asset-modules/
|
8
|
+
* @param entryItem The available entries, `development` it contains multiple enties, `production` only one entry in once build.
|
9
|
+
*/
|
10
|
+
export declare const ruleAssets: (entryItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{dirname,join,relative,resolve}from"node:path";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"./constants.js";import{isIconSvg}from"./rule-utils.js";const getEntryAssetFileName=(e,t,r)=>{const[s,n]=t,{projectCwd:a,projectVirtualPath:o}=r;let i=dirname(join(o,e.replace(/^src/,"")));const l=n.entry.map((e=>dirname(join(a,e)))),m=resolve(a,e),c=l.find((e=>m.startsWith(e)));return c&&(i=dirname(join(s,relative(c,m)))),`${i}/[name]-[contenthash:8][ext]`};export const ruleAssets=(e,t)=>({type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:r})=>getEntryAssetFileName(r,e,t)},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { type RuleSetRule } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Actually, style-loader is the one that is responsible for CSS HMR
|
6
|
+
* https://github.com/webpack-contrib/style-loader/blob/master/src/index.js#L31-L42
|
7
|
+
* @param serveMode
|
8
|
+
* @param entryMapItem
|
9
|
+
* @param evolveOptions `builtin` loaders
|
10
|
+
*/
|
11
|
+
export declare const ruleCss: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import cssnano from"cssnano";import MiniCssExtractPlugin from"mini-css-extract-plugin";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";const getPostcssOptions=(s,o={},e={})=>{const r=[...e.plugins||[],cssnano({preset:["default",{discardComments:{removeAll:!s},reduceInitial:!1,normalizeWhitespace:!s,...e.cssnanoOptions}]})];return!1!==o&&r.push(forgePostcssPluginPixel(o)),{plugins:r}};export const ruleCss=(s,o,e)=>{const{pixelOptions:r,cssLoaderOptions:t,postcssOptions:i}=e.loaderOptions,l={test:/\.css$/i,use:[{loader:MiniCssExtractPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...t}}]},n=allowPx2remForModule(o,e);if(Array.isArray(l.use)){const o=getPostcssOptions(s,!!n&&r,i);l.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return l};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { type RuleSetRule } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Preparing configurations for `less-loader`
|
6
|
+
* @param serveMode The value indicates if we are in `built` or `serve` mode.
|
7
|
+
* @param pluginLoaderOptions `builtin` loaders
|
8
|
+
* @example
|
9
|
+
* ```ts
|
10
|
+
* `~` makes the url an module
|
11
|
+
* webpack: {
|
12
|
+
* externals: {
|
13
|
+
* antd: 'antd',
|
14
|
+
* dayjs: 'dayjs',
|
15
|
+
* },
|
16
|
+
* resolve: {
|
17
|
+
* alias: {
|
18
|
+
* '@': resolve(projectCwd, './src'),
|
19
|
+
* },
|
20
|
+
* },
|
21
|
+
* },
|
22
|
+
* `@import '~@/theme/default.less';` at `src/theme/default.less`
|
23
|
+
*
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
export declare const ruleLess: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{requireResolve}from"@flatjs/common";import{ruleCss}from"./rule-css.js";export const ruleLess=(s,e,r)=>{const o=ruleCss(s,e,r);o.test=/\.less$/i;const t=r.loaderOptions.lessOptions;return Array.isArray(o.use)&&o.use.push({loader:requireResolve(import.meta.url,"less-loader"),options:{sourceMap:s,lessOptions:{sourceMap:s,javascriptEnabled:!0,...t}}}),o};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleScripts=(e,r,s)=>{const{babelOptions:o={},modularImports:t=[]}=s.loaderOptions,l=mergeBabelOption(t,o);shouldEnableReactFastRefresh(e,r,s)&&(l.plugins?l.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):l.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]);return{test:/\.(tsx|ts|js|jsx)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:l}]}};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{getDirname}from"@armit/file-utility";import{isIconSvg}from"./rule-utils.js";export const ruleSvgIcon=()=>({test:e=>isIconSvg(e),use:[{loader:getDirname(import.meta.url,"../../loaders/loader-icon.cjs"),options:{svgo:{plugins:[{name:"removeTitle"},{name:"removeDimensions"}]}}}]});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Causeof we expose a component <Icon /> from `@wove/react` it can be optimized via icon-loader.
|
3
|
+
* limitation assets match `svg-icons/**\/*.svg` to icon loader resolver.
|
4
|
+
* @param resource
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export declare const isIconSvg: (resource: string) => boolean;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{ICON_PATH_REGEX}from"./constants.js";export const isIconSvg=s=>ICON_PATH_REGEX.test(s)&&s.endsWith(".svg");
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -0,0 +1 @@
|
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},maxProcesses:"50%",ci:{basedBranch:"origin/master"}};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
|
2
|
+
import { type requireResolve } from '@flatjs/common';
|
3
|
+
import { type PartialDeep } from 'type-fest';
|
4
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
5
|
+
export interface EvolveConfigBase extends ConfigEnvBase {
|
6
|
+
command: 'build' | 'serve' | 'static';
|
7
|
+
/**
|
8
|
+
* Expose `env`.`resolve` to allow dynamic resolve `esm` node modules from `flatjs-evolve.config.ts`
|
9
|
+
* @example
|
10
|
+
* ```ts
|
11
|
+
* export default defineConfig((env) => {
|
12
|
+
* console.log(env.resolve(import.meta.url, 'tailwindcss'));
|
13
|
+
* ...
|
14
|
+
* }
|
15
|
+
* // Note may you need to change `module` to `ESNext` at your `tsconfig.json`
|
16
|
+
* `tsconfig.json`
|
17
|
+
* {
|
18
|
+
* "module": "ESNext"
|
19
|
+
* }
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
resolve: typeof requireResolve;
|
23
|
+
}
|
24
|
+
export declare const defineConfig: (userConfig: UserConfigExport<PartialDeep<FlatEvolveOptions>, EvolveConfigBase>) => UserConfigExport<import("type-fest/source/partial-deep.js").PartialObjectDeep<FlatEvolveOptions, {}>, EvolveConfigBase>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{defineConfig as myDefineConfig}from"@armit/config-loader";export const defineConfig=i=>myDefineConfig(i);
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './define-config.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export*from"./define-config.js";
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { type Compiler } from 'webpack';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
/**
|
4
|
+
* Integrated webpack-dev-server with `mock` server together
|
5
|
+
* @param compiler Webpack compiler(s)
|
6
|
+
* @param enableHmr Value indicates if we need to liveReload or `HMR`
|
7
|
+
* @param devPort The port number of `@flatjs/mock`
|
8
|
+
* @param evolveOptions The configuration of `@flatjs/evolve` (FlatEvolveOptions)
|
9
|
+
*/
|
10
|
+
export declare const addCompilerToDevServer: (compiler: Compiler, enableHmr: boolean, devPort: number, evolveOptions: FlatEvolveOptions) => Promise<boolean>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,r,t,o)=>{const{projectCwd:p,devServer:s}=o,l=new WebpackDevServer({server:{type:s?.https?"https":"http",options:{...s?.https}},open:!1,compress:!0,port:t,hot:r,liveReload:!r,allowedHosts:"all",static:{directory:`${join(p,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},client:{progress:!0,overlay:s?.clientOverlay}},e);return new Promise(((e,r)=>{l.startCallback((t=>{if(t)return r(t);e(!0)}))}))};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type Application } from 'express';
|
2
|
+
import { type FlatEvolveOptions } from '../types/index.js';
|
3
|
+
import { type EvolveDevServerEntryMap } from './middlewares/index.js';
|
4
|
+
/**
|
5
|
+
* Add route `/pages`, `*` to main web-server
|
6
|
+
*/
|
7
|
+
export declare const createAppPageRoute: (projectCwd: string, app: Application, devHostUri: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => void;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,a,r,t,s)=>{const{devServer:d}=s;a.use("/pages",...createPageMiddleware(r,d?.mockOptions?.apiContext||"api",t,s)),a.use("*",createPublicAssetsMiddleware(e))};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
2
|
+
import { type EvolveDevServerEntryMap } from './middlewares/create-page-middleware.js';
|
3
|
+
export declare const createDevServerCompilerTasks: (projectCwd: string, mainPage: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Promise<boolean>[]>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{relative}from"node:path";import{chalk,logger,mergeOptions,urlJoin}from"@flatjs/common";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTasks=async(e,o,r,t)=>{const i=[];for(const[a,n]of Object.entries(r)){const l=n.entryConfig,s=l.options?.moduleFederation,p=shouldEnableReactFastRefresh(!0,[a,l],t);(s?.remotes||[]).forEach((e=>{e.endpoint=e=>{const o=r[e];if(!o)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(o?.devServerHostUri,["/public"])}}));const{devServerPort:c,devServerHostUri:m}=r[a],f={[a]:l},d=urlJoin(m,["public"]),v=await loadWebpackConfig("development",f,mergeOptions(t,{webpack:{publicPath:d}})),h=webpack(splitToMultiCompilerConfigs(f,v,t)[0]);i.push(addCompilerToDevServer(h,p,c,t));const g=h.name||"";h.hooks.invalid.tap("fileChange",(o=>{const r=relative(e,o||"");logger.info(`file change ➩ ${chalk(["cyan"])(r)}`,g)})),h.hooks.done.tap("compileDone",(()=>{logger.info(`debug page ➩ ${chalk(["cyan"])(o)}`,g)}))}return i};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
import { type EvolveDevServerEntryMap } from './middlewares/create-page-middleware.js';
|
4
|
+
export declare const createDevServerEntries: (startPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{mergeOptions}from"@flatjs/common";import{prepareMockDomain}from"@flatjs/mock";import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const createDevServerEntries=async(r,e,o)=>{const{devServer:t,projectVirtualPath:n}=o,m={};let a=r;for(const[r,o]of Object.entries(e)){a+=1;const{mockPort:e,hostUri:i}=await prepareMockDomain(mergeOptions(t?.mockOptions||{},{port:a})),s=normalizeEvolveEntryName(r,n);m[r]={entryConfig:o,devServerPort:e,devServerHostUri:i,normalizedEntryName:s}}return m};
|
@@ -0,0 +1 @@
|
|
1
|
+
import https from"node:https";import{prepareMockDomain}from"@flatjs/mock";import express from"express";export const createDevServer=async e=>{const r=express(),t=e.devServer?.mockOptions,{mockPort:o,hostUri:s}=await prepareMockDomain(t||{});return new Promise((t=>{const p=e.devServer?.https?https.createServer(e.devServer?.https,r):r;r.set("hostUri",s),p.listen(o,(()=>{t({app:r,devHostUri:s,devPort:o})}))}))};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export * from './middlewares/index.js';
|
2
|
+
export * from './add-compiler-to-dev-server.js';
|
3
|
+
export * from './create-dev-server.js';
|
4
|
+
export * from './create-app-page-route.js';
|
5
|
+
export * from './create-dev-server-entries.js';
|
6
|
+
export * from './create-dev-server-compiler-tasks.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export*from"./middlewares/index.js";export*from"./add-compiler-to-dev-server.js";export*from"./create-dev-server.js";export*from"./create-app-page-route.js";export*from"./create-dev-server-entries.js";export*from"./create-dev-server-compiler-tasks.js";
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { type RequestHandler } from 'express';
|
2
|
+
import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
+
export type EvolveDevServerEntryMap = {
|
5
|
+
/**
|
6
|
+
* entryName: `home`
|
7
|
+
*/
|
8
|
+
[entryName: string]: {
|
9
|
+
/**
|
10
|
+
* entryMapItem config options.
|
11
|
+
*/
|
12
|
+
entryConfig: EvolveEntryMapContent;
|
13
|
+
/**
|
14
|
+
* dev server port number
|
15
|
+
*/
|
16
|
+
devServerPort: number;
|
17
|
+
/**
|
18
|
+
* dev server host uri.
|
19
|
+
*/
|
20
|
+
devServerHostUri: string;
|
21
|
+
/**
|
22
|
+
* entryName: `home` should be normallized to ${`projectVirtualPath`}/home
|
23
|
+
*/
|
24
|
+
normalizedEntryName: string;
|
25
|
+
};
|
26
|
+
};
|
27
|
+
/**
|
28
|
+
* A middleware to proxy the page modules template.
|
29
|
+
* @example `http://dev.flatjs.com:3001/pages`
|
30
|
+
* @param mode The mode of this dev server instance.
|
31
|
+
* @param hostUri The main host base url.
|
32
|
+
* @param apiContext apiBase e.g. `api`
|
33
|
+
* @param servedDevServerEntries The served webpack entries
|
34
|
+
* @param forPageMiddlewares Allow us provider customized middlewares for `page`, `modules`
|
35
|
+
* @param evolveOptions The evolve config options
|
36
|
+
*/
|
37
|
+
export declare const createPageMiddleware: (devHostUri: string, apiContext: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => RequestHandler[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import _ from"lodash";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{injectFederationScripts}from"../../helpers/script-injects.js";const getPageMainHtml=async(e,t,l)=>{const r=getPackageDir(),o=readFileSync(join(r,"./templates/main.html"),"utf-8"),a=[],i=l.projectVirtualPath.replace(/^\//,"");for(const[r,o]of Object.entries(l.entryMap)){const l=o.options?.servePageMainLinkFn||(e=>e),n=Object.keys(e).includes(r),s=normalizeEvolveEntryName(r,i),m=urlJoin(t,["pages",s],{env:"me"});a.push({name:r.replace(i,"").replace(/^\//,""),link:l(m,{hostUri:t,entryName:r,virtualPath:i}),flagText:n?"serve":"static",isServed:n?1:0})}const n={title:"@flatjs/evolve",modules:a.sort(((e,t)=>t.isServed-e.isServed))};return _.template(o)(n)},getPageModuleHtml=async(e,t,l,r,o)=>{const{entryMap:a,projectVirtualPath:i}=o,n=Object.keys(a).sort(((e,t)=>t.length-e.length)),s=getPackageDir(),m=n.find((e=>{const l=normalizeEvolveEntryName(e,i);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(l,!0))}));if(!m){const e=readFileSync(join(s,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:s},{name:"served entry names",value:JSON.stringify(n)},{name:"module path",value:`${t.path}`}]})}const p=normalizeEvolveEntryName(m,i),c=a[m],u=c.options,d=e[m],g=d?.devServerHostUri||l,f=u?.serveModuleTemplate||"./templates/module.html",v=join(o.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(f)?f:existsSync(v)?v:join(s,"./templates/module.html"),"utf-8"),S=o.devServer,y=S?.defaultServeGlobalData?await S.defaultServeGlobalData(c,l):{},j={mode:"development",envCdn:urlJoin(l,["public"])},P={title:getHtmlPluginConfig("title",j,u?.title),favicon:getHtmlPluginConfig("favicon",j,u?.favicon),viewport:allowPx2remForModule([m,c],o)?getHtmlPluginConfig("viewport",j,u?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",j,u?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",j,u?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",j,u?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",j,u?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",j,u?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(l,["public"])]},o.multiHtmlCdnEnvResolver),global:{hostUrl:l,apiBase:urlJoin(l,[r]),virtualPath:join("/pages",i),moduleName:m.replace(i,"").replace(/^\//,""),...y,...u?.serveGlobalData||{}},styles:[urlJoin(g,[join("public",p,"bundle.css")])],scripts:[urlJoin(g,[join("public",p,"bundle.js")])]};return _.template(h)(P)};export const createPageMiddleware=(e,t,l,r)=>(r.devServer?.middlewares||[]).concat((async(o,a)=>{let i;i="/"===o.path?await getPageMainHtml(l,e,r):await getPageModuleHtml(l,o,e,t,r),a.send(i)}));
|
@@ -0,0 +1 @@
|
|
1
|
+
import{extname,join}from"node:path";import{fileWalk}from"@armit/file-utility";export const createPublicAssetsMiddleware=e=>async(i,s)=>{const t=i.baseUrl;if(t.startsWith("/public")){const i=await fileWalk(join("public/","**/*.{js,css}"),{cwd:e}),a=extname(t),l=i.find((e=>extname(e)===a&&-1!==e.indexOf(t.replace(/\.(?:js|css)$/,""))));l?s.sendFile(l):s.sendFile(join(e,t))}else s.redirect("/pages")};
|
@@ -0,0 +1 @@
|
|
1
|
+
export*from"./create-page-middleware.js";export*from"./create-public-assets-middleware.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
export class EvolveBuildError extends Error{constructor(r,e){let o=r;e&&(o+=": "+JSON.stringify(e)),super(o),this.code=r}}
|
@@ -0,0 +1 @@
|
|
1
|
+
export const allowPx2remForModule=(o,e)=>{const l=e?.loaderOptions?.pixelOptions;return!!((o&&o[1]?.options?.allowPx2rem)??l)};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type EntryMapItem, type EvolveEntryMap } from '../types/types-entry-map.js';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
/**
|
4
|
+
* Only fetch single one entry map once `serve`,`build` recycle.
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export declare const assertOnlySingleEntryItem: (entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => EntryMapItem;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export const assertOnlySingleEntryItem=(e,r)=>{if(Object.keys(e).length>1)throw new Error("Only single one entry map support right now for `serve`, `build`!");let t;for(const[r,o]of Object.entries(e)){t=[r,o];break}if(!t)throw new Error('No entry map found while "serve", "build" process!');const[o,n]=t;return[normalizeEvolveEntryName(o,r.projectVirtualPath),n]};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{arrayChunk}from"@flatjs/common";export const chunkEntryMap=(r,o=2)=>{const n=Object.keys(r),t=arrayChunk(n,o),c=[];for(const o of t){const n=o.reduce(((o,n)=>({...o,[n]:r[n]})),{});c.push(n)}return c};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { type EvolveEntryItemOption } from '../types/types-entry-map.js';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
export declare const enableBundleHashNameForModule: (evolveOptions: FlatEvolveOptions, entryItemOption?: EvolveEntryItemOption) => boolean;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const enableBundleHashNameForModule=(e,a)=>{const n=e.webpack?.enableBundleHashName;return!!(a?.enableBundleHashName??n)};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
2
|
+
/**
|
3
|
+
* Filter to find actived entry input by entry name filter.
|
4
|
+
* @param definedEntries
|
5
|
+
* @param modules `home;mine;`
|
6
|
+
* @returns activedEntries
|
7
|
+
*/
|
8
|
+
export declare const filterActivedEntriesByModule: (definedEntries: EvolveEntryMap, modules: Array<string | RegExp>) => EvolveEntryMap;
|
9
|
+
/**
|
10
|
+
* Filter to find actived entry input by absolute entry filepath
|
11
|
+
* @param projectCwd
|
12
|
+
* @param definedEntries
|
13
|
+
* @param entryInputs [`/xxxx/x/xxxx/src/home/index.tsx`]
|
14
|
+
* @returns activedEntries
|
15
|
+
*/
|
16
|
+
export declare const filterActivedEntriesByEntryInputs: (projectCwd: string, definedEntries: EvolveEntryMap, entryInputs: string[]) => Promise<EvolveEntryMap>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{arraysIntersect,normalizeSemicolonFilterParts}from"@flatjs/common";import{resolveEntryMapInputFiles}from"./resolve-entry-map-input-files.js";export const filterActivedEntriesByModule=(t,e)=>{const r=normalizeSemicolonFilterParts(e),n={};for(const[e,o]of Object.entries(t)){r.find((t=>("string"==typeof t?new RegExp(`${t}`):t).test(e)))&&(n[e]=o)}return n};export const filterActivedEntriesByEntryInputs=async(t,e,r)=>{const n={};for(const[o,s]of Object.entries(e)){const e=await resolveEntryMapInputFiles(t,{[o]:s});arraysIntersect(e,r)&&(n[o]=s)}return n};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Get current timestramp as `string`
|
3
|
+
*/
|
4
|
+
export declare const currNow: () => string;
|
5
|
+
/**
|
6
|
+
* Generate bundle file name from rules
|
7
|
+
* 1. if `serveMode`, always return `bundle
|
8
|
+
* 2. else if `enableBundleHashName` always return `bundle[contenthash].{css,js}`
|
9
|
+
* 3. otherwise return `bundle.{css,js}?${currNow}`
|
10
|
+
* @param type `js` | `css`
|
11
|
+
* @param serveMode If we are run `serve` mode
|
12
|
+
* @param enableBundleHashName If we need to generate bundle file name with `[contenthash]`
|
13
|
+
*/
|
14
|
+
export declare const getBundleFileName: (type: 'css' | 'js', serveMode: boolean, enableBundleHashName?: boolean) => string;
|