@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.
- package/dist/create-webpack/load-watch-options.d.ts +12 -0
- package/dist/create-webpack/load-watch-options.js +1 -0
- package/dist/create-webpack/load-webpack-config.js +1 -1
- package/dist/dev-server/create-dev-server-compiler-task.js +1 -1
- package/dist/helpers/normalize-entry-module-absolute-path.d.ts +10 -0
- package/dist/helpers/normalize-entry-module-absolute-path.js +1 -0
- package/dist/types/types-entry-map.d.ts +4 -0
- package/package.json +1 -1
@@ -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=
|
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[
|
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))};
|