@flatjs/evolve 1.8.1-next.33 → 1.8.1-next.34

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.34
4
+
5
+ ### Patch Changes
6
+
7
+ - 51339d5: add `tsconfig-paths` & `extensionAlias`
8
+
3
9
  ## 1.8.1-next.33
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";import{moduleName}from"../constants.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{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";export const createPlugins=(e,n,r)=>{const[t,s]=n,a=enableBundleHashNameForModule(r,s?.options),l=[new CaseSensitivePathsPlugin,new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,a)}`,chunkFilename:"[id].[contenthash].css"}),...createCleanWebpackPlugin(e,n,r),...createModuleFederationPlugin(e,n,r),...createHtmlPlugins(e,n,r)],{analyzer:i,loaderOptions:o,webpack:c}=r,u=n[1].entry||[],m=u.find((e=>/.vue$/.test(e)));if(o.runTsChecker&&!m){const n=u.reduce(((e,n)=>{const r=/\.(?:ts|tsx|js|jsx)$/.test(n)?[n]:[".ts",".tsx","jsx",".js"].map((e=>n+e));return e.concat(r)}),[]);logger.debug(`ForkTsCheckerWebpackPlugin: include: ${JSON.stringify(n)}`,moduleName),l.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:r.projectCwd,memoryLimit:8192,configOverwrite:{include:[...n,"./*.d.ts"]}}}))}i&&l.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...i}));const p=shouldEnableReactFastRefresh(e,n,r);p&&l.push(new ReactRefreshWebpackPlugin({overlay:!1})),!p&&e&&logger.warn(`The HMR has disabled cause of ("${t}":"moduleFederation")`);const d=c?.plugins||[];return l.concat(d)};
1
+ import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";import{moduleName}from"../constants.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{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";export const createPlugins=(e,n,r)=>{const[t,a]=n,s=enableBundleHashNameForModule(r,a?.options),l=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,s)}`,chunkFilename:"[id].[contenthash].css"}),...createCleanWebpackPlugin(e,n,r),...createModuleFederationPlugin(e,n,r),...createHtmlPlugins(e,n,r)],{analyzer:i,loaderOptions:o}=r,c=n[1].entry||[],u=c.find((e=>/.vue$/.test(e)));if(o.runTsChecker&&!u){const n=c.reduce(((e,n)=>{const r=/\.(?:ts|tsx|js|jsx)$/.test(n)?[n]:[".ts",".tsx","jsx",".js"].map((e=>n+e));return e.concat(r)}),[]);logger.debug(`ForkTsCheckerWebpackPlugin: include: ${JSON.stringify(n)}`,moduleName),l.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:r.projectCwd,memoryLimit:8192,configOverwrite:{include:[...n,"./*.d.ts"]}}}))}i&&l.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...i}));const m=shouldEnableReactFastRefresh(e,n,r);m&&l.push(new ReactRefreshWebpackPlugin({overlay:!1})),!m&&e&&logger.warn(`The HMR has disabled cause of ("${t}":"moduleFederation")`);const p=r.webpack?.plugins||[];return l.concat(p)};
@@ -1,2 +1,2 @@
1
1
  import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
2
- export declare const createResolve: (webpackOptions?: FlatEvolveWebpackOptions) => import("webpack").ResolveOptions;
2
+ export declare const createResolve: (projectCwd: string, webpackOptions?: FlatEvolveWebpackOptions) => import("webpack").ResolveOptions;
@@ -1 +1 @@
1
- import{mergeOptions}from"@flatjs/common";export const createResolve=e=>mergeOptions({mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".json",".vue"]},e?.resolve||{});
1
+ import{join}from"node:path";import{mergeOptions}from"@flatjs/common";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";export const createResolve=(s,o)=>{const n={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js"]})]};return mergeOptions(n,o?.resolve||{})};
@@ -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=(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:createPlugins(a,i,r),watchOptions:c,context:o,target:s?.target??["web","es5"],resolve:createResolve(s),module:{rules:m},devtool:a?"eval-source-map":s?.sourceMap||!1,externals:createExternals(s?.externals,i),output:createOutput(a,r),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,s),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=(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:createPlugins(a,i,r),watchOptions:c,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),output:createOutput(a,r),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,s),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
@@ -1 +1 @@
1
- import{cpus}from"node:os";import{ensureSlash,logger,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{moduleName}from"../constants.js";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{chunkEntryMap}from"../helpers/chunk-entry-map.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const getMaxProcessTasks=(e,r)=>Math.max(1,"string"==typeof r&&r.endsWith("%")?Math.round(cpus().length*Number(r.slice(0,-1))/100):Number(r)||e),startSingleEntryBuild=(e,r)=>{const t=loadWebpackConfig("production",e,r),o=splitToMultiCompilerConfigs(e,t,r);if(o.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=o[0];return new Promise(((e,t)=>{webpack(n,((o,s)=>{if(o)return t(o);const i=s?.toJson();return i?.errors?.length?t(i.errors):r.rejectWarnings&&i?.warnings?.length?t(i.warnings):void e({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(e,r,t)=>{await envVerify(e,t);const o=t.multiHtmlCdn?.prod||[];if(!o.length)throw new Error('No CDN configuration for env: "prod"');const n=ensureSlash(o[Math.floor(Math.random()*o.length)],!0),s=[],i=chunkEntryMap(r,(a=Object.keys(r).length,l=t.maxProcesses,Math.max(1,"string"==typeof l&&l.endsWith("%")?Math.round(cpus().length*Number(l.slice(0,-1))/100):Number(l)||a)));var a,l;for(const e of i){logger.info({buildEntries:Object.keys(e)},moduleName);const r=[];for(const[o,s]of Object.entries(e)){const e={[o]:s},i=s.options?.useRelativeAssetPath;r.push(startSingleEntryBuild(e,mergeOptions(t,{webpack:{publicPath:i?"auto":n}})))}const o=await Promise.all(r);s.push(...o)}return s};
1
+ import{cpus}from"node:os";import{chalk,ensureSlash,logger,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{moduleName}from"../constants.js";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{chunkEntryMap}from"../helpers/chunk-entry-map.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const getMaxProcessTasks=(t,e)=>Math.max(1,"string"==typeof e&&e.endsWith("%")?Math.round(cpus().length*Number(e.slice(0,-1))/100):Number(e)||t),startSingleEntryBuild=(t,e)=>{const r=loadWebpackConfig("production",t,e),o=splitToMultiCompilerConfigs(t,r,e);if(o.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=o[0];return new Promise(((t,r)=>{webpack(n,((o,s)=>{if(o)return r(o);const i=s?.toJson();return i?.errors?.length?r(i.errors):e.rejectWarnings&&i?.warnings?.length?r(i.warnings):void t({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(t,e,r)=>{await envVerify(t,r);const o=r.multiHtmlCdn?.prod||[];if(!o.length)throw new Error('No CDN configuration for env: "prod"');const n=ensureSlash(o[Math.floor(Math.random()*o.length)],!0),s=[],i=chunkEntryMap(e,(a=Object.keys(e).length,l=r.maxProcesses,Math.max(1,"string"==typeof l&&l.endsWith("%")?Math.round(cpus().length*Number(l.slice(0,-1))/100):Number(l)||a)));var a,l;for(const t of i){logger.info(`Build task processing...\n ${chalk(["magenta"])(JSON.stringify(Object.keys(t),null,2))}`,moduleName);const e=[];for(const[o,s]of Object.entries(t)){const t={[o]:s},i=s.options?.useRelativeAssetPath;e.push(startSingleEntryBuild(t,mergeOptions(r,{webpack:{publicPath:i?"auto":n}})))}const o=await Promise.all(e);s.push(...o)}return s};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.33",
3
+ "version": "1.8.1-next.34",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -67,6 +67,7 @@
67
67
  "react-refresh": "0.14.0",
68
68
  "svgo": "3.0.2",
69
69
  "terser-webpack-plugin": "5.3.9",
70
+ "tsconfig-paths-webpack-plugin": "4.0.1",
70
71
  "type-fest": "^3.11.0",
71
72
  "webpack": "5.83.1",
72
73
  "webpack-bundle-analyzer": "4.8.0",