@flatjs/evolve 2.0.2 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/create-webpack/create-output.d.ts +2 -1
- package/dist/create-webpack/create-output.js +1 -1
- package/dist/create-webpack/load-webpack-config.js +1 -1
- package/dist/default-options.js +1 -1
- package/dist/dev-server/add-compiler-to-dev-server.js +1 -1
- package/dist/helpers/filter-actived-entries.js +1 -1
- package/dist/plugins/multi-html/index.js +1 -1
- package/dist/types/types-dev-server.d.ts +7 -1
- package/dist/types/types-entry-map.d.ts +22 -0
- package/dist/types/types-multi-html.d.ts +1 -1
- package/package.json +36 -36
@@ -1,3 +1,4 @@
|
|
1
1
|
import { type Configuration } from 'webpack';
|
2
|
+
import { type EntryMapItem } from '../types/types-entry-map.js';
|
2
3
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
-
export declare const createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions) => Promise<Configuration['output']>;
|
4
|
+
export declare const createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Promise<Configuration['output']>;
|
@@ -1 +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:
|
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,o)=>{const{projectCwd:n,webpack:a}=t;let u="auto";const i=o[1];a?.publicPath&&"auto"!==a.publicPath&&(u=ensureSlash(a.publicPath,!0));const p="function"==typeof a?.outputDir?await a.outputDir():a?.outputDir||"public";return{devtoolModuleFilenameTemplate:({namespace:e,resourcePath:t})=>`webpack:///${join(e,t)}`,environment:{},pathinfo:!1,path:join(n,p),publicPath:u,filename:`[name]/${getBundleFileName("js",e,a?.enableBundleHashName)}`,chunkFilename:"[id].[contenthash].js",...i.options?.output}};
|
@@ -1 +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,r,i),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
|
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,i),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,r,i),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
|
package/dist/default-options.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",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"}};
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},webSocketURL:"localIp",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"}};
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,r,
|
1
|
+
import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,o,r,t,s)=>{const{projectCwd:p,devServer:c}=s,l=new WebpackDevServer({server:{type:c?.https?"https":"http",options:{...c?.https}},open:!1,compress:!0,port:r,hot:o,liveReload:!o,allowedHosts:"all",static:{directory:`${join(p,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},client:{progress:!0,overlay:c?.clientOverlay,webSocketURL:"localIp"===c?.webSocketURL?{hostname:t||void 0}:{hostname:"0.0.0.0",...c?.webSocketURL}}},e);return new Promise(((e,o)=>{l.startCallback((r=>{if(r)return o(r);e(!0)}))}))};
|
@@ -1 +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};
|
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||"number"==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};
|
@@ -1 +1 @@
|
|
1
|
-
import{FlatEvolveMultiCdnPlugin}from"./multi-html-cdn-plugin.js";import{createMultiHtmlWebpackPlugin}from"./multi-html-plugin.js";export const createHtmlPlugins=(t,l,u)=>{const i=[];if(t)return i;const n=Object.keys(u.multiHtmlCdn);return i.push(...createMultiHtmlWebpackPlugin(t,u,l,n)),i.push(new FlatEvolveMultiCdnPlugin(u)),i};
|
1
|
+
import{FlatEvolveMultiCdnPlugin}from"./multi-html-cdn-plugin.js";import{createMultiHtmlWebpackPlugin}from"./multi-html-plugin.js";export const createHtmlPlugins=(t,l,u)=>{const i=[];if(t||l[1]?.options?.output?.library)return i;const n=Object.keys(u.multiHtmlCdn);return i.push(...createMultiHtmlWebpackPlugin(t,u,l,n)),i.push(new FlatEvolveMultiCdnPlugin(u)),i};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { type SecureContextHttps, type FlatMockOptions } from '@flatjs/mock';
|
2
2
|
import { type RequestHandler } from 'express';
|
3
3
|
import { type Configuration } from 'webpack';
|
4
|
-
import { type ClientConfiguration } from 'webpack-dev-server';
|
4
|
+
import { type WebSocketURL, type ClientConfiguration } from 'webpack-dev-server';
|
5
5
|
import { type EvolveEntryMapContent } from './types-entry-map.js';
|
6
6
|
export interface WebpackWatchOptions {
|
7
7
|
/**
|
@@ -58,6 +58,12 @@ export type FlatEvolveDevServerOptions = {
|
|
58
58
|
* }
|
59
59
|
*/
|
60
60
|
clientOverlay?: ClientConfiguration['overlay'];
|
61
|
+
/**
|
62
|
+
* This option allows specifying URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).
|
63
|
+
* @example use `localIp` for remote mobile devices HMR it will convert to local ip `ws://10.10.100.3/ws`
|
64
|
+
* @example use `{ hostname: '0.0.0.0' }`, will get 'auto://0.0.0.0:0/ws'
|
65
|
+
*/
|
66
|
+
webSocketURL?: WebSocketURL | 'localIp';
|
61
67
|
/**
|
62
68
|
* The customized config options of `flatjs/mock`, it will override options `flatjs-mock.config.ts`
|
63
69
|
*/
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type Configuration } from 'webpack';
|
1
2
|
import { type ModuleFederationOptions } from './types-federation.js';
|
2
3
|
import { type MultiHtmlCDNEntryItem } from './types-multi-html.js';
|
3
4
|
/**
|
@@ -57,6 +58,27 @@ export interface EvolveEntryItemOption extends MultiHtmlCDNEntryItem {
|
|
57
58
|
* @default undefined
|
58
59
|
*/
|
59
60
|
mockFilters?: Array<string | RegExp>;
|
61
|
+
/**
|
62
|
+
* Extends the default `output` configuration for each entry item.
|
63
|
+
* normally we use `output.library` to define the global variable name.
|
64
|
+
* @example
|
65
|
+
* ```ts
|
66
|
+
*'plugin-chart': {
|
67
|
+
* entry: [`./src/plugin-chart/index`],
|
68
|
+
* options: {
|
69
|
+
* output: {
|
70
|
+
* library: {
|
71
|
+
* name: 'dashboardPluginChart',
|
72
|
+
* type: 'var',
|
73
|
+
* },
|
74
|
+
* libraryTarget: 'window',
|
75
|
+
* },
|
76
|
+
* },
|
77
|
+
* }
|
78
|
+
* ```
|
79
|
+
* @default undefined
|
80
|
+
*/
|
81
|
+
output?: Configuration['output'];
|
60
82
|
}
|
61
83
|
export type EvolveEntryMapContent = {
|
62
84
|
entry: [string, ...string[]];
|
@@ -10,7 +10,7 @@ export type EvolveMultiCDNEnvResolver = (url: string) => EvolveMultiCdnEnvType |
|
|
10
10
|
/**
|
11
11
|
* The html plugin configuration for each entry item
|
12
12
|
*/
|
13
|
-
export
|
13
|
+
export type MultiHtmlCDNEntryItem = {
|
14
14
|
/**
|
15
15
|
* The title to use for the generated HTML document
|
16
16
|
* @default ''
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -34,17 +34,17 @@
|
|
34
34
|
"typecheck": "tsc --project ./tsconfig.json --noEmit"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@armit/config-loader": "^0.1.
|
38
|
-
"@armit/file-utility": "^0.1.
|
39
|
-
"@armit/git": "^0.1.
|
40
|
-
"@armit/package": "^0.1.
|
41
|
-
"@armit/worker-threads": "^0.1.
|
42
|
-
"@babel/core": "7.23.
|
43
|
-
"@flatjs/common": "2.0.
|
44
|
-
"@flatjs/evolve-preset-babel": "2.0.
|
45
|
-
"@flatjs/forge-postcss-plugin-pixel": "2.0.
|
46
|
-
"@flatjs/graph": "2.0.
|
47
|
-
"@flatjs/mock": "2.0.
|
37
|
+
"@armit/config-loader": "^0.1.4",
|
38
|
+
"@armit/file-utility": "^0.1.3",
|
39
|
+
"@armit/git": "^0.1.3",
|
40
|
+
"@armit/package": "^0.1.3",
|
41
|
+
"@armit/worker-threads": "^0.1.3",
|
42
|
+
"@babel/core": "7.23.9",
|
43
|
+
"@flatjs/common": "2.0.3",
|
44
|
+
"@flatjs/evolve-preset-babel": "2.0.3",
|
45
|
+
"@flatjs/forge-postcss-plugin-pixel": "2.0.3",
|
46
|
+
"@flatjs/graph": "2.0.3",
|
47
|
+
"@flatjs/mock": "2.0.3",
|
48
48
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
49
49
|
"@types/babel__core": "7.20.5",
|
50
50
|
"babel-loader": "9.1.3",
|
@@ -52,55 +52,55 @@
|
|
52
52
|
"babel-plugin-import": "1.13.8",
|
53
53
|
"better-opn": "3.0.2",
|
54
54
|
"case-sensitive-paths-webpack-plugin": "2.4.0",
|
55
|
-
"css-loader": "6.
|
56
|
-
"cssnano": "6.0.
|
55
|
+
"css-loader": "6.9.1",
|
56
|
+
"cssnano": "6.0.3",
|
57
57
|
"express": "4.18.2",
|
58
58
|
"fork-ts-checker-webpack-plugin": "9.0.2",
|
59
|
-
"happy-dom": "
|
60
|
-
"html-webpack-plugin": "5.
|
61
|
-
"image-minimizer-webpack-plugin": "
|
59
|
+
"happy-dom": "13.3.1",
|
60
|
+
"html-webpack-plugin": "5.6.0",
|
61
|
+
"image-minimizer-webpack-plugin": "4.0.0",
|
62
62
|
"less": "4.2.0",
|
63
|
-
"less-loader": "
|
63
|
+
"less-loader": "12.1.0",
|
64
64
|
"listr": "0.14.3",
|
65
65
|
"lodash": "4.17.21",
|
66
|
-
"mini-css-extract-plugin": "2.7.
|
67
|
-
"postcss": "8.4.
|
68
|
-
"postcss-loader": "
|
66
|
+
"mini-css-extract-plugin": "2.7.7",
|
67
|
+
"postcss": "8.4.33",
|
68
|
+
"postcss-loader": "8.0.0",
|
69
69
|
"react-refresh": "0.14.0",
|
70
|
-
"svgo": "3.
|
70
|
+
"svgo": "3.2.0",
|
71
71
|
"tarjan-graph": "3.0.0",
|
72
|
-
"terser-webpack-plugin": "5.3.
|
72
|
+
"terser-webpack-plugin": "5.3.10",
|
73
73
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
74
|
-
"type-fest": "^4.
|
74
|
+
"type-fest": "^4.10.1",
|
75
75
|
"typescript": "5.3.3",
|
76
|
-
"webpack": "5.
|
76
|
+
"webpack": "5.90.0",
|
77
77
|
"webpack-bundle-analyzer": "4.10.1",
|
78
78
|
"webpack-dev-server": "4.15.1",
|
79
79
|
"webpack-sources": "3.2.3"
|
80
80
|
},
|
81
81
|
"devDependencies": {
|
82
|
-
"@armit/eslint-config-bases": "^0.1.
|
83
|
-
"@flatjs/testing": "2.0.
|
84
|
-
"@swc/core": "1.3.
|
82
|
+
"@armit/eslint-config-bases": "^0.1.4",
|
83
|
+
"@flatjs/testing": "2.0.3",
|
84
|
+
"@swc/core": "1.3.106",
|
85
85
|
"@types/express": "4.17.21",
|
86
86
|
"@types/listr": "0.14.9",
|
87
|
-
"@types/node": "20.
|
88
|
-
"@vitest/coverage-istanbul": "1.
|
89
|
-
"@vitest/ui": "1.
|
90
|
-
"eslint": "8.
|
87
|
+
"@types/node": "20.11.6",
|
88
|
+
"@vitest/coverage-istanbul": "1.2.1",
|
89
|
+
"@vitest/ui": "1.2.1",
|
90
|
+
"eslint": "8.56.0",
|
91
91
|
"imagemin-gifsicle": "7.0.0",
|
92
92
|
"imagemin-jpegtran": "7.0.0",
|
93
93
|
"imagemin-pngquant": "9.0.2",
|
94
94
|
"imagemin-svgo": "10.0.1",
|
95
95
|
"npm-run-all": "4.1.5",
|
96
|
-
"prettier": "3.
|
96
|
+
"prettier": "3.2.4",
|
97
97
|
"react": "18.2.0",
|
98
98
|
"rimraf": "5.0.5",
|
99
99
|
"swc-unplugin-ts": "1.0.2",
|
100
100
|
"ts-node": "10.9.2",
|
101
|
-
"vite-tsconfig-paths": "4.
|
102
|
-
"vitest": "1.
|
103
|
-
"vue-loader": "17.
|
101
|
+
"vite-tsconfig-paths": "4.3.1",
|
102
|
+
"vitest": "1.2.1",
|
103
|
+
"vue-loader": "17.4.2"
|
104
104
|
},
|
105
105
|
"peerDependencies": {
|
106
106
|
"imagemin-gifsicle": ">=7.0.0",
|