@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.
@@ -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: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"}};
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"}}};
@@ -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,o,t,s)=>{const{projectCwd:p,devServer:i}=s,l=new WebpackDevServer({server:{type:i?.https?"https":"http",options:{...i?.https}},open:!1,compress:!0,port:o,hot:r,liveReload:!r,allowedHosts:"all",static:{directory:`${join(p,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},client:{progress:!0,overlay:i?.clientOverlay,webSocketURL:{hostname:t||void 0}}},e);return new Promise(((e,r)=>{l.startCallback((o=>{if(o)return r(o);e(!0)}))}))};
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 declare type MultiHtmlCDNEntryItem = {
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.2",
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.2",
38
- "@armit/file-utility": "^0.1.1",
39
- "@armit/git": "^0.1.1",
40
- "@armit/package": "^0.1.1",
41
- "@armit/worker-threads": "^0.1.1",
42
- "@babel/core": "7.23.6",
43
- "@flatjs/common": "2.0.2",
44
- "@flatjs/evolve-preset-babel": "2.0.2",
45
- "@flatjs/forge-postcss-plugin-pixel": "2.0.2",
46
- "@flatjs/graph": "2.0.2",
47
- "@flatjs/mock": "2.0.2",
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.8.1",
56
- "cssnano": "6.0.1",
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": "12.10.3",
60
- "html-webpack-plugin": "5.5.4",
61
- "image-minimizer-webpack-plugin": "3.8.3",
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": "11.1.3",
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.6",
67
- "postcss": "8.4.32",
68
- "postcss-loader": "7.3.3",
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.1.0",
70
+ "svgo": "3.2.0",
71
71
  "tarjan-graph": "3.0.0",
72
- "terser-webpack-plugin": "5.3.9",
72
+ "terser-webpack-plugin": "5.3.10",
73
73
  "tsconfig-paths-webpack-plugin": "4.1.0",
74
- "type-fest": "^4.8.3",
74
+ "type-fest": "^4.10.1",
75
75
  "typescript": "5.3.3",
76
- "webpack": "5.89.0",
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.2",
83
- "@flatjs/testing": "2.0.2",
84
- "@swc/core": "1.3.100",
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.10.4",
88
- "@vitest/coverage-istanbul": "1.0.4",
89
- "@vitest/ui": "1.0.4",
90
- "eslint": "8.55.0",
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.1.1",
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.2.2",
102
- "vitest": "1.0.4",
103
- "vue-loader": "17.3.1"
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",