From 5c40dc932822c8e9ea2ba78cff473bac9fc00437 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 25 Apr 2024 17:15:12 +0800 Subject: [PATCH 01/10] fix: do not remove request config of dataLoader compilation (#6869) --- .changeset/odd-crews-sing.md | 5 +++++ examples/with-request/src/app.tsx | 2 +- packages/ice/src/bundler/rspack/getConfig.ts | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-crews-sing.md diff --git a/.changeset/odd-crews-sing.md b/.changeset/odd-crews-sing.md new file mode 100644 index 0000000000..1577994cce --- /dev/null +++ b/.changeset/odd-crews-sing.md @@ -0,0 +1,5 @@ +--- +'@ice/app': patch +--- + +fix: do not remove request config of dataLoader compilation in speedup mode diff --git a/examples/with-request/src/app.tsx b/examples/with-request/src/app.tsx index c95d85f2b6..a8c0f7a935 100644 --- a/examples/with-request/src/app.tsx +++ b/examples/with-request/src/app.tsx @@ -1,7 +1,7 @@ import { request as requestAPI, defineDataLoader } from 'ice'; import { defineRequestConfig } from '@ice/plugin-request/types'; -export const dataLader = defineDataLoader(async () => { +export const dataLoader = defineDataLoader(async () => { try { return await requestAPI('/user'); } catch (err) { diff --git a/packages/ice/src/bundler/rspack/getConfig.ts b/packages/ice/src/bundler/rspack/getConfig.ts index 955f9a5b0d..a6d5283a64 100644 --- a/packages/ice/src/bundler/rspack/getConfig.ts +++ b/packages/ice/src/bundler/rspack/getConfig.ts @@ -14,6 +14,7 @@ import { import { getReCompilePlugin, getServerPlugin, getSpinnerPlugin } from '../config/plugins.js'; import { getExpandedEnvs } from '../../utils/runtimeEnv.js'; import type { BundlerOptions, Context } from '../types.js'; +import type { PluginData } from '../../types/plugin.js'; type GetConfig = ( context: Context, @@ -94,9 +95,17 @@ export const getDataLoaderConfig: GetDataLoaderRspackConfig = async (context, ta extendsPluginAPI: { generator, }, + getAllPlugin, } = context; const { config } = task; const frameworkExports = generator.getExportList('framework', config.target); + const plugins = getAllPlugin(['keepExports']) as PluginData[]; + let keepExports = ['dataLoader']; + plugins.forEach(plugin => { + if (plugin.keepExports) { + keepExports = keepExports.concat(plugin.keepExports); + } + }); return await getRspackConfig({ rootDir, rspack, @@ -115,7 +124,7 @@ export const getDataLoaderConfig: GetDataLoaderRspackConfig = async (context, ta 'data-loader': path.join(rootDir, RUNTIME_TMP_DIR, 'data-loader.ts'), }, swcOptions: { - keepExports: ['dataLoader'], + keepExports, }, splitChunks: false, redirectImports: frameworkExports, From 8dada9b6cda834266b0065a5f6f27793de6e9797 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Mon, 6 May 2024 09:56:22 +0800 Subject: [PATCH 02/10] Feat: plugin for intl (#6863) * feat: plugin for intl * chore: readme * chore: changelog * Update runtime.tsx * Update README.md * feat: support intl in server --- .changeset/brave-actors-suffer.md | 5 ++ examples/with-intl/.browserslistrc | 1 + examples/with-intl/ice.config.mts | 6 ++ examples/with-intl/package.json | 23 ++++++ examples/with-intl/public/favicon.ico | Bin 0 -> 2719 bytes examples/with-intl/src/app.tsx | 8 ++ examples/with-intl/src/document.tsx | 22 ++++++ examples/with-intl/src/global.css | 3 + examples/with-intl/src/locales/en-US.ts | 3 + examples/with-intl/src/locales/zh-CN.json | 3 + examples/with-intl/src/pages/index.tsx | 10 +++ examples/with-intl/src/typings.d.ts | 1 + examples/with-intl/tsconfig.json | 32 ++++++++ packages/ice/src/createService.ts | 9 ++- packages/ice/src/service/runtimeGenerator.ts | 2 +- packages/ice/src/types/plugin.ts | 2 +- .../ice/templates/core/entry.server.ts.ejs | 2 + packages/plugin-intl/CHANGELOG.md | 5 ++ packages/plugin-intl/README.md | 73 ++++++++++++++++++ packages/plugin-intl/package.json | 42 ++++++++++ packages/plugin-intl/runtime.d.ts | 1 + packages/plugin-intl/src/index.ts | 73 ++++++++++++++++++ packages/plugin-intl/src/runtime.tsx | 52 +++++++++++++ packages/plugin-intl/src/types.ts | 7 ++ packages/plugin-intl/templates/locales.ts.ejs | 13 ++++ packages/plugin-intl/tsconfig.json | 11 +++ packages/plugin-intl/types.d.ts | 1 + pnpm-lock.yaml | 58 ++++++++++++-- 28 files changed, 459 insertions(+), 9 deletions(-) create mode 100644 .changeset/brave-actors-suffer.md create mode 100644 examples/with-intl/.browserslistrc create mode 100644 examples/with-intl/ice.config.mts create mode 100644 examples/with-intl/package.json create mode 100644 examples/with-intl/public/favicon.ico create mode 100644 examples/with-intl/src/app.tsx create mode 100644 examples/with-intl/src/document.tsx create mode 100644 examples/with-intl/src/global.css create mode 100644 examples/with-intl/src/locales/en-US.ts create mode 100644 examples/with-intl/src/locales/zh-CN.json create mode 100644 examples/with-intl/src/pages/index.tsx create mode 100644 examples/with-intl/src/typings.d.ts create mode 100644 examples/with-intl/tsconfig.json create mode 100644 packages/plugin-intl/CHANGELOG.md create mode 100644 packages/plugin-intl/README.md create mode 100644 packages/plugin-intl/package.json create mode 100644 packages/plugin-intl/runtime.d.ts create mode 100644 packages/plugin-intl/src/index.ts create mode 100644 packages/plugin-intl/src/runtime.tsx create mode 100644 packages/plugin-intl/src/types.ts create mode 100644 packages/plugin-intl/templates/locales.ts.ejs create mode 100644 packages/plugin-intl/tsconfig.json create mode 100644 packages/plugin-intl/types.d.ts diff --git a/.changeset/brave-actors-suffer.md b/.changeset/brave-actors-suffer.md new file mode 100644 index 0000000000..32f4d54d0f --- /dev/null +++ b/.changeset/brave-actors-suffer.md @@ -0,0 +1,5 @@ +--- +'@ice/app': patch +--- + +feat: support generator api to inject code in server entry diff --git a/examples/with-intl/.browserslistrc b/examples/with-intl/.browserslistrc new file mode 100644 index 0000000000..7637baddc3 --- /dev/null +++ b/examples/with-intl/.browserslistrc @@ -0,0 +1 @@ +chrome 55 \ No newline at end of file diff --git a/examples/with-intl/ice.config.mts b/examples/with-intl/ice.config.mts new file mode 100644 index 0000000000..f721ecc97b --- /dev/null +++ b/examples/with-intl/ice.config.mts @@ -0,0 +1,6 @@ +import { defineConfig } from '@ice/app'; +import intl from '@ice/plugin-intl'; + +export default defineConfig(() => ({ + plugins: [intl()], +})); diff --git a/examples/with-intl/package.json b/examples/with-intl/package.json new file mode 100644 index 0000000000..b54a99d39a --- /dev/null +++ b/examples/with-intl/package.json @@ -0,0 +1,23 @@ +{ + "name": "@examples/with-intl", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "ice start", + "build": "ice build" + }, + "description": "", + "author": "", + "license": "MIT", + "dependencies": { + "@ice/app": "workspace:*", + "@ice/plugin-intl": "workspace:*", + "@ice/runtime": "workspace:*", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.2" + } +} diff --git a/examples/with-intl/public/favicon.ico b/examples/with-intl/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a2605c57e9d85aabd689ff5c565286dee148ab6d GIT binary patch literal 2719 zcmbVO`8yMiA9svQv58DRxk@YN91}_`b4{U4xk7!C`zZN1)+bw`g+vn_YM5h6q=V&5 zY&mjF?i^!|S(r95*X&b&!uR`np7;CpJg?XDeqPV>{^^x+*4bW0T3K2|L_`MVVB`9m z^Z$&LFJVfVn*0@o`Uz6v;qRJkbcT zDz0Q12lTZ%`ghogFZaE+CzC-?b?9FC>?D|Pkd}eIbR7dOXL}DpS5J}aua3Bq7}H>3 z8Og;>eXE)t$2j*0A8+@``?d@C5+r!O_l|zaGtfJqEVzm*-TcP@xe{qr(<>BvWYfnOA_I+w&Y*YLR6D?M(%fv^^ylDNyqy>P1;<>wK^T+^*ewX1F*_vqxLT{VuTwPl_xOnH+!=f&y+_wjGs5N)( zIwZ0G zVGDjn#KgnB&u8q{TCQ(JV{CoGszvgBKP2U=F>)r@Dd4e=_(ruDP;4@M8F1kb3KIcNh8el;^6SjxPb7UgHpr7VfQ{=QKLXR9T}an41j9LX(*&x z-s#Okyn>i7`hll*yEa0SH(77uC0SJod(1wZCZLG$IX8 zgg3YePH-pHznZz=(oROkAeRf08LlBU$+*P0OW%>UC7k&8KMHpwmfDk`%76o_!Ai5Q zv)lzh<8xj&BbK%Y*OQ66ME|)KPtGM~9a&2KcW&o<8==OD`^n_3dOjy-R&Dl$5-+l* zJk2a{$R7I*qYCI3d|S*C82Dj`%fgc&G38RV+WC_$Yb{Uz={03hE-uD{=}iJUvPZc@ zt@}G;<>y$*@SltoJE~focFsZ_%Vbscb&wTfMg7u*ewX*sdAFmh*0k%&US4YBUcE7I zS*M!n8G80JPMI?e(Kh;8I!0u|uubOc~y^z<%yrpt0`9F!ItogT=I31$ZGr>Mw-+qHLv=|9sm zqSffY$EJ3d$F3s{wZ^iI$ORCwgCovV*z7IJR_1c20|(Pu``hy5BR9x; zj`h)HANSU`uiHrH1al^C++E+4k-F#40F8fOzDsC(0Xs_TfF_ULf!|_ydeL)|a1Jro z`}oH|*+3cJgt{U(L5hV1`U2z}RHY)-m_|6j3|=SDC%ammwfd@xib@hygHkVx9b`lO z?$3^18)@?D*+AOx0ZjHT`-U6{Gw5FzvfmkN3 z>iM1+Vy@*`o~eUlNbT~YRw;AfVZk*Rzhw{rfS>9?r{1t{Jz0+mb{haKPbYZv5|eNn z{VNt9&hCNNqdZGqsVPQ278pp2rceA9wQu#Hu@5G@9)y1mxhlAJgx^x41b|O)>(hC6 zxd+|P4EGtQlBdYei{4G+%Yjm*!k3gG4k^VNrm%6MB+4qxbr8fSZ)yPg8T}_ZJT+IP zPp>P*QW*+sNU72cez@>5*Y{~{N`ykK-2%RGGE`#c5`~cR(bxhgHm7@CaT!_8+Mjy; zHnG=2&MHd)7E?Cz8+Avg7#vT&{UEqr*A$6pnRzmfOtWn~ryvDmrNp@=;|j;Q`*Pf~ z0wA-DHO_2Rx{kE?x=eA}-pcZLRF1s-8H3LN$F?iILXGiax~+Tq(*AT!Z$j3GqT~QM zDJ`F4Bhc|j5w71Oqzj^ZTcN0e;k$t-6jDX82_cvM&yKe5hu z{TF*|*%zp_PJCQ=e=%NMFhSpL9&+)wS_~GOdp1WOv0%r%V44FAam3hgp7A%Eqw9j7 zIXBU3EgbRndo#+!1Zz8t$)d)OHLuyV&l1PAn?smen<&|-$OZu2@8QTn+MFr)m3y5- zfPE&Ulh$|uf)x((@(gCxmst)n0lNsHVHV1vQ#pvcm1a`CF zS@fp^M4vE;eKx|G*CXdsmp&Wt1mx%QJo>M(<&}@+-#Hn(j8=1Slj$Qe+2o-f9!SL> zEHKc%kW6BqCu-JR%k3tZRt?x>Bi-k>>pFEKlwy7na65EDm3*q_CZ5vQlsF&RSHHAk zHG23^LvvqA)%5Kw(48PmI=s$K?gnb-%=m$(j$Z$1A5lTUkx;d$vpI=C9~KSm?z_~c z#SXvKTSJ~$>E(6?fHXpHU_&wdoa3=(dgo@B&oO~(nr*w#-l#{yhr6ZiG zDK@Pu;rBB-zUnG5K`1`LFFgGPx93J zo=uIxw8w{%Ah89CE zG%Z{%x-c=Q%W~)VcuxU+8@pZ@!$84eF)sG~iycG%+E-hae$E0JnM{rKv6SObgAvd= zaAXfwR)*@t?uUq zrv8D1TZTqxkCAXZq(WAY7Ogs8eUtXYJ4IS4%)&D|9^+Qd3!h**T4=;BlDsFb@~YaS zs8Ks~*8$jS{|`e^1EWtdZ4QHH1}etRcJfqc7dId05z9J`2!%ttHP;`wI>YxHjW8Z1 ztxy7L7%x$L(!+>)q|FupVfw;o&5+IA4Oi_6Kadib+iKTi>Ozfzo9y&%QVVV literal 0 HcmV?d00001 diff --git a/examples/with-intl/src/app.tsx b/examples/with-intl/src/app.tsx new file mode 100644 index 0000000000..b5373fa689 --- /dev/null +++ b/examples/with-intl/src/app.tsx @@ -0,0 +1,8 @@ +import { defineAppConfig } from 'ice'; +import type { LocaleConfig } from '@ice/plugin-intl/types'; + +export default defineAppConfig(() => ({})); + +export const locale: LocaleConfig = { + getLocale: () => 'en-US', +}; diff --git a/examples/with-intl/src/document.tsx b/examples/with-intl/src/document.tsx new file mode 100644 index 0000000000..1e7b99c49d --- /dev/null +++ b/examples/with-intl/src/document.tsx @@ -0,0 +1,22 @@ +import { Meta, Title, Links, Main, Scripts } from 'ice'; + +function Document() { + return ( + + + + + + + + <Links /> + </head> + <body> + <Main /> + <Scripts /> + </body> + </html> + ); +} + +export default Document; diff --git a/examples/with-intl/src/global.css b/examples/with-intl/src/global.css new file mode 100644 index 0000000000..604282adc9 --- /dev/null +++ b/examples/with-intl/src/global.css @@ -0,0 +1,3 @@ +body { + font-size: 14px; +} diff --git a/examples/with-intl/src/locales/en-US.ts b/examples/with-intl/src/locales/en-US.ts new file mode 100644 index 0000000000..4e07843c44 --- /dev/null +++ b/examples/with-intl/src/locales/en-US.ts @@ -0,0 +1,3 @@ +export default { + new: 'New', +}; diff --git a/examples/with-intl/src/locales/zh-CN.json b/examples/with-intl/src/locales/zh-CN.json new file mode 100644 index 0000000000..05912a29f6 --- /dev/null +++ b/examples/with-intl/src/locales/zh-CN.json @@ -0,0 +1,3 @@ +{ + "new": "新建" +} diff --git a/examples/with-intl/src/pages/index.tsx b/examples/with-intl/src/pages/index.tsx new file mode 100644 index 0000000000..3d40c8df36 --- /dev/null +++ b/examples/with-intl/src/pages/index.tsx @@ -0,0 +1,10 @@ +import { intl } from 'ice'; + +export default function Home() { + return ( + <> + <h1>home</h1> + <button>{intl.formatMessage({ id: 'new' })}</button> + </> + ); +} diff --git a/examples/with-intl/src/typings.d.ts b/examples/with-intl/src/typings.d.ts new file mode 100644 index 0000000000..1f6ba4ffa6 --- /dev/null +++ b/examples/with-intl/src/typings.d.ts @@ -0,0 +1 @@ +/// <reference types="@ice/app/types" /> diff --git a/examples/with-intl/tsconfig.json b/examples/with-intl/tsconfig.json new file mode 100644 index 0000000000..26fd9ec799 --- /dev/null +++ b/examples/with-intl/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compileOnSave": false, + "buildOnSave": false, + "compilerOptions": { + "baseUrl": ".", + "outDir": "build", + "module": "esnext", + "target": "es6", + "jsx": "react-jsx", + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "lib": ["es6", "dom"], + "sourceMap": true, + "allowJs": true, + "rootDir": "./", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noImplicitAny": false, + "importHelpers": true, + "strictNullChecks": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "skipLibCheck": true, + "paths": { + "@/*": ["./src/*"], + "ice": [".ice"] + } + }, + "include": ["src", ".ice", "ice.config.*"], + "exclude": ["build", "public"] +} \ No newline at end of file diff --git a/packages/ice/src/createService.ts b/packages/ice/src/createService.ts index b440de2976..5a434aa20f 100644 --- a/packages/ice/src/createService.ts +++ b/packages/ice/src/createService.ts @@ -93,8 +93,13 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt addEntryCode: (callback: (originalCode: string) => string) => { entryCode = callback(entryCode); }, - addEntryImportAhead: (declarationData: Pick<DeclarationData, 'source'>) => { - generator.addDeclaration('entry', declarationData); + addEntryImportAhead: (declarationData: Pick<DeclarationData, 'source'>, type = 'client') => { + if (type === 'both' || type === 'server') { + generator.addDeclaration('entryServer', declarationData); + } + if (type === 'both' || type === 'client') { + generator.addDeclaration('entry', declarationData); + } }, modifyRenderData: generator.modifyRenderData, addDataLoaderImport: (declarationData: DeclarationData) => { diff --git a/packages/ice/src/service/runtimeGenerator.ts b/packages/ice/src/service/runtimeGenerator.ts index d9c39cb070..e115b1bb11 100644 --- a/packages/ice/src/service/runtimeGenerator.ts +++ b/packages/ice/src/service/runtimeGenerator.ts @@ -141,7 +141,7 @@ export default class Generator { this.rerender = false; this.renderTemplates = []; this.renderDataRegistration = []; - this.contentTypes = ['framework', 'frameworkTypes', 'routeConfigTypes', 'dataLoaderImport', 'runtimeOptions', 'entry']; + this.contentTypes = ['framework', 'frameworkTypes', 'routeConfigTypes', 'dataLoaderImport', 'runtimeOptions', 'entry', 'entryServer']; // empty .ice before render fse.emptyDirSync(path.join(rootDir, targetDir)); // add initial templates diff --git a/packages/ice/src/types/plugin.ts b/packages/ice/src/types/plugin.ts index cd19b013f2..7043b36ad2 100644 --- a/packages/ice/src/types/plugin.ts +++ b/packages/ice/src/types/plugin.ts @@ -13,7 +13,7 @@ export type { CreateLoggerReturnType } from '../utils/logger.js'; type AddExport = (exportData: DeclarationData) => void; type AddEntryCode = (callback: (code: string) => string) => void; -type AddEntryImportAhead = (exportData: Pick<DeclarationData, 'source'>) => void; +type AddEntryImportAhead = (exportData: Pick<DeclarationData, 'source'>, type?: string) => void; type RemoveExport = (removeSource: string | string[]) => void; type EventName = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'; type GetExportList = (key: string, target?: string) => DeclarationData[]; diff --git a/packages/ice/templates/core/entry.server.ts.ejs b/packages/ice/templates/core/entry.server.ts.ejs index eb62643ce8..f0535b214e 100644 --- a/packages/ice/templates/core/entry.server.ts.ejs +++ b/packages/ice/templates/core/entry.server.ts.ejs @@ -1,4 +1,5 @@ import './env.server'; +<%- entryServer.imports %> import * as runtime from '@ice/runtime/server'; <% if (hydrate) {-%> import { commons, statics } from './runtime-modules'; @@ -21,6 +22,7 @@ import routesManifest from './route-manifest.json'; import routesConfig from './routes-config.bundle.mjs'; <% if (dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%> <% if (hydrate) {-%><%- runtimeOptions.imports %><% } -%> + <% if (!hydrate) {-%> // Do not inject runtime modules when render mode is document only. const commons = []; diff --git a/packages/plugin-intl/CHANGELOG.md b/packages/plugin-intl/CHANGELOG.md new file mode 100644 index 0000000000..7e9ae42333 --- /dev/null +++ b/packages/plugin-intl/CHANGELOG.md @@ -0,0 +1,5 @@ +# @ice/plugin-intl + +## 1.0.0 + +- Initial release diff --git a/packages/plugin-intl/README.md b/packages/plugin-intl/README.md new file mode 100644 index 0000000000..ba9e5ea78e --- /dev/null +++ b/packages/plugin-intl/README.md @@ -0,0 +1,73 @@ +# @ice/plugin-intl + +`@ice/plugin-intl` is a ice.js plugin. It provides a simple way to add internationalization support to your application. + +> `@ice/plugin-intl` is based on `react-intl`. + +## Install + +```bash +$ npm i @ice/plugin-intl --save-dev +``` + +## Usage + +Define the plugin in `ice.config.mts`: + +```ts +import { defineConfig } from '@ice/app'; +import intl from '@ice/plugin-intl'; + +export default defineConfig({ + plugins: [ + intl(), + ], +}); +``` + +Define locale config in `src/app.ts`: + +```ts +import { defineAppConfig } from 'ice'; +import type { LocaleConfig } from '@ice/plugin-intl/types'; + +export default defineAppConfig(() => ({})); + +export const locale: LocaleConfig = { + // Cutomize getLocale method and other options supported by react-intl. + getLocale: () => 'en-US', +}; +``` + +## Locales + +Locales are defined in the `src/locales` directory. Each locale is defined in a separate file, with the locale name as the file name. For example, `en-US.ts`: + +```ts +export default { + 'app.title': 'My Application', + 'app.welcome': 'Welcome to my application!', +}; +``` + +Use the `useIntl` hook to access the current locale: + +```tsx +import { useIntl } from 'ice'; + +export default function Home() { + const intl = useIntl(); + console.log(intl.formatMessage({ id: 'new' })); + return <h1>home</h1>; +} +``` + +Use the `intl` function to access the current locale: + +```tsx +import { intl } from 'ice'; + +function alertMessage() { + alert(intl.formatMessage({ id: 'app.welcome' })); +} +``` diff --git a/packages/plugin-intl/package.json b/packages/plugin-intl/package.json new file mode 100644 index 0000000000..f1747c4af1 --- /dev/null +++ b/packages/plugin-intl/package.json @@ -0,0 +1,42 @@ +{ + "name": "@ice/plugin-intl", + "version": "1.0.0", + "description": "react intl plugin for ice.js 3.", + "files": [ + "esm", + "!esm/**/*.map", + "*.d.ts", + "templates" + ], + "type": "module", + "main": "esm/index.js", + "module": "esm/index.js", + "types": "esm/index.d.ts", + "exports": { + ".": "./esm/index.js", + "./runtime": "./esm/runtime.js", + "./types": "./esm/types.js" + }, + "sideEffects": false, + "scripts": { + "watch": "tsc -w --sourceMap", + "build": "tsc" + }, + "dependencies": { + "react-intl": "^6.0.0", + "fast-glob": "^3.3.2" + }, + "devDependencies": { + "@ice/app": "^3.3.2", + "@ice/runtime": "^1.2.9", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0" + }, + "repository": { + "type": "http", + "url": "https://github.com/alibaba/ice/tree/master/packages/plugin-intl" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/plugin-intl/runtime.d.ts b/packages/plugin-intl/runtime.d.ts new file mode 100644 index 0000000000..72417e24df --- /dev/null +++ b/packages/plugin-intl/runtime.d.ts @@ -0,0 +1 @@ +export * from './esm/runtime'; diff --git a/packages/plugin-intl/src/index.ts b/packages/plugin-intl/src/index.ts new file mode 100644 index 0000000000..07625fc719 --- /dev/null +++ b/packages/plugin-intl/src/index.ts @@ -0,0 +1,73 @@ +import * as path from 'path'; +import { fileURLToPath } from 'url'; +import fg from 'fast-glob'; +import type { Plugin } from '@ice/app/types'; + +const _dirname = path.dirname(fileURLToPath(import.meta.url)); + +const plugin: Plugin = () => ({ + name: 'plugin-intl', + setup: ({ generator, context, createLogger, watch }) => { + const { rootDir } = context; + const logger = createLogger('plugin-intl'); + + const renderLocaleEntry = (localeFiles: string[]) => { + const locales = []; + let localeExport = []; + localeFiles.forEach((file) => { + const filename = path.basename(file, path.extname(file)); + // `-` is not allowed in import specifier. + const specifier = filename.replace('-', '_'); + locales.push(`import ${specifier} from '@/locales/${filename}';`); + localeExport.push(`'${filename}': ${specifier},`); + }); + + generator.addRenderFile( + path.join(_dirname, '../templates/locales.ts.ejs'), + 'locales.ts', + { + localeImport: locales.join('\n'), + localeExport: localeExport.join('\n '), + }, + ); + }; + const globRule = 'src/locales/*.{ts,js,json}'; + // Glob all locale files, and generate runtime options. + const localeFiles = fg.sync(globRule, { cwd: rootDir }); + if (localeFiles.length > 0) { + // Filter the entry of locale files. + const mainEntry = localeFiles.find((file) => file.match(/index\.(ts|js|json)$/)); + let runtimeSource = ''; + if (mainEntry) { + runtimeSource = `@/locales/${path.basename(mainEntry)}`; + } else { + // Create a locale entry file to export all locale files. + renderLocaleEntry(localeFiles); + + // Add watch event for locale files added or removed. + watch.addEvent([/src\/locales/, (event) => { + if (event === 'unlink' || event === 'add') { + const files = fg.sync(globRule, { cwd: rootDir }); + renderLocaleEntry(files); + } + }]); + runtimeSource = './locales'; + + generator.addEntryImportAhead({ + source: runtimeSource, + }, 'both'); + } + } else { + logger.warn('No locale files found, please check the `src/locales` folder.'); + } + + // Add intl export from ice. + generator.addExport({ + specifier: ['useIntl', 'intl'], + source: '@ice/plugin-intl/runtime', + }); + }, + runtime: '@ice/plugin-intl/runtime', +}); + +export default plugin; diff --git a/packages/plugin-intl/src/runtime.tsx b/packages/plugin-intl/src/runtime.tsx new file mode 100644 index 0000000000..c940a6970c --- /dev/null +++ b/packages/plugin-intl/src/runtime.tsx @@ -0,0 +1,52 @@ +import * as React from 'react'; +import { createIntl, createIntlCache, RawIntlProvider, useIntl } from 'react-intl'; +import type { IntlShape } from 'react-intl'; +import type { RuntimePlugin } from '@ice/runtime/types'; +import type { LocaleConfig } from './types.js'; + +const EXPORT_NAME = 'locale'; +const cache = createIntlCache(); + +const getDefaultLocale = () => { + return (typeof navigator !== 'undefined' && navigator.language) || 'zh-CN'; +}; + +const getLocaleMessages = () => { + return (typeof window !== 'undefined' + // @ts-ignore + ? window.__ICE_LOCALE_MESSAGES__ + : global.__ICE_LOCALE_MESSAGES__) || {}; +}; + +const defaultLocale = getDefaultLocale(); +let intl: IntlShape = createIntl({ + locale: defaultLocale, + messages: getLocaleMessages()?.[defaultLocale] || {}, +}); + +const runtime: RuntimePlugin = async ({ + addProvider, + appContext, +}) => { + const { appExport } = appContext; + const exported = appExport[EXPORT_NAME]; + const localeConfig: LocaleConfig = (typeof exported === 'function' ? await exported() : exported) || {}; + const { getLocale, ...l } = localeConfig; + const locale = getLocale ? getLocale() : getDefaultLocale(); + + intl = createIntl({ + ...l, + messages: getLocaleMessages()?.[locale] || {}, + locale: getLocale ? getLocale() : getDefaultLocale(), + }, cache); + addProvider(({ children }) => { + return <RawIntlProvider value={intl}>{children}</RawIntlProvider>; + }); +}; + +export { + intl, + useIntl, +}; + +export default runtime; diff --git a/packages/plugin-intl/src/types.ts b/packages/plugin-intl/src/types.ts new file mode 100644 index 0000000000..57f058e32c --- /dev/null +++ b/packages/plugin-intl/src/types.ts @@ -0,0 +1,7 @@ +import type { IntlConfig } from 'react-intl'; + +interface AdditionalConfig { + getLocale: () => string; +} + +export type LocaleConfig = Partial<IntlConfig> & AdditionalConfig; diff --git a/packages/plugin-intl/templates/locales.ts.ejs b/packages/plugin-intl/templates/locales.ts.ejs new file mode 100644 index 0000000000..d75f402aa6 --- /dev/null +++ b/packages/plugin-intl/templates/locales.ts.ejs @@ -0,0 +1,13 @@ +<%- localeImport %> + +const localeMessages = { + <%- localeExport %> +}; +const LOCALE_KEY = '__ICE_LOCALE_MESSAGES__'; +if (typeof window !== 'undefined') { + window[LOCALE_KEY] = localeMessages; +} else { + global[LOCALE_KEY]= localeMessages; +} + +export default localeMessages; diff --git a/packages/plugin-intl/tsconfig.json b/packages/plugin-intl/tsconfig.json new file mode 100644 index 0000000000..ea83b793fe --- /dev/null +++ b/packages/plugin-intl/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "rootDir": "src", + "outDir": "esm", + "module": "ES2020", + "moduleResolution": "NodeNext", + }, + "include": ["src"] +} \ No newline at end of file diff --git a/packages/plugin-intl/types.d.ts b/packages/plugin-intl/types.d.ts new file mode 100644 index 0000000000..8554e6cd41 --- /dev/null +++ b/packages/plugin-intl/types.d.ts @@ -0,0 +1 @@ +export * from './esm/types'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f9ddbb1cd..2c54f49598 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -947,6 +947,31 @@ importers: specifier: ^3.12.1 version: 3.12.3 + examples/with-intl: + dependencies: + '@ice/app': + specifier: workspace:* + version: link:../../packages/ice + '@ice/plugin-intl': + specifier: workspace:* + version: link:../../packages/plugin-intl + '@ice/runtime': + specifier: workspace:* + version: link:../../packages/runtime + react: + specifier: ^18.2.0 + version: 18.2.0 + react-dom: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + devDependencies: + '@types/react': + specifier: ^18.0.0 + version: 18.0.34 + '@types/react-dom': + specifier: ^18.0.2 + version: 18.0.11 + examples/with-jest: dependencies: '@ice/runtime': @@ -2024,6 +2049,28 @@ importers: specifier: ^18.0.0 version: 18.0.11 + packages/plugin-intl: + dependencies: + fast-glob: + specifier: ^3.3.2 + version: 3.3.2 + react-intl: + specifier: ^6.0.0 + version: 6.3.2(react@18.2.0)(typescript@4.9.5) + devDependencies: + '@ice/app': + specifier: ^3.3.2 + version: link:../ice + '@ice/runtime': + specifier: ^1.2.9 + version: link:../runtime + '@types/react': + specifier: ^18.0.0 + version: 18.0.34 + '@types/react-dom': + specifier: ^18.0.0 + version: 18.0.11 + packages/plugin-jsx-plus: dependencies: '@babel/core': @@ -10668,7 +10715,7 @@ packages: commander: 2.20.3 consola: 2.15.3 esbuild: 0.16.17 - fast-glob: 3.3.0 + fast-glob: 3.3.2 fs-extra: 8.1.0 json5: 2.2.3 lodash: 4.17.21 @@ -13456,6 +13503,7 @@ packages: glob-parent: 5.1.2 merge2: 1.4.1 micromatch: 4.0.5 + dev: false /fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} @@ -14079,7 +14127,7 @@ packages: '@types/glob': 7.2.0 array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.3.0 + fast-glob: 3.3.2 glob: 7.2.3 ignore: 5.2.4 merge2: 1.4.1 @@ -14092,7 +14140,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.3.0 + fast-glob: 3.3.2 ignore: 5.2.4 merge2: 1.4.1 slash: 3.0.0 @@ -14103,7 +14151,7 @@ packages: dependencies: array-union: 3.0.1 dir-glob: 3.0.1 - fast-glob: 3.3.0 + fast-glob: 3.3.2 ignore: 5.2.4 merge2: 1.4.1 slash: 4.0.0 @@ -21608,7 +21656,7 @@ packages: css-functions-list: 3.1.0 css-tree: 2.3.1 debug: 4.3.4 - fast-glob: 3.3.0 + fast-glob: 3.3.2 fastest-levenshtein: 1.0.16 file-entry-cache: 6.0.1 global-modules: 2.0.0 From 7bd238ad49dfb667423b37f550a96fa40af6d0d5 Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Mon, 6 May 2024 10:13:14 +0800 Subject: [PATCH 03/10] chore: lint --- packages/plugin-intl/src/runtime.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/plugin-intl/src/runtime.tsx b/packages/plugin-intl/src/runtime.tsx index c940a6970c..60d91400e9 100644 --- a/packages/plugin-intl/src/runtime.tsx +++ b/packages/plugin-intl/src/runtime.tsx @@ -12,10 +12,9 @@ const getDefaultLocale = () => { }; const getLocaleMessages = () => { - return (typeof window !== 'undefined' - // @ts-ignore - ? window.__ICE_LOCALE_MESSAGES__ - : global.__ICE_LOCALE_MESSAGES__) || {}; + // @ts-ignore + const localeMessages = typeof window === 'undefined' ? global.__ICE_LOCALE_MESSAGES__ : window.__ICE_LOCALE_MESSAGES__; + return localeMessages || {}; }; const defaultLocale = getDefaultLocale(); From 11a87dc6e572e74327b34e587d2d28ecb38746b9 Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Mon, 6 May 2024 17:22:33 +0800 Subject: [PATCH 04/10] feat: support split page chunk in cjs format (#6843) * feat: support spilt page chunk in cjs format * fix: escape route path * fix: multipile entry for server compile * chore: changelog --- .changeset/spotty-dodos-drop.md | 5 ++ packages/ice/src/bundler/config/plugins.ts | 8 +++ packages/ice/src/bundler/rspack/getConfig.ts | 4 ++ .../src/bundler/webpack/getWebpackConfig.ts | 3 + packages/ice/src/createService.ts | 16 +++++- packages/ice/src/getWatchEvents.ts | 5 +- packages/ice/src/routes.ts | 22 +++++++- packages/ice/src/types/userConfig.ts | 2 +- packages/ice/src/utils/generateEntry.ts | 8 ++- packages/ice/src/utils/getEntryPoints.ts | 17 ++++++ .../ice/src/utils/getServerCompilerPlugin.ts | 6 +- packages/ice/src/utils/multipleEntry.ts | 56 +++++++++++++++++++ .../ice/templates/core/entry.server.ts.ejs | 2 +- 13 files changed, 143 insertions(+), 11 deletions(-) create mode 100644 .changeset/spotty-dodos-drop.md create mode 100644 packages/ice/src/utils/getEntryPoints.ts create mode 100644 packages/ice/src/utils/multipleEntry.ts diff --git a/.changeset/spotty-dodos-drop.md b/.changeset/spotty-dodos-drop.md new file mode 100644 index 0000000000..e7a0ec498c --- /dev/null +++ b/.changeset/spotty-dodos-drop.md @@ -0,0 +1,5 @@ +--- +'@ice/app': patch +--- + +feat: support spilt page chunk in cjs format diff --git a/packages/ice/src/bundler/config/plugins.ts b/packages/ice/src/bundler/config/plugins.ts index f2ce39d9f9..a17f5410a3 100644 --- a/packages/ice/src/bundler/config/plugins.ts +++ b/packages/ice/src/bundler/config/plugins.ts @@ -2,6 +2,8 @@ import ServerRunnerPlugin from '../../webpack/ServerRunnerPlugin.js'; import { IMPORT_META_RENDERER, IMPORT_META_TARGET, WEB } from '../../constant.js'; import getServerCompilerPlugin from '../../utils/getServerCompilerPlugin.js'; import ReCompilePlugin from '../../webpack/ReCompilePlugin.js'; +import getEntryPoints from '../../utils/getEntryPoints.js'; +import { multipleServerEntry } from '../../utils/multipleEntry.js'; import type ServerRunner from '../../service/ServerRunner'; import type ServerCompileTask from '../../utils/ServerCompileTask.js'; import type { ServerCompiler, UserConfig } from '../../types'; @@ -28,6 +30,8 @@ interface ServerPluginOptions { serverEntry?: string; ensureRoutesConfig: () => Promise<void>; userConfig?: UserConfig; + getFlattenRoutes?: () => string[]; + command?: string; } export const getServerPlugin = ({ serverRunner, @@ -39,6 +43,8 @@ export const getServerPlugin = ({ outputDir, serverCompileTask, userConfig, + getFlattenRoutes, + command, }: ServerPluginOptions) => { if (serverRunner) { return new ServerRunnerPlugin(serverRunner, ensureRoutesConfig); @@ -51,6 +57,8 @@ export const getServerPlugin = ({ serverCompileTask, userConfig, ensureRoutesConfig, + entryPoints: multipleServerEntry(userConfig, command) + ? getEntryPoints(rootDir, getFlattenRoutes(), serverEntry) : undefined, runtimeDefineVars: { [IMPORT_META_TARGET]: JSON.stringify(target), [IMPORT_META_RENDERER]: JSON.stringify('server'), diff --git a/packages/ice/src/bundler/rspack/getConfig.ts b/packages/ice/src/bundler/rspack/getConfig.ts index a6d5283a64..1ca8a848b5 100644 --- a/packages/ice/src/bundler/rspack/getConfig.ts +++ b/packages/ice/src/bundler/rspack/getConfig.ts @@ -35,9 +35,11 @@ const getConfig: GetConfig = async (context, options, rspack) => { const { rootDir, userConfig, + command, extendsPluginAPI: { serverCompileTask, getRoutesFile, + getFlattenRoutes, }, } = context; const { reCompile, ensureRoutesConfig } = getRouteExportConfig(rootDir); @@ -57,6 +59,8 @@ const getConfig: GetConfig = async (context, options, rspack) => { outputDir, serverCompileTask, userConfig, + getFlattenRoutes, + command, }), // Add ReCompile plugin when routes config changed. getReCompilePlugin(reCompile, routeManifest), diff --git a/packages/ice/src/bundler/webpack/getWebpackConfig.ts b/packages/ice/src/bundler/webpack/getWebpackConfig.ts index d45402f19d..c086f9c4b6 100644 --- a/packages/ice/src/bundler/webpack/getWebpackConfig.ts +++ b/packages/ice/src/bundler/webpack/getWebpackConfig.ts @@ -59,6 +59,7 @@ const getWebpackConfig: GetWebpackConfig = async (context, options) => { configFilePath, extendsPluginAPI: { serverCompileTask, + getFlattenRoutes, getRoutesFile, generator, }, @@ -96,6 +97,8 @@ const getWebpackConfig: GetWebpackConfig = async (context, options) => { outputDir, serverCompileTask, userConfig, + command, + getFlattenRoutes, }); if (serverCompilerPlugin) { webpackConfig.plugins.push(serverCompilerPlugin); diff --git a/packages/ice/src/createService.ts b/packages/ice/src/createService.ts index 5a434aa20f..a20bbb27ee 100644 --- a/packages/ice/src/createService.ts +++ b/packages/ice/src/createService.ts @@ -38,6 +38,7 @@ import addPolyfills from './utils/runtimePolyfill.js'; import webpackBundler from './bundler/webpack/index.js'; import rspackBundler from './bundler/rspack/index.js'; import getDefaultTaskConfig from './plugins/task.js'; +import { multipleServerEntry, renderMultiEntry } from './utils/multipleEntry.js'; import hasDocument from './utils/hasDocument.js'; const require = createRequire(import.meta.url); @@ -248,7 +249,10 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt const iceRuntimePath = '@ice/runtime'; // Only when code splitting use the default strategy or set to `router`, the router will be lazy loaded. const lazy = [true, 'chunks', 'page', 'page-vendors'].includes(userConfig.codeSplitting); - const { routeImports, routeDefinition } = getRoutesDefinition(routesInfo.routes, lazy); + const { routeImports, routeDefinition } = getRoutesDefinition({ + manifest: routesInfo.routes, + lazy, + }); const loaderExports = hasExportAppData || Boolean(routesInfo.loaders); const hasDataLoader = Boolean(userConfig.dataLoader) && loaderExports; // add render data @@ -272,6 +276,7 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt hasDataLoader, routeImports, routeDefinition, + routesFile: './routes', }); dataCache.set('routes', JSON.stringify(routesInfo)); dataCache.set('hasExportAppData', hasExportAppData ? 'true' : ''); @@ -309,6 +314,15 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt }); } + if (multipleServerEntry(userConfig, command)) { + renderMultiEntry({ + generator, + renderRoutes: routeManifest.getFlattenRoute(), + routesManifest: routesInfo.routes, + lazy, + }); + } + // render template before webpack compile const renderStart = new Date().getTime(); generator.render(); diff --git a/packages/ice/src/getWatchEvents.ts b/packages/ice/src/getWatchEvents.ts index 05eda45a47..ec697bccfe 100644 --- a/packages/ice/src/getWatchEvents.ts +++ b/packages/ice/src/getWatchEvents.ts @@ -30,7 +30,10 @@ const getWatchEvents = (options: Options): WatchEvent[] => { async (eventName: string) => { if (eventName === 'add' || eventName === 'unlink' || eventName === 'change') { const routesRenderData = await generateRoutesInfo(rootDir, routesConfig); - const { routeImports, routeDefinition } = getRoutesDefinition(routesRenderData.routes, lazyRoutes); + const { routeImports, routeDefinition } = getRoutesDefinition({ + manifest: routesRenderData.routes, + lazy: lazyRoutes, + }); const stringifiedData = JSON.stringify(routesRenderData); if (cache.get('routes') !== stringifiedData) { cache.set('routes', stringifiedData); diff --git a/packages/ice/src/routes.ts b/packages/ice/src/routes.ts index bfe542376c..f841fbab50 100644 --- a/packages/ice/src/routes.ts +++ b/packages/ice/src/routes.ts @@ -64,9 +64,20 @@ function getFilePath(file: string) { return formatPath(path.isAbsolute(file) ? file : `@/pages/${file}`.replace(new RegExp(`${path.extname(file)}$`), '')); } -export function getRoutesDefinition(nestRouteManifest: NestedRouteManifest[], lazy = false, depth = 0) { +interface GetDefinationOptions { + manifest: NestedRouteManifest[]; + lazy?: boolean; + depth?: number; + matchRoute?: (route: NestedRouteManifest) => boolean; +} + +export function getRoutesDefinition(options: GetDefinationOptions) { + const { manifest, lazy = false, depth = 0, matchRoute = () => true } = options; const routeImports: string[] = []; - const routeDefinition = nestRouteManifest.reduce((prev, route) => { + const routeDefinition = manifest.reduce((prev, route) => { + if (!matchRoute(route)) { + return prev; + } const { children, path: routePath, index, componentName, file, id, layout, exports } = route; const componentPath = id.startsWith('__') ? file : getFilePath(file); @@ -112,7 +123,12 @@ export function getRoutesDefinition(nestRouteManifest: NestedRouteManifest[], la routeProperties.push('layout: true,'); } if (children) { - const res = getRoutesDefinition(children, lazy, depth + 1); + const res = getRoutesDefinition({ + manifest: children, + lazy, + depth: depth + 1, + matchRoute, + }); routeImports.push(...res.routeImports); routeProperties.push(`children: [${res.routeDefinition}]`); } diff --git a/packages/ice/src/types/userConfig.ts b/packages/ice/src/types/userConfig.ts index f924fdc789..ae252c00a9 100644 --- a/packages/ice/src/types/userConfig.ts +++ b/packages/ice/src/types/userConfig.ts @@ -220,7 +220,7 @@ export interface UserConfig { /** * bundle server code as a single file */ - bundle?: boolean; + bundle?: boolean | 'page'; /** * ignore file when bundle server code, module return empty when match */ diff --git a/packages/ice/src/utils/generateEntry.ts b/packages/ice/src/utils/generateEntry.ts index 20c8743909..198e59d8c1 100644 --- a/packages/ice/src/utils/generateEntry.ts +++ b/packages/ice/src/utils/generateEntry.ts @@ -67,9 +67,13 @@ const writeFile = async (file: string, content: string) => { await fse.writeFile(file, content); }; -function formatFilePath(routePath: string, type: 'js' | 'html' | 'js.map'): string { +export function escapeRoutePath(str: string) { // Win32 do not support file name start with ':' and '*'. - return routePath === '/' ? `index.${type}` : `${routePath.replace(/\/(:|\*)/g, '/$')}.${type}`; + return str.replace(/\/(:|\*)/g, '/$'); +} + +function formatFilePath(routePath: string, type: 'js' | 'html' | 'js.map'): string { + return routePath === '/' ? `index.${type}` : `${escapeRoutePath(routePath)}.${type}`; } async function generateFilePath( diff --git a/packages/ice/src/utils/getEntryPoints.ts b/packages/ice/src/utils/getEntryPoints.ts new file mode 100644 index 0000000000..94e6c78c27 --- /dev/null +++ b/packages/ice/src/utils/getEntryPoints.ts @@ -0,0 +1,17 @@ +import * as path from 'path'; +import { RUNTIME_TMP_DIR } from '../constant.js'; +import getServerEntry from './getServerEntry.js'; +import { formatServerEntry } from './multipleEntry.js'; + +function getEntryPoints(rootDir: string, routes: string[], mainEntry: string) { + const serverEntry: Record<string, string> = {}; + routes.forEach((route) => { + serverEntry[`pages${route === '/' ? '/index' : route}`] = + path.join(rootDir, RUNTIME_TMP_DIR, formatServerEntry(route)); + }); + serverEntry.index = getServerEntry(rootDir, mainEntry); + + return serverEntry; +} + +export default getEntryPoints; diff --git a/packages/ice/src/utils/getServerCompilerPlugin.ts b/packages/ice/src/utils/getServerCompilerPlugin.ts index ecddd9eb85..a4f3db2fa1 100644 --- a/packages/ice/src/utils/getServerCompilerPlugin.ts +++ b/packages/ice/src/utils/getServerCompilerPlugin.ts @@ -13,6 +13,7 @@ interface Options { serverCompileTask: ExtendsPluginAPI['serverCompileTask']; ensureRoutesConfig: () => Promise<void>; runtimeDefineVars: Record<string, string>; + entryPoints?: Record<string, string>; } function getServerCompilerPlugin(serverCompiler: ServerCompiler, options: Options) { @@ -24,15 +25,16 @@ function getServerCompilerPlugin(serverCompiler: ServerCompiler, options: Option serverCompileTask, ensureRoutesConfig, runtimeDefineVars, + entryPoints, } = options; - const entryPoint = getServerEntry(rootDir, serverEntry); const { ssg, ssr, server: { format } } = userConfig; const isEsm = userConfig?.server?.format === 'esm'; + return new ServerCompilerPlugin( serverCompiler, [ { - entryPoints: { index: entryPoint }, + entryPoints: entryPoints || { index: getServerEntry(rootDir, serverEntry) }, outdir: path.join(outputDir, SERVER_OUTPUT_DIR), splitting: isEsm, format, diff --git a/packages/ice/src/utils/multipleEntry.ts b/packages/ice/src/utils/multipleEntry.ts new file mode 100644 index 0000000000..31b7ce631d --- /dev/null +++ b/packages/ice/src/utils/multipleEntry.ts @@ -0,0 +1,56 @@ +import matchRoutes from '@ice/runtime/matchRoutes'; +import type { NestedRouteManifest } from '@ice/route-manifest'; +import type { CommandName } from 'build-scripts'; +import { getRoutesDefinition } from '../routes.js'; +import type Generator from '../service/runtimeGenerator.js'; +import type { UserConfig } from '../types/userConfig.js'; +import { escapeRoutePath } from './generateEntry.js'; + +interface Options { + renderRoutes: string[]; + routesManifest: NestedRouteManifest[]; + generator: Generator; + lazy: boolean; +} + +export const multipleServerEntry = (userConfig: UserConfig, command: CommandName): boolean => { + return userConfig?.server?.bundle === 'page' && + userConfig.server.format === 'cjs' && + command === 'build'; +}; + +export const formatRoutePath = (route: string) => { + return escapeRoutePath(route) + .replace(/^\//, '').replace(/\//g, '_'); +}; + +export const formatServerEntry = (route: string) => { + return `server.entry.${formatRoutePath(route) || 'index'}.ts`; +}; + +export function renderMultiEntry(options: Options) { + const { renderRoutes, routesManifest, generator, lazy } = options; + renderRoutes.forEach((route) => { + const routeId = formatRoutePath(route); + generator.addRenderFile( + 'core/entry.server.ts.ejs', + formatServerEntry(route), + { + routesFile: `./routes.${routeId}`, + }, + ); + // Generate route file for each route. + const matches = matchRoutes(routesManifest, route); + const { routeImports, routeDefinition } = getRoutesDefinition({ + manifest: routesManifest, + lazy, + matchRoute: (routeItem) => { + return matches.some((match) => match.route.id === routeItem.id); + }, + }); + generator.addRenderFile('core/routes.tsx.ejs', `routes.${routeId}.tsx`, { + routeImports, + routeDefinition, + }); + }); +} diff --git a/packages/ice/templates/core/entry.server.ts.ejs b/packages/ice/templates/core/entry.server.ts.ejs index f0535b214e..c4ae2cfe13 100644 --- a/packages/ice/templates/core/entry.server.ts.ejs +++ b/packages/ice/templates/core/entry.server.ts.ejs @@ -15,7 +15,7 @@ import type { RenderToPipeableStreamOptions } from 'react-dom/server'; // @ts-ignore import assetsManifest from 'virtual:assets-manifest.json'; <% if (hydrate) {-%> -import createRoutes from './routes'; +import createRoutes from '<%- routesFile %>'; <% } else { -%> import routesManifest from './route-manifest.json'; <% } -%> From a805fa9562777e297119300b9ce4a02de999c0a0 Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Mon, 6 May 2024 19:25:42 +0800 Subject: [PATCH 05/10] fix: minify config of swc (#6871) --- .changeset/tricky-cheetahs-mate.md | 5 +++++ packages/webpack-config/src/index.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/tricky-cheetahs-mate.md diff --git a/.changeset/tricky-cheetahs-mate.md b/.changeset/tricky-cheetahs-mate.md new file mode 100644 index 0000000000..0071da5fbd --- /dev/null +++ b/.changeset/tricky-cheetahs-mate.md @@ -0,0 +1,5 @@ +--- +'@ice/webpack-config': patch +--- + +fix: minify config of swc diff --git a/packages/webpack-config/src/index.ts b/packages/webpack-config/src/index.ts index dd187bda1b..3f0ab39271 100644 --- a/packages/webpack-config/src/index.ts +++ b/packages/webpack-config/src/index.ts @@ -139,7 +139,8 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio inline: 2, passes: 4, }, - mangle: { + // If JSMinifier is swc remove mangle config because it will cause minification error. + mangle: minify === JSMinifier.swc ? {} : { safari10: true, }, format: { From e78c7d22cf124fad38e94682ebde0e1c4365c24b Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Tue, 7 May 2024 09:48:45 +0800 Subject: [PATCH 06/10] fix: single route mismatch warning for development (#6870) --- .changeset/red-ducks-look.md | 5 +++++ packages/runtime/src/singleRouter.tsx | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/red-ducks-look.md diff --git a/.changeset/red-ducks-look.md b/.changeset/red-ducks-look.md new file mode 100644 index 0000000000..0608886a6e --- /dev/null +++ b/.changeset/red-ducks-look.md @@ -0,0 +1,5 @@ +--- +'@ice/runtime': patch +--- + +fix: single route mismatch warning for development diff --git a/packages/runtime/src/singleRouter.tsx b/packages/runtime/src/singleRouter.tsx index 6d6a347244..2a65cd10e5 100644 --- a/packages/runtime/src/singleRouter.tsx +++ b/packages/runtime/src/singleRouter.tsx @@ -279,6 +279,10 @@ export const matchRoutes = ( for (let i = 0; matches == null && i < branches.length; i++) { matches = matchRouteBranch(branches[i], stripedPathname); } + if (!matches) { + console.warn('Single route manifest: ', routes); + console.warn(`Basename "${basename}" is not match with pathname "${pathname}"`); + } return matches; }; @@ -316,13 +320,13 @@ export const getSingleRoute = async ( let loaders = []; let loaderIds = []; const components = matchedRoutes.map(({ route }) => { - const { loader } = routeModules[route.id]; + const { loader, Component } = routeModules?.[route.id] || {}; if (loader) { loaders.push(loader()); loaderIds.push(route.id); } return { - Component: routeModules[route.id].Component || route.Component, + Component: Component || route.Component, isDataRoute: !!loader, id: route.id, }; From e858a52280660ec7ea88643bccd30de3dd485e7f Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Tue, 7 May 2024 09:51:40 +0800 Subject: [PATCH 07/10] fix: support https in speedup mode (#6879) --- .changeset/strong-zoos-applaud.md | 5 +++++ packages/rspack-config/src/index.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/strong-zoos-applaud.md diff --git a/.changeset/strong-zoos-applaud.md b/.changeset/strong-zoos-applaud.md new file mode 100644 index 0000000000..7510a82fd1 --- /dev/null +++ b/.changeset/strong-zoos-applaud.md @@ -0,0 +1,5 @@ +--- +'@ice/rspack-config': patch +--- + +fix: support cli option `https` for speedup mode diff --git a/packages/rspack-config/src/index.ts b/packages/rspack-config/src/index.ts index 84e474a60c..205a3441dd 100644 --- a/packages/rspack-config/src/index.ts +++ b/packages/rspack-config/src/index.ts @@ -108,6 +108,7 @@ const getConfig: GetConfig = async (options) => { redirectImports, fastRefresh, sourceMap, + https, } = taskConfig || {}; const isDev = mode === 'development'; const absoluteOutputDir = path.isAbsolute(outputDir) ? outputDir : path.join(rootDir, outputDir); @@ -306,6 +307,7 @@ const getConfig: GetConfig = async (options) => { client: { logging: 'info', }, + https, ...devServer, setupMiddlewares: middlewares, }, From e4a32686c69c836c2d039fcad5c30ea8aef0bfb3 Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Tue, 7 May 2024 09:59:43 +0800 Subject: [PATCH 08/10] Feat: support options for compilationConfig (#6880) * feat: support options for compilationConfig * fix: update plugin rax compat * chore: lint --- .changeset/chatty-masks-join.md | 5 +++++ .changeset/real-knives-nail.md | 5 +++++ packages/plugin-rax-compat/src/services/jsx.ts | 4 ++-- packages/shared-config/src/types.ts | 14 +++++++++++++- .../shared-config/src/unPlugins/compilation.ts | 18 ++++-------------- 5 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 .changeset/chatty-masks-join.md create mode 100644 .changeset/real-knives-nail.md diff --git a/.changeset/chatty-masks-join.md b/.changeset/chatty-masks-join.md new file mode 100644 index 0000000000..8efd2d4b73 --- /dev/null +++ b/.changeset/chatty-masks-join.md @@ -0,0 +1,5 @@ +--- +'@ice/plugin-rax-compat': patch +--- + +fix: support pass options for `compilationConfig` diff --git a/.changeset/real-knives-nail.md b/.changeset/real-knives-nail.md new file mode 100644 index 0000000000..773bdd4ae2 --- /dev/null +++ b/.changeset/real-knives-nail.md @@ -0,0 +1,5 @@ +--- +'@ice/shared-config': patch +--- + +feat: support options for compilationConfig diff --git a/packages/plugin-rax-compat/src/services/jsx.ts b/packages/plugin-rax-compat/src/services/jsx.ts index 5c73818940..9bf15f7098 100644 --- a/packages/plugin-rax-compat/src/services/jsx.ts +++ b/packages/plugin-rax-compat/src/services/jsx.ts @@ -16,7 +16,7 @@ export class JSXService { // Reset jsc.transform.react.runtime to classic. config.swcOptions = merge(config.swcOptions || {}, { - compilationConfig: (source: string, id: string) => { + compilationConfig: (source: string, id: string, compileOptions) => { let swcCompilationConfig = {}; const hasJSXComment = source.indexOf('@jsx createElement') !== -1; const isRaxComponent = /(from|require\()\s*['"]rax['"]/.test(source); @@ -43,7 +43,7 @@ export class JSXService { }; } - return merge({}, originalSwcCompilationConfigFunc(source, id), swcCompilationConfig); + return merge({}, originalSwcCompilationConfigFunc(source, id, compileOptions), swcCompilationConfig); }, }); }); diff --git a/packages/shared-config/src/types.ts b/packages/shared-config/src/types.ts index e284ab9038..91babe7ed8 100644 --- a/packages/shared-config/src/types.ts +++ b/packages/shared-config/src/types.ts @@ -40,9 +40,21 @@ interface ConfigurationCtx<T = typeof webpack> extends Config { } type Experimental = Configuration['experiments']; + +export type JSXSuffix = 'jsx' | 'tsx'; +export interface GetJsxTransformOptions { + rootDir: string; + mode: Options['mode']; + suffix?: JSXSuffix; + fastRefresh: boolean; + polyfill: Config['polyfill']; + enableEnv: boolean; +} + interface SwcOptions { removeExportExprs?: string[]; - compilationConfig?: SwcCompilationConfig | ((source: string, id: string) => SwcCompilationConfig); + compilationConfig?: SwcCompilationConfig | + ((source: string, id: string, options: GetJsxTransformOptions) => SwcCompilationConfig); keepExports?: string[] | { value: string[]; include?: (id: string) => boolean }; nodeTransform?: boolean; } diff --git a/packages/shared-config/src/unPlugins/compilation.ts b/packages/shared-config/src/unPlugins/compilation.ts index 7b25415cea..f847784228 100644 --- a/packages/shared-config/src/unPlugins/compilation.ts +++ b/packages/shared-config/src/unPlugins/compilation.ts @@ -5,13 +5,11 @@ import consola from 'consola'; import type { SwcConfig, ReactConfig } from '@ice/bundles'; import type { UnpluginOptions } from '@ice/bundles/compiled/unplugin/index.js'; import lodash from '@ice/bundles/compiled/lodash/index.js'; -import type { Config } from '../types.js'; +import type { Config, JSXSuffix, GetJsxTransformOptions } from '../types.js'; import transformImport from '../utils/transformImport.js'; const { merge } = lodash; -type JSXSuffix = 'jsx' | 'tsx'; - interface Options { rootDir: string; mode: 'development' | 'production' | 'none'; @@ -84,8 +82,8 @@ const compilationPlugin = (options: Options): UnpluginOptions => { filename: id, sourceMaps: !!sourceMap, }; - - const commonOptions = getJsxTransformOptions({ rootDir, mode, suffix, fastRefresh, polyfill, enableEnv }); + const compileOptions = { rootDir, mode, suffix, fastRefresh, polyfill, enableEnv }; + const commonOptions = getJsxTransformOptions(compileOptions); // auto detect development mode if ( @@ -99,7 +97,7 @@ const compilationPlugin = (options: Options): UnpluginOptions => { merge(programmaticOptions, commonOptions); if (typeof compilationConfig === 'function') { - merge(programmaticOptions, compilationConfig(source, fileId)); + merge(programmaticOptions, compilationConfig(source, fileId, compileOptions)); } else if (compilationConfig) { merge(programmaticOptions, compilationConfig); } @@ -180,14 +178,6 @@ const compilationPlugin = (options: Options): UnpluginOptions => { }; }; -interface GetJsxTransformOptions { - rootDir: string; - mode: Options['mode']; - suffix?: JSXSuffix; - fastRefresh: boolean; - polyfill: Config['polyfill']; - enableEnv: boolean; -} export function getJsxTransformOptions({ suffix, From 433e275354370a908b714e9396c999f1e10df82c Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Tue, 7 May 2024 10:16:44 +0800 Subject: [PATCH 09/10] chore: fix compile error --- packages/plugin-intl/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-intl/src/index.ts b/packages/plugin-intl/src/index.ts index 07625fc719..5a18d5a28f 100644 --- a/packages/plugin-intl/src/index.ts +++ b/packages/plugin-intl/src/index.ts @@ -55,6 +55,7 @@ const plugin: Plugin = () => ({ generator.addEntryImportAhead({ source: runtimeSource, + // @ts-ignore }, 'both'); } } else { From 61ed9f03cc13356ffe378e33d3d9c421e7a7ad75 Mon Sep 17 00:00:00 2001 From: ClarkXia <xiawenwu41@gmail.com> Date: Tue, 7 May 2024 10:43:16 +0800 Subject: [PATCH 10/10] chore: update versions (#6873) --- .changeset/brave-actors-suffer.md | 5 ----- .changeset/chatty-masks-join.md | 5 ----- .changeset/odd-crews-sing.md | 5 ----- .changeset/real-knives-nail.md | 5 ----- .changeset/red-ducks-look.md | 5 ----- .changeset/spotty-dodos-drop.md | 5 ----- .changeset/strong-zoos-applaud.md | 5 ----- .changeset/tricky-cheetahs-mate.md | 5 ----- packages/ice/CHANGELOG.md | 16 ++++++++++++++++ packages/ice/package.json | 10 +++++----- packages/plugin-i18n/package.json | 4 ++-- packages/plugin-rax-compat/CHANGELOG.md | 6 ++++++ packages/plugin-rax-compat/package.json | 4 ++-- packages/rspack-config/CHANGELOG.md | 8 ++++++++ packages/rspack-config/package.json | 4 ++-- packages/runtime/CHANGELOG.md | 6 ++++++ packages/runtime/package.json | 2 +- packages/shared-config/CHANGELOG.md | 6 ++++++ packages/shared-config/package.json | 2 +- packages/webpack-config/CHANGELOG.md | 8 ++++++++ packages/webpack-config/package.json | 4 ++-- pnpm-lock.yaml | 14 +++++++------- 22 files changed, 72 insertions(+), 62 deletions(-) delete mode 100644 .changeset/brave-actors-suffer.md delete mode 100644 .changeset/chatty-masks-join.md delete mode 100644 .changeset/odd-crews-sing.md delete mode 100644 .changeset/real-knives-nail.md delete mode 100644 .changeset/red-ducks-look.md delete mode 100644 .changeset/spotty-dodos-drop.md delete mode 100644 .changeset/strong-zoos-applaud.md delete mode 100644 .changeset/tricky-cheetahs-mate.md diff --git a/.changeset/brave-actors-suffer.md b/.changeset/brave-actors-suffer.md deleted file mode 100644 index 32f4d54d0f..0000000000 --- a/.changeset/brave-actors-suffer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/app': patch ---- - -feat: support generator api to inject code in server entry diff --git a/.changeset/chatty-masks-join.md b/.changeset/chatty-masks-join.md deleted file mode 100644 index 8efd2d4b73..0000000000 --- a/.changeset/chatty-masks-join.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/plugin-rax-compat': patch ---- - -fix: support pass options for `compilationConfig` diff --git a/.changeset/odd-crews-sing.md b/.changeset/odd-crews-sing.md deleted file mode 100644 index 1577994cce..0000000000 --- a/.changeset/odd-crews-sing.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/app': patch ---- - -fix: do not remove request config of dataLoader compilation in speedup mode diff --git a/.changeset/real-knives-nail.md b/.changeset/real-knives-nail.md deleted file mode 100644 index 773bdd4ae2..0000000000 --- a/.changeset/real-knives-nail.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/shared-config': patch ---- - -feat: support options for compilationConfig diff --git a/.changeset/red-ducks-look.md b/.changeset/red-ducks-look.md deleted file mode 100644 index 0608886a6e..0000000000 --- a/.changeset/red-ducks-look.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/runtime': patch ---- - -fix: single route mismatch warning for development diff --git a/.changeset/spotty-dodos-drop.md b/.changeset/spotty-dodos-drop.md deleted file mode 100644 index e7a0ec498c..0000000000 --- a/.changeset/spotty-dodos-drop.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/app': patch ---- - -feat: support spilt page chunk in cjs format diff --git a/.changeset/strong-zoos-applaud.md b/.changeset/strong-zoos-applaud.md deleted file mode 100644 index 7510a82fd1..0000000000 --- a/.changeset/strong-zoos-applaud.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/rspack-config': patch ---- - -fix: support cli option `https` for speedup mode diff --git a/.changeset/tricky-cheetahs-mate.md b/.changeset/tricky-cheetahs-mate.md deleted file mode 100644 index 0071da5fbd..0000000000 --- a/.changeset/tricky-cheetahs-mate.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@ice/webpack-config': patch ---- - -fix: minify config of swc diff --git a/packages/ice/CHANGELOG.md b/packages/ice/CHANGELOG.md index ace526e3b5..c96a5200af 100644 --- a/packages/ice/CHANGELOG.md +++ b/packages/ice/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 3.4.8 + +### Patch Changes + +- 8dada9b6: feat: support generator api to inject code in server entry +- 5c40dc93: fix: do not remove request config of dataLoader compilation in speedup mode +- 11a87dc6: feat: support spilt page chunk in cjs format +- Updated dependencies [e4a32686] +- Updated dependencies [e78c7d22] +- Updated dependencies [e858a522] +- Updated dependencies [a805fa95] + - @ice/shared-config@1.2.7 + - @ice/runtime@1.4.7 + - @ice/rspack-config@1.1.7 + - @ice/webpack-config@1.1.14 + ## 3.4.7 ### Patch Changes diff --git a/packages/ice/package.json b/packages/ice/package.json index 8177386229..d76fd776e5 100644 --- a/packages/ice/package.json +++ b/packages/ice/package.json @@ -1,6 +1,6 @@ { "name": "@ice/app", - "version": "3.4.7", + "version": "3.4.8", "description": "provide scripts and configuration used by web framework ice", "type": "module", "main": "./esm/index.js", @@ -49,10 +49,10 @@ "dependencies": { "@ice/bundles": "0.2.6", "@ice/route-manifest": "1.2.2", - "@ice/runtime": "^1.4.5", - "@ice/shared-config": "1.2.6", - "@ice/webpack-config": "1.1.13", - "@ice/rspack-config": "1.1.6", + "@ice/runtime": "^1.4.7", + "@ice/shared-config": "1.2.7", + "@ice/webpack-config": "1.1.14", + "@ice/rspack-config": "1.1.7", "@swc/helpers": "0.5.1", "@types/express": "^4.17.14", "address": "^1.1.2", diff --git a/packages/plugin-i18n/package.json b/packages/plugin-i18n/package.json index bcabba8076..d75adf7de2 100644 --- a/packages/plugin-i18n/package.json +++ b/packages/plugin-i18n/package.json @@ -56,8 +56,8 @@ "webpack-dev-server": "4.15.0" }, "peerDependencies": { - "@ice/app": "^3.4.7", - "@ice/runtime": "^1.4.5" + "@ice/app": "^3.4.8", + "@ice/runtime": "^1.4.7" }, "publishConfig": { "access": "public" diff --git a/packages/plugin-rax-compat/CHANGELOG.md b/packages/plugin-rax-compat/CHANGELOG.md index 992f7107bd..493bbfd99c 100644 --- a/packages/plugin-rax-compat/CHANGELOG.md +++ b/packages/plugin-rax-compat/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.3.1 + +### Patch Changes + +- e4a32686: fix: support pass options for `compilationConfig` + ## 0.3.0 ### Minor Changes diff --git a/packages/plugin-rax-compat/package.json b/packages/plugin-rax-compat/package.json index cb7ca6e94a..b624c28411 100644 --- a/packages/plugin-rax-compat/package.json +++ b/packages/plugin-rax-compat/package.json @@ -1,6 +1,6 @@ { "name": "@ice/plugin-rax-compat", - "version": "0.3.0", + "version": "0.3.1", "description": "Provide rax compat support for ice.js", "license": "MIT", "type": "module", @@ -30,7 +30,7 @@ "stylesheet-loader": "^0.9.1" }, "devDependencies": { - "@ice/app": "^3.4.2", + "@ice/app": "^3.4.8", "@types/lodash-es": "^4.17.7", "webpack": "^5.88.0" }, diff --git a/packages/rspack-config/CHANGELOG.md b/packages/rspack-config/CHANGELOG.md index 2a1b0a8dfe..1a080b497d 100644 --- a/packages/rspack-config/CHANGELOG.md +++ b/packages/rspack-config/CHANGELOG.md @@ -1,5 +1,13 @@ # @ice/rspack-config +## 1.1.7 + +### Patch Changes + +- e858a522: fix: support cli option `https` for speedup mode +- Updated dependencies [e4a32686] + - @ice/shared-config@1.2.7 + ## 1.1.6 ### Patch Changes diff --git a/packages/rspack-config/package.json b/packages/rspack-config/package.json index ade042ed32..aa27d49a95 100644 --- a/packages/rspack-config/package.json +++ b/packages/rspack-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/rspack-config", - "version": "1.1.6", + "version": "1.1.7", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", @@ -16,7 +16,7 @@ ], "dependencies": { "@ice/bundles": "0.2.6", - "@ice/shared-config": "1.2.6" + "@ice/shared-config": "1.2.7" }, "devDependencies": { "@rspack/core": "0.5.7" diff --git a/packages/runtime/CHANGELOG.md b/packages/runtime/CHANGELOG.md index 91b5c19128..8e2bb7eefb 100644 --- a/packages/runtime/CHANGELOG.md +++ b/packages/runtime/CHANGELOG.md @@ -1,5 +1,11 @@ # @ice/runtime +## 1.4.7 + +### Patch Changes + +- e78c7d22: fix: single route mismatch warning for development + ## 1.4.6 - Fix: serverDataLoader is not work when dataLoader is not defined. diff --git a/packages/runtime/package.json b/packages/runtime/package.json index fc33762574..cc3630f5a2 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@ice/runtime", - "version": "1.4.6", + "version": "1.4.7", "description": "Runtime module for ice.js", "type": "module", "types": "./esm/index.d.ts", diff --git a/packages/shared-config/CHANGELOG.md b/packages/shared-config/CHANGELOG.md index 49dcc30e88..49f03bfb4b 100644 --- a/packages/shared-config/CHANGELOG.md +++ b/packages/shared-config/CHANGELOG.md @@ -1,5 +1,11 @@ # @ice/shared-config +## 1.2.7 + +### Patch Changes + +- e4a32686: feat: support options for compilationConfig + ## 1.2.6 ### Patch Changes diff --git a/packages/shared-config/package.json b/packages/shared-config/package.json index ee34fb0b2e..0193fd6987 100644 --- a/packages/shared-config/package.json +++ b/packages/shared-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/shared-config", - "version": "1.2.6", + "version": "1.2.7", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", diff --git a/packages/webpack-config/CHANGELOG.md b/packages/webpack-config/CHANGELOG.md index 58e36ee7fd..0e726af0bb 100644 --- a/packages/webpack-config/CHANGELOG.md +++ b/packages/webpack-config/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.1.14 + +### Patch Changes + +- a805fa95: fix: minify config of swc +- Updated dependencies [e4a32686] + - @ice/shared-config@1.2.7 + ## 1.1.13 ### Patch Changes diff --git a/packages/webpack-config/package.json b/packages/webpack-config/package.json index 8edae22d73..7f62579f6e 100644 --- a/packages/webpack-config/package.json +++ b/packages/webpack-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/webpack-config", - "version": "1.1.13", + "version": "1.1.14", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", @@ -15,7 +15,7 @@ "*.d.ts" ], "dependencies": { - "@ice/shared-config": "1.2.6", + "@ice/shared-config": "1.2.7", "@ice/bundles": "0.2.6", "fast-glob": "^3.2.11", "process": "^0.11.10" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c54f49598..364767086d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1678,16 +1678,16 @@ importers: specifier: 1.2.2 version: link:../route-manifest '@ice/rspack-config': - specifier: 1.1.6 + specifier: 1.1.7 version: link:../rspack-config '@ice/runtime': - specifier: ^1.4.5 + specifier: ^1.4.7 version: link:../runtime '@ice/shared-config': - specifier: 1.2.6 + specifier: 1.2.7 version: link:../shared-config '@ice/webpack-config': - specifier: 1.1.13 + specifier: 1.1.14 version: link:../webpack-config '@swc/helpers': specifier: 0.5.1 @@ -2234,7 +2234,7 @@ importers: version: 0.9.1 devDependencies: '@ice/app': - specifier: ^3.4.2 + specifier: ^3.4.8 version: link:../ice '@types/lodash-es': specifier: ^4.17.7 @@ -2382,7 +2382,7 @@ importers: specifier: 0.2.6 version: link:../bundles '@ice/shared-config': - specifier: 1.2.6 + specifier: 1.2.7 version: link:../shared-config devDependencies: '@rspack/core': @@ -2487,7 +2487,7 @@ importers: specifier: 0.2.6 version: link:../bundles '@ice/shared-config': - specifier: 1.2.6 + specifier: 1.2.7 version: link:../shared-config fast-glob: specifier: ^3.2.11