@flatjs/evolve 3.0.14 → 3.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/dist/core/rspack/create-plugins.js +1 -1
- package/dist/core/rspack/create-rspack-rule-sets.js +1 -1
- package/dist/helpers/load-env-config.js +1 -1
- package/dist/load-config/load-evolve-config.js +1 -1
- package/dist/main/create-thread-worker.js +1 -1
- package/dist/plugins/rspack/circular-dependency-plugin/index.js +1 -1
- package/dist/plugins/rspack/multi-html/multi-html-cdn-rspack-plugin.d.ts +1 -1
- package/dist/plugins/rspack/multi-html/multi-html-cdn-rspack-plugin.js +1 -1
- package/dist/plugins/rspack/progress-plugin/index.d.ts +2 -3
- package/dist/plugins/webpack/circular-dependency/circular-dependency-webpack-plugin.js +1 -1
- package/dist/plugins/webpack/clean-webpack/clean-webpack-plugin.js +1 -1
- package/dist/plugins/webpack/module-federation/index.d.ts +2 -2
- package/dist/rules/rspack/rule-scripts.d.ts +11 -1
- package/dist/rules/rspack/rule-scripts.js +1 -1
- package/package.json +63 -62
package/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# @flatjs/evolve
|
|
2
2
|
|
|
3
|
-
## Note: because below configuration of `tsconfig.json `
|
|
4
|
-
|
|
5
|
-
```json
|
|
6
|
-
{ "baseUrl": "./src" }
|
|
7
|
-
```
|
|
8
|
-
|
|
9
3
|
We should not create folder name like `webpack` in `src/webpack`;
|
|
10
4
|
|
|
11
5
|
1. while we use `import { moduleX } from webpack`; it will resolve `moduleX` from `src/webpack` instead import from `node_modules`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack from"@rspack/core";import
|
|
1
|
+
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack from"@rspack/core";import{ReactRefreshRspackPlugin}from"@rspack/plugin-react-refresh";import{assertChunkFilename}from"../../helpers/assert-chunk-filename.js";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{createCircularDependencyRspackPlugins}from"../../plugins/rspack/circular-dependency-plugin/index.js";import{createBuiltinDefineVariablesRspackPlugins}from"../../plugins/rspack/define-variable/index.js";import{createModuleFederationRspackPlugins}from"../../plugins/rspack/module-federation/index.js";import{createHtmlRspackPlugins}from"../../plugins/rspack/multi-html/index.js";import{createProgressRspackPlugins}from"../../plugins/rspack/progress-plugin/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createCodeCheckerWebpackPlugins}from"../../plugins/webpack/code-checker/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createRspackPlugins=async(e,s,a,r)=>{const n=s[0],[i,c]=n,l=enableBundleHashNameForModule(a,c?.options),t=[...createProgressRspackPlugins(e,s),new rspack.IgnorePlugin({resourceRegExp:/\.d\.[cm]ts$/}),new CaseSensitivePathsPlugin,...createCircularDependencyRspackPlugins(e,a),new rspack.CssExtractRspackPlugin({filename:`[name]/${getBundleFileName("css",e,l)}`,chunkFilename:assertChunkFilename(a,n,"css")}),...await createBuiltinDefineVariablesRspackPlugins(e,a),...createCleanWebpackPlugins(e,s,a),...createModuleFederationRspackPlugins(e,s,a),...await createHtmlRspackPlugins(e,s,a),...createStatsWebpackPlugins(e,a,r),...createCodeCheckerWebpackPlugins(e,a)],o=shouldEnableReactFastRefresh(e,n,a);o&&t.push(new ReactRefreshRspackPlugin({exclude:[/node_modules/]})),!o&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${i}"\``)),a.openRsdoctor&&t.push(new RsdoctorRspackPlugin);const p=a.webpack?.plugins||[];return t.concat(p)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rspackRuleAssets,rspackRuleCss,rspackRuleLess,rspackRuleScripts,rspackRuleSvgIcon}from"../../rules/index.js";export const createRspackRuleSets=(s,e,c)=>{const r=e[0],p=[rspackRuleSvgIcon(),rspackRuleAssets(e,c),rspackRuleCss(s,r,c,!1),rspackRuleCss(s,r,c,!0),rspackRuleLess(s,r,c)
|
|
1
|
+
import{rspackRuleAssets,rspackRuleCss,rspackRuleLess,rspackRuleScripts,rspackRuleSvgIcon}from"../../rules/index.js";export const createRspackRuleSets=(s,e,c)=>{const r=e[0],p=[rspackRuleSvgIcon(),rspackRuleAssets(e,c),rspackRuleCss(s,r,c,!1),rspackRuleCss(s,r,c,!0),rspackRuleLess(s,r,c),...rspackRuleScripts(s,r,c)],a=c.webpack?.ruleSets||[];return p.concat(a)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"fs";import{join}from"path";import{chalk,logger}from"@flatjs/common";import{searchConfig}from"@hyperse/config-loader";export const loadEnvConfig=async(o,n)=>{const{projectCwd:t}=n,e=join(t,"configuration"),i=`env.${o}.ts`;if(!existsSync(join(e,i)))return void logger.
|
|
1
|
+
import{existsSync}from"fs";import{join}from"path";import{chalk,logger}from"@flatjs/common";import{searchConfig}from"@hyperse/config-loader";export const loadEnvConfig=async(o,n)=>{const{projectCwd:t}=n,e=join(t,"configuration"),i=`env.${o}.ts`;if(!existsSync(join(e,i)))return void logger.debug(`Env config file not found: ${chalk(["yellow"])(i)}`);const r={externals:[/^@flatjs\/.*/],projectCwd:t};"test"===process.env.NODE_ENV&&(r.externalExclude=o=>o.toString().startsWith("@flatjs/"));const c=await searchConfig(o,e,r);let f;if(f="function"==typeof c?.config?await(c?.config(o)):c?.config||{},f)return f;logger.warn(`Env config is undefined: ${chalk(["yellow"])(i)}`)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger,mergeOptions}from"@flatjs/common";import{searchConfig}from"@hyperse/config-loader";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{normalizeResolveAlias}from"../helpers/normalize-resolve-alias.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},l={configFile:configFileName,loaderOptions:{externals:[/^@flatjs\/.*/]}})=>{const{configFile:r,loaderOptions:s}=l,a=await searchConfig(r,e,{...s,projectCwd:e});let n
|
|
1
|
+
import{logger,mergeOptions}from"@flatjs/common";import{searchConfig}from"@hyperse/config-loader";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{normalizeResolveAlias}from"../helpers/normalize-resolve-alias.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},l={configFile:configFileName,loaderOptions:{externals:[/^@flatjs\/.*/]}})=>{const{configFile:r,loaderOptions:s}=l,a=await searchConfig(r,e,{...s,projectCwd:e});let n;n="function"==typeof a?.config?await(a?.config(o)):a?.config||{};const t=mergeOptions(defaultEvolveOptions,n),m=mergeOptions(t,i),f=mergeOptions(m,{projectCwd:e}),p="build"===o.command?f:await refreshEvolveMockOptions(e,f,l);return logger.debug(`Load evolve config:\n${JSON.stringify(p,null,2)}`,moduleName),p.webpack?.resolve?.alias&&(p.webpack.resolve.alias=normalizeResolveAlias(e,p.webpack?.resolve?.alias)),p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Tinypool from"tinypool";import{mergeOptions}from"@flatjs/common";import{customMessageChannel}from"../helpers/custom-message-channel.js";import{getWorkerPath}from"./get-worker-path.js";import startBuildWorker from"./start-build-worker.js";class ThreadPoolForUnittest{startBuildWorker(e){return startBuildWorker(e)}terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')}}class ThreadPoolForTinyPool{constructor(e,
|
|
1
|
+
import Tinypool from"tinypool";import{mergeOptions}from"@flatjs/common";import{customMessageChannel}from"../helpers/custom-message-channel.js";import{getWorkerPath}from"./get-worker-path.js";import startBuildWorker from"./start-build-worker.js";class ThreadPoolForUnittest{startBuildWorker(e){return startBuildWorker(e)}terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')}}class ThreadPoolForTinyPool{constructor(e,o){const{idleTimeout:r=6e4,minThreads:t=1,maxThreads:s}=o||{};this.pool=new Tinypool({runtime:"worker_threads",filename:e,minThreads:t,maxThreads:s,idleTimeout:r})}startBuildWorker(e){const{port1:o}=customMessageChannel.createMessageChannel(),r=mergeOptions(e,{messagePort:Tinypool.move(o)});return this.pool.run(r)}terminate(){this.pool.destroy(),customMessageChannel.dispose()}}export const createThreadWorker=e=>{const o=getWorkerPath();return"test"===process.env.NODE_ENV?(console.warn("[WARNING] Using fake thread pool worker for unittest!"),new ThreadPoolForUnittest):new ThreadPoolForTinyPool(o,e)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger}from"@flatjs/common";import{
|
|
1
|
+
import{logger}from"@flatjs/common";import{CircularCheckRspackPlugin}from"@rspack/core";const cutBefore=(e,r)=>{const c=new RegExp(`^[\\s\\S]*?${r}`),n=e.replace(c,"");return n.includes("!/")?`/${n.split("!/")[1]}`:n};export const createCircularDependencyRspackPlugins=(e,r)=>{if(!e)return[];const{projectCwd:c}=r;return[new CircularCheckRspackPlugin({exclude:/node_modules/,failOnError:!1,onDetected({paths:e}){const r=e.map(e=>cutBefore(e,c)).join(" -> ");logger.warn(`Circular dependency detected:\r\n ${r}`)}})]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{basename}from"node:path";import{ensureSlash}from"@flatjs/common";import rspack from"@rspack/core";import{getRuntimeCDNBase}from"../../../helpers/get-runtime-cdn-base.js";import{findEnvCdn,httpUrlJoin}from"../../../helpers/script-injects.js";export class FlatEvolveMultiCdnRspackPlugin{constructor(e,t){if(this.pluginName="FlatEvolveMultiCdnRspackPlugin",this.requireFn=rspack.RuntimeGlobals.publicPath,this.config=e.multiHtmlCdn,this.entryMapItemList=t,this.cdnResolver=e.multiHtmlCdnEnvResolver||function cdnResolver(){},!this.config?.prod)throw new Error("We must setup `prod` for each CDN config node!")}apply(e){e.hooks.compilation.tap(this.pluginName,e=>{e.hooks.runtimeModule.tap(this.pluginName,(e,t)=>{const s=this.entryMapItemList.find(e=>e[0]===t.name);if("public_path"===e.name&&s){const t=
|
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{basename}from"node:path";import{ensureSlash}from"@flatjs/common";import rspack from"@rspack/core";import{getRuntimeCDNBase}from"../../../helpers/get-runtime-cdn-base.js";import{findEnvCdn,httpUrlJoin}from"../../../helpers/script-injects.js";export class FlatEvolveMultiCdnRspackPlugin{constructor(e,t){if(this.pluginName="FlatEvolveMultiCdnRspackPlugin",this.requireFn=rspack.RuntimeGlobals.publicPath,this.config=e.multiHtmlCdn,this.entryMapItemList=t,this.cdnResolver=e.multiHtmlCdnEnvResolver||function cdnResolver(){},!this.config?.prod)throw new Error("We must setup `prod` for each CDN config node!")}apply(e){e.hooks.compilation.tap(this.pluginName,e=>{e.hooks.runtimeModule.tap(this.pluginName,(e,t)=>{const s=this.entryMapItemList.find(e=>e[0]===t.name);if("public_path"===e.name&&s&&e.source){const t=e.source.source.toString("utf-8"),s=["","// Dynamic assets path override...",getRuntimeCDNBase(this.config,this.cdnResolver,this.requireFn)].join("\n");e.source.source=Buffer.from(`${t}\n${s}`,"utf-8")}})}),e.hooks.compilation.tap(this.pluginName,t=>{HtmlWebpackPlugin.getHooks(t).beforeAssetTagGeneration.tap(this.pluginName,e=>{const{assets:t,plugin:s,outputName:n}=e,i=s?.options?.chunks||[],o=Array.isArray(i)?i.find(e=>n.includes(ensureSlash(e,!0))):i,{userOptions:r}=e.plugin;if(!o)throw new Error("We must have current chunk!");const a=t.js.filter(e=>e.includes(ensureSlash(o,!0))),l=t.css.filter(e=>e.includes(ensureSlash(o,!0))),p=r.multiCdn,u=t.publicPath,c=a.map(e=>{if(p.disabled)return basename(e);const t=findEnvCdn(this.config,p.env);return httpUrlJoin(t,e.replace(u,""))}),m=l.map(e=>{if(p.disabled)return basename(e);const t=findEnvCdn(this.config,p.env);return httpUrlJoin(t,e.replace(u,""))});return e.assets.js=c,e.assets.css=m,e}),t.hooks.processAssets.tap({name:this.pluginName,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE},s=>{if(e.options.output.library)for(const e of Object.keys(s))e.endsWith(".html")&&delete t.assets[e]})})}}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Plugin as RspackPlugin } from '@rspack/core';
|
|
2
|
-
import { type ProgressPluginArgument } from '@rspack/core';
|
|
1
|
+
import type { Plugin as RspackPlugin, ProgressPluginOptions } from '@rspack/core';
|
|
3
2
|
import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
|
4
|
-
export declare const createProgressRspackPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], pluginOptions?:
|
|
3
|
+
export declare const createProgressRspackPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], pluginOptions?: ProgressPluginOptions) => RspackPlugin[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative}from"node:path";import Graph from"tarjan-graph";import webpack from"webpack";import{mergeOptions}from"@flatjs/common";const BASE_ERROR="Circular dependency detected:\r\n",PLUGIN_TITLE="CircularDependencyWebpackPlugin";export class CircularDependencyWebpackPlugin{constructor(o={}){this.options=mergeOptions({exclude:/node_modules/,include:/.*/,failOnError:!1,allowAsyncCycles:!1,projectCwd:process.cwd()},o)}apply(o){const e=this.options.projectCwd;o.hooks.compilation.tap(PLUGIN_TITLE,o=>{o.hooks.optimizeModules.tap(PLUGIN_TITLE,t=>{this.options.onStart&&this.options.onStart({compilation:o});const n=new(Graph.default||Graph);for(const e of t){const t=[];for(const n of e.dependencies){if(n.constructor&&"CommonJsSelfReferenceDependency"===n.constructor.name)continue;let r
|
|
1
|
+
import{relative}from"node:path";import Graph from"tarjan-graph";import webpack from"webpack";import{mergeOptions}from"@flatjs/common";const BASE_ERROR="Circular dependency detected:\r\n",PLUGIN_TITLE="CircularDependencyWebpackPlugin";export class CircularDependencyWebpackPlugin{constructor(o={}){this.options=mergeOptions({exclude:/node_modules/,include:/.*/,failOnError:!1,allowAsyncCycles:!1,projectCwd:process.cwd()},o)}apply(o){const e=this.options.projectCwd;o.hooks.compilation.tap(PLUGIN_TITLE,o=>{o.hooks.optimizeModules.tap(PLUGIN_TITLE,t=>{this.options.onStart&&this.options.onStart({compilation:o});const n=new(Graph.default||Graph);for(const e of t){const t=[];for(const n of e.dependencies){if(n.constructor&&"CommonJsSelfReferenceDependency"===n.constructor.name)continue;let r;r=o.moduleGraph?o.moduleGraph.getModule(n):n.module,r&&(r instanceof webpack.NormalModule&&r.resource&&(this.options.allowAsyncCycles&&"weak"in n&&n.weak||e!==r&&t.push(r.identifier())))}n.add(e.identifier(),t)}const r=n.getCycles();this.isCyclic(r,o,e),this.options.onEnd&&this.options.onEnd({compilation:o})})})}isCyclic(o,e,t){o.forEach(o=>{const n=o.slice().reverse().map(o=>{const t=e.findModule(o.name);return t instanceof webpack.NormalModule&&t.resource||null});if(n.every(o=>!o||this.options.exclude.test(o)||!this.options.include.test(o)))return;const r=n.map(o=>relative(t,o));if(this.options.onDetected){try{this.options.onDetected({paths:r.concat([r[0]]),compilation:e})}catch(o){e.errors.push(o)}return}const s=new Error(BASE_ERROR.concat(r.concat([r[0]]).join(" -> ")));this.options.failOnError?e.errors.push(s):e.warnings.push(s)})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",e=>{this.handleInitial(e)}),t.done.tap("clean-webpack-plugin",e=>{logger.info("start clean cache..."),this.handleDone(e)})}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map(e=>e.name),s=this.currentAssets.filter(e=>!1===t.includes(e));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach(e=>{const t=relative(this.projectCwd,e);logger.debug(`clean-webpack-plugin: removed ${t}`,moduleName)})}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){
|
|
1
|
+
import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",e=>{this.handleInitial(e)}),t.done.tap("clean-webpack-plugin",e=>{logger.info("start clean cache..."),this.handleDone(e)})}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map(e=>e.name),s=this.currentAssets.filter(e=>!1===t.includes(e));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach(e=>{const t=relative(this.projectCwd,e);logger.debug(`clean-webpack-plugin: removed ${t}`,moduleName)})}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){const t="clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the `dangerouslyAllowCleanPatternsOutsideProject` option.";throw Object.assign(new Error(t),{cause:e})}throw e}}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import webpack from 'webpack';
|
|
2
2
|
import { type EntryMapItem } from '../../../types/types-entry-map.js';
|
|
3
3
|
import { type FlatEvolveOptions } from '../../../types/types-options.js';
|
|
4
|
-
export declare const createModuleFederationWebpackPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => WebpackPluginInstance[];
|
|
4
|
+
export declare const createModuleFederationWebpackPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => webpack.WebpackPluginInstance[];
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { RuleSetRule } from '@rspack/core';
|
|
2
2
|
import { type EntryMapItem, type FlatEvolveOptions } from '../../types/index.js';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* SWC script rules for rspack.
|
|
5
|
+
*
|
|
6
|
+
* Build: transpile all scripts (incl. `node_modules`) for IE11 / ES5 — unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Serve + HMR: React refresh must NOT run on `node_modules` because
|
|
9
|
+
* `@rspack/plugin-react-refresh` excludes them; otherwise SWC injects
|
|
10
|
+
* `$RefreshReg$` without a definition (e.g. `@rspack/core/hot/emitter.js`).
|
|
11
|
+
* Dependencies are still transpiled, just with `refresh: false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const rspackRuleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertSwcImportOptions}from"@flatjs/babel-plugin-import/helpers";import{requireResolve}from"@flatjs/common";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const rspackRuleScripts=(e,
|
|
1
|
+
import{assertSwcImportOptions}from"@flatjs/babel-plugin-import/helpers";import{requireResolve}from"@flatjs/common";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";const scriptTest=/\.(jsx|tsx|ts|js|mjs|cjs|mts|cts)$/,nodeModules=/[\\/]node_modules[\\/]/;export const rspackRuleScripts=(e,s,t)=>{const{loaderOptions:r,projectCwd:o,inspector:a}=t,{modularImports:p=[]}=r,l=assertSwcImportOptions(o,p),n=shouldEnableReactFastRefresh(e,s,t),c=[];c.push([requireResolve(import.meta.url,"@flatjs/swc-plugin-import"),{modularImports:l}]),e&&a&&c.push(["@hyperse/inspector-swc-plugin",{projectCwd:o}]);const createSwcRule=(e,s={})=>({test:scriptTest,...s,use:[{loader:"builtin:swc-loader",options:{isModule:"unknown",jsc:{parser:{decorators:!0,syntax:"typescript",tsx:!0},externalHelpers:!0,experimental:{keepImportAttributes:!0,plugins:[...c]},transform:{legacyDecorator:!0,react:{runtime:"automatic",pragma:"React.createElement",pragmaFrag:"React.Fragment",throwIfNamespace:!0,development:e,refresh:e}}},env:{mode:"entry",targets:{browsers:["ie >= 11","safari > 10"]}}}}]});return e?[createSwcRule(n,{exclude:nodeModules}),createSwcRule(!1,{include:nodeModules})]:[createSwcRule(!1)]};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flatjs/evolve",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,82 +47,83 @@
|
|
|
47
47
|
"@armit/git": "^0.3.0",
|
|
48
48
|
"@armit/package": "^0.3.1",
|
|
49
49
|
"@babel/core": "^7.28.4",
|
|
50
|
-
"@clack/prompts": "^
|
|
51
|
-
"@discoveryjs/json-ext": "
|
|
52
|
-
"@flatjs/babel-plugin-import": "2.
|
|
53
|
-
"@flatjs/common": "2.
|
|
54
|
-
"@flatjs/evolve-preset-babel": "2.
|
|
55
|
-
"@flatjs/forge-postcss-plugin-pixel": "2.
|
|
56
|
-
"@flatjs/forge-ts-checker": "1.
|
|
57
|
-
"@flatjs/graph": "2.
|
|
58
|
-
"@flatjs/mock": "2.
|
|
59
|
-
"@flatjs/swc-plugin-import": "1.0.
|
|
60
|
-
"@hyperse/config-loader": "^1.0.
|
|
61
|
-
"@hyperse/html-webpack-plugin-loader": "^1.0.
|
|
62
|
-
"@hyperse/inspector": "^2.0.
|
|
63
|
-
"@hyperse/inspector-babel-plugin": "^2.0.
|
|
64
|
-
"@hyperse/inspector-common": "^2.0.
|
|
65
|
-
"@hyperse/inspector-middleware": "^2.0.
|
|
66
|
-
"@hyperse/inspector-swc-plugin": "^2.0.
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@rspack
|
|
70
|
-
"@rspack/
|
|
71
|
-
"@rspack/
|
|
72
|
-
"@
|
|
50
|
+
"@clack/prompts": "^1.6.0",
|
|
51
|
+
"@discoveryjs/json-ext": "1.1.0",
|
|
52
|
+
"@flatjs/babel-plugin-import": "2.3.0-next.0",
|
|
53
|
+
"@flatjs/common": "2.3.0-next.0",
|
|
54
|
+
"@flatjs/evolve-preset-babel": "2.3.0-next.0",
|
|
55
|
+
"@flatjs/forge-postcss-plugin-pixel": "2.3.0-next.0",
|
|
56
|
+
"@flatjs/forge-ts-checker": "1.2.0-next.0",
|
|
57
|
+
"@flatjs/graph": "2.3.0-next.0",
|
|
58
|
+
"@flatjs/mock": "2.5.0-next.0",
|
|
59
|
+
"@flatjs/swc-plugin-import": "1.1.0-next.0",
|
|
60
|
+
"@hyperse/config-loader": "^1.0.9",
|
|
61
|
+
"@hyperse/html-webpack-plugin-loader": "^1.0.8",
|
|
62
|
+
"@hyperse/inspector": "^2.0.3",
|
|
63
|
+
"@hyperse/inspector-babel-plugin": "^2.0.3",
|
|
64
|
+
"@hyperse/inspector-common": "^2.0.3",
|
|
65
|
+
"@hyperse/inspector-middleware": "^2.0.3",
|
|
66
|
+
"@hyperse/inspector-swc-plugin": "^2.0.3",
|
|
67
|
+
"@module-federation/runtime-tools": "^2.8.0",
|
|
68
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
|
69
|
+
"@rsdoctor/rspack-plugin": "^1.5.17",
|
|
70
|
+
"@rspack/core": "~2.1.4",
|
|
71
|
+
"@rspack/dev-server": "~2.1.0",
|
|
72
|
+
"@rspack/plugin-react-refresh": "^2.0.2",
|
|
73
|
+
"@swc/helpers": "^0.5.23",
|
|
73
74
|
"@types/babel__core": "^7.20.5",
|
|
74
|
-
"babel-loader": "^10.
|
|
75
|
+
"babel-loader": "^10.1.1",
|
|
75
76
|
"better-opn": "^3.0.2",
|
|
76
77
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
77
|
-
"chokidar": "^
|
|
78
|
-
"ci-info": "^4.
|
|
79
|
-
"css-loader": "^7.1.
|
|
80
|
-
"cssnano": "^
|
|
81
|
-
"express": "^5.1
|
|
78
|
+
"chokidar": "^5.0.0",
|
|
79
|
+
"ci-info": "^4.4.0",
|
|
80
|
+
"css-loader": "^7.1.4",
|
|
81
|
+
"cssnano": "^8.0.2",
|
|
82
|
+
"express": "^5.2.1",
|
|
82
83
|
"fast-glob": "^3.3.3",
|
|
83
84
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
84
|
-
"happy-dom": "^20.
|
|
85
|
-
"html-webpack-plugin": "^5.6.
|
|
86
|
-
"image-minimizer-webpack-plugin": "^
|
|
87
|
-
"less": "^4.
|
|
88
|
-
"less-loader": "^
|
|
85
|
+
"happy-dom": "^20.10.6",
|
|
86
|
+
"html-webpack-plugin": "^5.6.7",
|
|
87
|
+
"image-minimizer-webpack-plugin": "^5.0.0",
|
|
88
|
+
"less": "^4.6.7",
|
|
89
|
+
"less-loader": "^13.0.0",
|
|
89
90
|
"listr": "^0.14.3",
|
|
90
|
-
"lodash": "^4.
|
|
91
|
-
"log-update": "^
|
|
92
|
-
"mini-css-extract-plugin": "^2.
|
|
93
|
-
"postcss": "
|
|
94
|
-
"postcss-loader": "^8.2.
|
|
91
|
+
"lodash": "^4.18.1",
|
|
92
|
+
"log-update": "^8.0.0",
|
|
93
|
+
"mini-css-extract-plugin": "^2.10.2",
|
|
94
|
+
"postcss": "8.5.16",
|
|
95
|
+
"postcss-loader": "^8.2.1",
|
|
95
96
|
"react-refresh": "^0.18.0",
|
|
96
|
-
"svgo": "^4.0.
|
|
97
|
+
"svgo": "^4.0.1",
|
|
97
98
|
"tarjan-graph": "^3.0.0",
|
|
98
|
-
"terser-webpack-plugin": "^5.
|
|
99
|
-
"tinypool": "
|
|
99
|
+
"terser-webpack-plugin": "^5.6.1",
|
|
100
|
+
"tinypool": "2.0.0",
|
|
100
101
|
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
101
|
-
"type-fest": "^
|
|
102
|
-
"typescript": "^
|
|
103
|
-
"webpack": "5.
|
|
104
|
-
"webpack-bundle-analyzer": "^5.1
|
|
105
|
-
"webpack-dev-server": "^5.2.
|
|
106
|
-
"webpack-sources": "^3.
|
|
102
|
+
"type-fest": "^5.7.0",
|
|
103
|
+
"typescript": "^6.0.3",
|
|
104
|
+
"webpack": "5.108.3",
|
|
105
|
+
"webpack-bundle-analyzer": "^5.3.1",
|
|
106
|
+
"webpack-dev-server": "^5.2.5",
|
|
107
|
+
"webpack-sources": "^3.5.0"
|
|
107
108
|
},
|
|
108
109
|
"devDependencies": {
|
|
109
|
-
"@flatjs/testing": "2.
|
|
110
|
-
"@hyperse/eslint-config-hyperse": "^1.
|
|
111
|
-
"@swc/core": "1.15.
|
|
112
|
-
"@types/express": "5.0.
|
|
113
|
-
"@types/listr": "0.14.
|
|
114
|
-
"@types/node": "
|
|
115
|
-
"@types/react": "19.2.
|
|
116
|
-
"
|
|
110
|
+
"@flatjs/testing": "2.3.0-next.0",
|
|
111
|
+
"@hyperse/eslint-config-hyperse": "^1.7.3",
|
|
112
|
+
"@swc/core": "1.15.43",
|
|
113
|
+
"@types/express": "5.0.6",
|
|
114
|
+
"@types/listr": "0.14.10",
|
|
115
|
+
"@types/node": "26.0.1",
|
|
116
|
+
"@types/react": "19.2.17",
|
|
117
|
+
"@types/react-dom": "19.2.3",
|
|
118
|
+
"eslint": "^10.6.0",
|
|
117
119
|
"imagemin-gifsicle": "7.0.0",
|
|
118
120
|
"imagemin-jpegtran": "8.0.0",
|
|
119
121
|
"imagemin-pngquant": "10.0.0",
|
|
120
|
-
"imagemin-svgo": "
|
|
122
|
+
"imagemin-svgo": "12.0.0",
|
|
121
123
|
"npm-run-all": "4.1.5",
|
|
122
|
-
"react": "19.2.
|
|
123
|
-
"rimraf": "6.
|
|
124
|
-
"
|
|
125
|
-
"vitest": "3.2.4",
|
|
124
|
+
"react": "19.2.7",
|
|
125
|
+
"rimraf": "6.1.3",
|
|
126
|
+
"vitest": "4.1.9",
|
|
126
127
|
"vue-loader": "17.4.2"
|
|
127
128
|
},
|
|
128
129
|
"peerDependencies": {
|