@flatjs/evolve 2.1.0-next.24 → 2.1.0-next.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ import { type FlatEvolveDevServerOptions } from '../types/types-dev-server.js';
2
+ import { EvolveEntryMap } from '../types/types-entry-map.js';
3
+ import { type FlatEvolveOptions } from '../types/types-options.js';
4
+ /**
5
+ * Loads the watch options for webpack configuration.
6
+ *
7
+ * @param groupEntryMap - The map of entry.
8
+ * @param evolveOptions - The options for the evolve process.
9
+ * @param originalOptions - The original watch options to be merged with.
10
+ * @returns The updated watch options for webpack configuration.
11
+ */
12
+ export declare const loadWatchOptions: (groupEntryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions, originalOptions?: FlatEvolveDevServerOptions["watchOptions"]) => FlatEvolveDevServerOptions["watchOptions"];
@@ -0,0 +1 @@
1
+ import{existsSync}from"node:fs";import{logger}from"@flatjs/common";import{normalizeEntryModuleAbsolutePath}from"../helpers/normalize-entry-module-absolute-path.js";export const loadWatchOptions=(o,e,t={})=>{const{ignored:r=[]}=t,{entryMap:n}=e,s=normalizeEntryModuleAbsolutePath(e,o),l=normalizeEntryModuleAbsolutePath(e,n);for(const o of l){existsSync(o)||logger.warn(`The module path does not exist. Check ${o}`);s.findIndex((e=>e===o))<0&&r.push(`**${o}**/*`)}return{...t,ignored:r}};
@@ -1 +1 @@
1
- import{assertGroupEntryItem}from"../helpers/assert-group-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:c}=r,n=assertGroupEntryItem(t,r),p=c?.watchOptions,i=createRuleSets(a,n,r),m=await createPlugins(a,n,r),l=n[0];return{mode:e,plugins:m,watchOptions:p,output:await createOutput(a,r,l),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:i},devtool:a?"eval-source-map":s?.sourceMap||!1,externalsType:s?.externalsType,externals:createExternals(s?.externals,l),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,r,l),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"errors-warnings"},cache:{type:"memory"}}};
1
+ import{assertGroupEntryItem}from"../helpers/assert-group-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";import{loadWatchOptions}from"./load-watch-options.js";export const loadWebpackConfig=async(e,t,r)=>{const a="development"===e,{projectCwd:o,webpack:s,devServer:c}=r,n=loadWatchOptions(t,r,c?.watchOptions),p=assertGroupEntryItem(t,r),i=createRuleSets(a,p,r),m=await createPlugins(a,p,r),l=p[0];return{mode:e,plugins:m,watchOptions:n,output:await createOutput(a,r,l),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:i},devtool:a?"eval-source-map":s?.sourceMap||!1,externalsType:s?.externalsType,externals:createExternals(s?.externals,l),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,r,l),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"errors-warnings"},cache:{type:"memory"}}};
@@ -1 +1 @@
1
- import webpack from"webpack";import{mergeOptions,urlJoin}from"@flatjs/common";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{assertSingleCompiler}from"../helpers/assert-single-compiler.js";import{flatEntryMap}from"../helpers/flat-entry-map.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTask=async(e,r,o,t)=>{const[s,a]=Object.entries(r)[0],{devServerPort:n,devServerHostUri:i}=a;for(const[,e]of Object.entries(r)){const r=e.entryConfig,t=r.options?.moduleFederation,s=t?.remotes||[],a=flatEntryMap(o);s.forEach((e=>{e.endpoint=e=>{const r=a[e];if(!r)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(r?.devServerHostUri,["/public"])}}))}const p=Object.keys(r).reduce(((e,o)=>(e[o]=r[o].entryConfig,e)),{}),l=urlJoin(i,["public"]),c=await loadWebpackConfig("development",p,mergeOptions(t,{webpack:{publicPath:l}})),m=shouldEnableReactFastRefresh(!0,[s,a.entryConfig],t),f=assertSingleCompiler(p,c,t,m),d=webpack(f);return addCompilerToDevServer(d,m,n,e,t)};
1
+ import{relative}from"node:path";import webpack from"webpack";import{chalk,logger,mergeOptions,urlJoin}from"@flatjs/common";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{assertSingleCompiler}from"../helpers/assert-single-compiler.js";import{flatEntryMap}from"../helpers/flat-entry-map.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTask=async(e,r,o,t)=>{const{projectCwd:a}=t,[n,i]=Object.entries(r)[0],{devServerPort:s,devServerHostUri:l}=i;for(const[,e]of Object.entries(r)){const r=e.entryConfig,t=r.options?.moduleFederation,a=t?.remotes||[],n=flatEntryMap(o);a.forEach((e=>{e.endpoint=e=>{const r=n[e];if(!r)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(r?.devServerHostUri,["/public"])}}))}const p=Object.keys(r).reduce(((e,o)=>(e[o]=r[o].entryConfig,e)),{}),c=urlJoin(l,["public"]),m=await loadWebpackConfig("development",p,mergeOptions(t,{webpack:{publicPath:c}})),f=shouldEnableReactFastRefresh(!0,[n,i.entryConfig],t),d=assertSingleCompiler(p,m,t,f),v=webpack(d),h=addCompilerToDevServer(v,f,s,e,t),b=v.name||"";return v.hooks.invalid.tap("fileChange",(e=>{const r=relative(a,e||"");logger.info(`file change ➩ ${chalk(["cyan"])(r||"")}`,b)})),h};
@@ -0,0 +1,10 @@
1
+ import { EvolveEntryMap } from '../types/types-entry-map.js';
2
+ import { FlatEvolveOptions } from '../types/types-options.js';
3
+ /**
4
+ * Normalizes the absolute paths of entry modules based on the provided evolve options and entry map.
5
+ *
6
+ * @param evolveOptions - The options for the evolve process.
7
+ * @param evolveEntryMap - The map of evolve entries.
8
+ * @returns An array of normalized entry module paths.
9
+ */
10
+ export declare const normalizeEntryModuleAbsolutePath: (evolveOptions: FlatEvolveOptions, evolveEntryMap: EvolveEntryMap) => string[];
@@ -0,0 +1 @@
1
+ import{resolve}from"node:path";import{ensureSlash}from"@flatjs/common";export const normalizeEntryModuleAbsolutePath=(e,o)=>{const{projectCwd:s}=e,t=[];for(const[,e]of Object.entries(o)){const{entryModuleBase:o,entry:r}=e;if(o)for(const e of o){const o=ensureSlash(resolve(s,e),!0);t.push(o)}else for(const e of r){let o=resolve(s,e);/\.(ts|tsx|js|jsx)$/.test(o)&&(o=o.replace(/\/[^/]*$/,""));const r=ensureSlash(o,!0);t.push(r)}}return Array.from(new Set(t))};
@@ -97,6 +97,10 @@ export type EvolveEntryMapContent = {
97
97
  * @default 'auto'
98
98
  */
99
99
  groupingSource?: 'auto' | 'manual';
100
+ /**
101
+ * The base path of the entry module
102
+ */
103
+ entryModuleBase?: string[];
100
104
  };
101
105
  export interface EvolveEntryMap {
102
106
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "2.1.0-next.24",
3
+ "version": "2.1.0-next.25",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {