@flatjs/evolve 1.8.1-next.29 → 1.8.1-next.31

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.31
4
+
5
+ ### Patch Changes
6
+
7
+ - b318549: Add array chunks & evolve split entryMap into multi chunks
8
+ - Updated dependencies [b318549]
9
+ - @flatjs/common@1.8.1-next.16
10
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.16
11
+ - @flatjs/mock@1.8.1-next.28
12
+ - @flatjs/evolve-preset-babel@1.8.1-next.6
13
+
14
+ ## 1.8.1-next.30
15
+
16
+ ### Patch Changes
17
+
18
+ - af2051d: Add `startStatic` API
19
+ - @flatjs/mock@1.8.1-next.27
20
+
3
21
  ## 1.8.1-next.29
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ import { type EvolveEntryMap } from '../types/types-entry-map.js';
2
+ /**
3
+ * Split entryMap into multi entryMap with a `size`
4
+ * @param entryMap
5
+ * @param size
6
+ */
7
+ export declare const chunkEntryMap: (entryMap: EvolveEntryMap, size?: number) => EvolveEntryMap[];
@@ -0,0 +1 @@
1
+ import{arrayChunk}from"@flatjs/common";export const chunkEntryMap=(r,o=2)=>{const n=Object.keys(r),t=arrayChunk(n,o),c=[];for(const o of t){const n=o.reduce(((o,n)=>({...o,[n]:r[n]})),{});c.push(n)}return c};
@@ -1,5 +1,6 @@
1
1
  export * from './allow-px2rem-for-module.js';
2
2
  export * from './assert-only-single-entry-item.js';
3
+ export * from './chunk-entry-map.js';
3
4
  export * from './enable-bundle-hashname-for-module.js';
4
5
  export * from './get-bundle-file-name.js';
5
6
  export * from './get-html-plugin-config.js';
@@ -1 +1 @@
1
- export*from"./allow-px2rem-for-module.js";export*from"./assert-only-single-entry-item.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./merge-babel-options.js";export*from"./normalize-entry-map.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-multi-compiler.js";
1
+ export*from"./allow-px2rem-for-module.js";export*from"./assert-only-single-entry-item.js";export*from"./chunk-entry-map.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./merge-babel-options.js";export*from"./normalize-entry-map.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-multi-compiler.js";
@@ -1 +1 @@
1
- import{logger,requireResolve}from"@flatjs/common";import{reactBabelPreset,vueBabelPreset}from"@flatjs/evolve-preset-babel";import babelMerge from"babel-merge";import{moduleName}from"../constants.js";export const mergeBabelOption=(e=[],r={usePreset:"react"})=>{const t=e.map((e=>[requireResolve("babel-plugin-import"),{transformToDefaultImport:!1,libraryDirectory:"dist",...e},e.libraryName])),{usePreset:a="react",...l}=r,o="react"===a?reactBabelPreset():"vue"===a?vueBabelPreset():reactBabelPreset();let s={};try{s=babelMerge(o,l),s.plugins?s.plugins.unshift(...t):s.plugins=t}catch(e){logger.error(e,moduleName)}return{...s,babelrc:!1}};
1
+ import{logger,requireResolve}from"@flatjs/common";import{reactBabelPreset,vueBabelPreset}from"@flatjs/evolve-preset-babel";import babelMerge from"babel-merge";import{moduleName}from"../constants.js";export const mergeBabelOption=(e=[],r={usePreset:"react"})=>{const t=e.map((e=>[requireResolve("babel-plugin-import"),{transformToDefaultImport:!1,libraryDirectory:"dist",...e},e.libraryName])),{usePreset:a="react",...l}=r,o="react"===a?reactBabelPreset():"vue"===a?vueBabelPreset():reactBabelPreset();let s={};try{s=babelMerge(o,l),s.plugins?s.plugins.unshift(...t):s.plugins=t}catch(e){logger.error(e,moduleName)}return{...s,babelrc:!1,compact:!1}};
@@ -1 +1 @@
1
- import{ensureSlash,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const startSingleEntryBuild=(r,o)=>{const t=loadWebpackConfig("production",r,o),e=splitToMultiCompilerConfigs(r,t,o);if(e.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=e[0];return new Promise(((r,t)=>{webpack(n,((e,i)=>{if(e)return t(e);const s=i?.toJson();return s?.errors?.length?t(s.errors):o.rejectWarnings&&s?.warnings?.length?t(s.warnings):void r({name:n.name,warningStats:s?.warnings})}))}))};export const prepareBuild=async(r,o,t)=>{await envVerify(r,t);const e=t.multiHtmlCdn?.prod||[];if(!e.length)throw new Error('No CDN configuration for env: "prod"');const n=[],i=ensureSlash(e[Math.floor(Math.random()*e.length)],!0);for(const[r,e]of Object.entries(o)){const o={[r]:e},s=e.options?.useRelativeAssetPath;n.push(startSingleEntryBuild(o,mergeOptions(t,{webpack:{publicPath:s?"auto":i}})))}return Promise.all(n)};
1
+ 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 startSingleEntryBuild=(r,o)=>{const t=loadWebpackConfig("production",r,o),e=splitToMultiCompilerConfigs(r,t,o);if(e.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=e[0];return new Promise(((r,t)=>{webpack(n,((e,i)=>{if(e)return t(e);const s=i?.toJson();return s?.errors?.length?t(s.errors):o.rejectWarnings&&s?.warnings?.length?t(s.warnings):void r({name:n.name,warningStats:s?.warnings})}))}))};export const prepareBuild=async(r,o,t)=>{await envVerify(r,t);const e=t.multiHtmlCdn?.prod||[];if(!e.length)throw new Error('No CDN configuration for env: "prod"');const n=ensureSlash(e[Math.floor(Math.random()*e.length)],!0),i=[],s=chunkEntryMap(o);for(const r of s){logger.info(`build task: ${JSON.stringify(Object.keys(r))}`,moduleName);const o=[];for(const[e,i]of Object.entries(r)){const r={[e]:i},s=i.options?.useRelativeAssetPath;o.push(startSingleEntryBuild(r,mergeOptions(t,{webpack:{publicPath:s?"auto":n}})))}const e=await Promise.all(o);i.push(...e)}return i};
@@ -4,4 +4,4 @@ import { type FlatEvolveOptions } from '../types/index.js';
4
4
  * @param projectCwd The Root directory (workspace) of this project.
5
5
  * @param evolveOptions FlatEvolveOptions
6
6
  */
7
- export declare const prepareStatic: (evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express>;
7
+ export declare const prepareStatic: (projectCwd: string, evolveOptions: FlatEvolveOptions) => Promise<void>;
@@ -1 +1 @@
1
- import{chalk,logger,urlJoin}from"@flatjs/common";import{createDevServer}from"../dev-server/create-dev-server.js";export const prepareStatic=async e=>createDevServer(e).then((({app:e,devHostUri:r})=>{const t=urlJoin(r,["/pages"]);return logger.info(`${"static page".padEnd(12," ")} ➩ ${chalk(["cyan"])(t)}`),e}));
1
+ import{chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute}from"../dev-server/create-app-page-route.js";import{createDevServer}from"../dev-server/create-dev-server.js";import{openPage}from"../helpers/open-page.js";export const prepareStatic=async(e,r)=>{const{app:a,devHostUri:o}=await createDevServer(r);attachMockMiddlewares(a,{...r.devServer?.mockOptions,projectCwd:e}),createAppPageRoute(e,a,o,{},r);const t=urlJoin(o,["/pages"]);r.devServer?.autoOpen&&openPage(t),logger.info(`${"static page".padEnd(12," ")} ➩ ${chalk(["cyan"])(t)}`)};
@@ -7,4 +7,4 @@ import { type FlatEvolveOptions } from '../types/types-options.js';
7
7
  * @param evolveOptions FlatEvolveOptions
8
8
  * @param configLoaderOptions FlatMockOptions
9
9
  */
10
- export declare const startStatic: (projectCwd: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions) => Promise<import("express-serve-static-core").Express>;
10
+ export declare const startStatic: (projectCwd: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions) => Promise<void>;
@@ -1 +1 @@
1
- import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,t={},a)=>{const r=await loadEvolveConfig({command:"static"},o,t,a);return prepareStatic(r)};
1
+ import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,t={},a)=>{const r=await loadEvolveConfig({command:"static"},o,t,a);return prepareStatic(o,r)};
@@ -34,7 +34,7 @@ export type FlatEvolveDevServerOptions = {
34
34
  /**
35
35
  * Allow us costomized global serve data injected into `window.GLOBAL = {...globalData}`
36
36
  */
37
- defaultServeGlobalData?: (entryItem: EvolveEntryMapContent, hostUrl: string) => Promise<Record<string, unknown>>;
37
+ defaultServeGlobalData?: (entryItem: EvolveEntryMapContent, hostUrl: string) => Promise<Record<string, unknown>> | Record<string, unknown>;
38
38
  /**
39
39
  * The value indicates if we will auto open broswers page for `serve`
40
40
  * @default true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.29",
3
+ "version": "1.8.1-next.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,7 +25,7 @@
25
25
  "build": "rimraf dist && tsc -p ./tsconfig.build.json && npm run minify",
26
26
  "?build-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
27
27
  "build-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
28
- "minify": "ts-node ../../scripts/minify.ts --dest=dist",
28
+ "minify": "node ../../scripts/minify.mjs --dest=dist",
29
29
  "codegen": "graphql-codegen --config ./codegen.cjs",
30
30
  "clean": "rimraf --no-glob ./dist ./coverage ./__data__ ./config/__data__ ./_release ./tsconfig.tsbuildinfo",
31
31
  "lint": "eslint . --ext .ts,.mts,.tsx,.js,.jsx,.cjs,.mjs --cache --cache-location ../../.cache/eslint/evolve.eslintcache",
@@ -40,10 +40,10 @@
40
40
  "@armit/file-utility": "^0.0.19",
41
41
  "@armit/package": "^0.0.29",
42
42
  "@babel/core": "7.21.8",
43
- "@flatjs/common": "1.8.1-next.15",
43
+ "@flatjs/common": "1.8.1-next.16",
44
44
  "@flatjs/evolve-preset-babel": "1.8.1-next.6",
45
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.15",
46
- "@flatjs/mock": "1.8.1-next.26",
45
+ "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.16",
46
+ "@flatjs/mock": "1.8.1-next.28",
47
47
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
48
48
  "@types/babel__core": "7.20.0",
49
49
  "babel-loader": "9.1.2",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@armit/eslint-config-bases": "^0.0.16",
78
- "@flatjs/testing": "1.8.1-next.12",
78
+ "@flatjs/testing": "1.8.1-next.13",
79
79
  "@swc/core": "1.3.59",
80
80
  "@types/express": "4.17.17",
81
81
  "@types/node": "20.2.3",