| ComponentModule>;
+
+export type Loader
= (() => LoaderComponent
) | LoaderComponent
;
+
+export interface DynamicOptions {
+ /** @default true */
+ ssr?: boolean;
+ /** the fallback UI to render before the actual is loaded */
+ fallback?: () => ReactNode;
+}
+
+// Normalize loader to return the module as form { default: Component } for `React.lazy`.
+function convertModule
(mod: React.ComponentType
| ComponentModule
) {
+ return { default: (mod as ComponentModule
)?.default || mod };
+}
+
+const DefaultFallback = () => null;
+
+export function dynamic
(loader: Loader
, option?: DynamicOptions) {
+ const { ssr = true, fallback = DefaultFallback } = option || {};
+ let realLoader;
+ // convert dynamic(import('xxx')) to dynamic(() => import('xxx'))
+ if (loader instanceof Promise) {
+ realLoader = () => loader;
+ } else if (typeof loader === 'function') {
+ realLoader = loader;
+ }
+ if (!realLoader) return DefaultFallback;
+ const Fallback = fallback;
+
+ if (!ssr && isServer) {
+ return () => ;
+ }
+
+ const LazyComp = lazy(() => realLoader().then(convertModule));
+ return (props) => {
+ const hasMounted = useMounted();
+
+ return ssr || hasMounted ? (
+ }>
+
+
+ ) : (
+
+ );
+ };
+}
diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts
index c62c946ed6..f5306cc11c 100644
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@ -50,7 +50,7 @@ import useMounted from './useMounted.js';
import usePageLifecycle from './usePageLifecycle.js';
import { withSuspense, useSuspenseData } from './Suspense.js';
import { createRouteLoader, WrapRouteComponent, RouteErrorComponent, Await } from './routes.js';
-
+import { dynamic } from './dynamic.js';
function useAppContext() {
console.warn('import { useAppContext } from \'@ice/runtime\'; is deprecated, please use import { useAppContext } from \'ice\'; instead.');
return useInternalAppContext();
@@ -117,6 +117,7 @@ export {
callDataLoader,
getRequestContext,
history,
+ dynamic,
useActive,
KeepAliveOutlet,
diff --git a/packages/runtime/src/singleRouter.tsx b/packages/runtime/src/singleRouter.tsx
index 14c6a40c3c..fda96b0f85 100644
--- a/packages/runtime/src/singleRouter.tsx
+++ b/packages/runtime/src/singleRouter.tsx
@@ -257,8 +257,14 @@ export const matchRoutes = (
location: Partial | string,
basename: string,
) => {
- const pathname = typeof location === 'string' ? location : location.pathname;
- const stripedPathname = stripBasename(pathname || '/', basename || '/');
+ const pathname = (typeof location === 'string' ? location : location.pathname) || '/';
+
+ let stripedPathname = stripBasename(pathname, basename || '/');
+ if (!stripedPathname && basename !== '/') {
+ // If pathname is not match, we should ignore the basename,
+ // in case of the basename is customized.
+ stripedPathname = stripBasename(pathname, '/');
+ }
let branches = flattenRoutes(routes);
if (branches.length === 1) {
// Just one branch, no need to match.
diff --git a/packages/shared-config/CHANGELOG.md b/packages/shared-config/CHANGELOG.md
index d134ee6c69..49dcc30e88 100644
--- a/packages/shared-config/CHANGELOG.md
+++ b/packages/shared-config/CHANGELOG.md
@@ -1,5 +1,14 @@
# @ice/shared-config
+## 1.2.6
+
+### Patch Changes
+
+- 0d3cfd59: refactor: the compilation for data-loader
+- Updated dependencies [8275f13f]
+- Updated dependencies [0d3cfd59]
+ - @ice/bundles@0.2.6
+
## 1.2.5
### Patch Changes
diff --git a/packages/shared-config/package.json b/packages/shared-config/package.json
index c4174969aa..ee34fb0b2e 100644
--- a/packages/shared-config/package.json
+++ b/packages/shared-config/package.json
@@ -1,6 +1,6 @@
{
"name": "@ice/shared-config",
- "version": "1.2.5",
+ "version": "1.2.6",
"repository": "alibaba/ice",
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
@@ -17,7 +17,7 @@
"*.d.ts"
],
"dependencies": {
- "@ice/bundles": "0.2.5",
+ "@ice/bundles": "0.2.6",
"@rollup/pluginutils": "^4.2.0",
"browserslist": "^4.22.1",
"consola": "^2.15.3",
diff --git a/packages/shared-config/src/types.ts b/packages/shared-config/src/types.ts
index d1a7722e8b..e284ab9038 100644
--- a/packages/shared-config/src/types.ts
+++ b/packages/shared-config/src/types.ts
@@ -47,7 +47,7 @@ interface SwcOptions {
nodeTransform?: boolean;
}
-interface ImportDeclaration {
+export interface ImportDeclaration {
specifier?: string | string[];
source: string;
type?: boolean;
@@ -79,6 +79,9 @@ export type { webpack };
type PluginFunction = (this: Compiler, compiler: Compiler) => void;
export interface Config {
+ // The name of the task, used for the output log.
+ name?: string;
+
target?: string;
mode?: 'none' | 'development' | 'production';
diff --git a/packages/webpack-config/CHANGELOG.md b/packages/webpack-config/CHANGELOG.md
index 2e555083c6..58e36ee7fd 100644
--- a/packages/webpack-config/CHANGELOG.md
+++ b/packages/webpack-config/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## 1.1.13
+
+### Patch Changes
+
+- Updated dependencies [8275f13f]
+- Updated dependencies [0d3cfd59]
+ - @ice/bundles@0.2.6
+ - @ice/shared-config@1.2.6
+
## 1.1.12
### Patch Changes
diff --git a/packages/webpack-config/package.json b/packages/webpack-config/package.json
index 47c171fb76..8edae22d73 100644
--- a/packages/webpack-config/package.json
+++ b/packages/webpack-config/package.json
@@ -1,6 +1,6 @@
{
"name": "@ice/webpack-config",
- "version": "1.1.12",
+ "version": "1.1.13",
"repository": "alibaba/ice",
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
@@ -15,8 +15,8 @@
"*.d.ts"
],
"dependencies": {
- "@ice/shared-config": "1.2.5",
- "@ice/bundles": "0.2.5",
+ "@ice/shared-config": "1.2.6",
+ "@ice/bundles": "0.2.6",
"fast-glob": "^3.2.11",
"process": "^0.11.10"
},
diff --git a/patches/@rspack__core@0.5.4.patch b/patches/@rspack__core@0.5.7.patch
similarity index 83%
rename from patches/@rspack__core@0.5.4.patch
rename to patches/@rspack__core@0.5.7.patch
index 8c0848fea2..1517ff1009 100644
--- a/patches/@rspack__core@0.5.4.patch
+++ b/patches/@rspack__core@0.5.7.patch
@@ -1,5 +1,5 @@
diff --git a/dist/config/adapter.js b/dist/config/adapter.js
-index 49122b3e9f4f0ac85b4075a98f693986b4333051..c3436a090fdbac00e555b2e308974f8d3f9c2426 100644
+index 4eebbcf79cba29acbc0a36d565acc1c08eaf790b..1d87c9be33f69b8dda1436d8e3b970ce0b571112 100644
--- a/dist/config/adapter.js
+++ b/dist/config/adapter.js
@@ -15,6 +15,7 @@ const getRawOptions = (options, compiler) => {
@@ -11,7 +11,7 @@ index 49122b3e9f4f0ac85b4075a98f693986b4333051..c3436a090fdbac00e555b2e308974f8d
target: getRawTarget(options.target),
context: options.context,
diff --git a/dist/config/defaults.js b/dist/config/defaults.js
-index aeb7b74dd8473fa049002cf710ae860577d6d2e2..0dd4fd09fd08482b5a2c5a82cad61ab70e2b2d68 100644
+index 1f9f61ff680b6db026c43eb95fe2d78c5f5d8195..56ce90247fd920717d42bc16864e6025fe6dca66 100644
--- a/dist/config/defaults.js
+++ b/dist/config/defaults.js
@@ -53,6 +53,11 @@ const applyRspackOptionsDefaults = (options) => {
@@ -41,7 +41,7 @@ index aeb7b74dd8473fa049002cf710ae860577d6d2e2..0dd4fd09fd08482b5a2c5a82cad61ab7
D(experiments, "lazyCompilation", false);
D(experiments, "asyncWebAssembly", false);
diff --git a/dist/config/normalization.js b/dist/config/normalization.js
-index 72167c504bd43f606481ccd1de0bdcb9eae71d9f..b16f9f3bbf1c45e00a9ca31684cefec55198683b 100644
+index 696eddf849f8a2f2c66237cb37db767f4dfe20ca..7e89b6091471de8287ce0785042676873141cfbe 100644
--- a/dist/config/normalization.js
+++ b/dist/config/normalization.js
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
@@ -53,10 +53,10 @@ index 72167c504bd43f606481ccd1de0bdcb9eae71d9f..b16f9f3bbf1c45e00a9ca31684cefec5
? config.ignoreWarnings.map(ignore => {
if (typeof ignore === "function") {
diff --git a/dist/config/zod.js b/dist/config/zod.js
-index 1c4c2cf4d02c562b8fc965c103de0eaf8e246b6a..7fa7e42a02180081096d77f64d7df0cc7d61b4d1 100644
+index a81260f08e4e7de64ff3c1f8769a658db4c73883..df3184bad831922f64f3c41b64bce08fcdf5b3cd 100644
--- a/dist/config/zod.js
+++ b/dist/config/zod.js
-@@ -766,6 +766,7 @@ exports.rspackOptions = zod_1.z.strictObject({
+@@ -775,5 +775,6 @@ exports.rspackOptions = zod_1.z.strictObject({
builtins: builtins.optional(),
module: moduleOptions.optional(),
profile: profile.optional(),
@@ -64,4 +64,3 @@ index 1c4c2cf4d02c562b8fc965c103de0eaf8e246b6a..7fa7e42a02180081096d77f64d7df0cc
+ bail: bail.optional(),
+ features: zod_1.z.custom().optional(),
});
- //# sourceMappingURL=zod.js.map
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 991e6096a0..2b6da01fde 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5,9 +5,9 @@ settings:
excludeLinksFromLockfile: false
patchedDependencies:
- '@rspack/core@0.5.4':
- hash: cx7wc7uikmrb5dsrfcy5wrjzui
- path: patches/@rspack__core@0.5.4.patch
+ '@rspack/core@0.5.7':
+ hash: hydgitlae4ar2jrvgl5qp2f2um
+ path: patches/@rspack__core@0.5.7.patch
unplugin@1.6.0:
hash: z2z7uvjbiarznogeja262ejlha
path: patches/unplugin@1.6.0.patch
@@ -792,6 +792,31 @@ importers:
specifier: ^18.0.6
version: 18.0.11
+ examples/with-dynamic:
+ dependencies:
+ '@ice/app':
+ specifier: workspace:*
+ version: link:../../packages/ice
+ '@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)
+ tslib:
+ specifier: ^2.4.0
+ version: 2.5.0
+ devDependencies:
+ '@types/react':
+ specifier: ^18.0.17
+ version: 18.0.34
+ '@types/react-dom':
+ specifier: ^18.0.6
+ version: 18.0.11
+
examples/with-entry-type:
dependencies:
'@ice/app':
@@ -1298,8 +1323,8 @@ importers:
specifier: 0.0.8
version: 0.0.8
'@ice/pack-binding':
- specifier: 0.0.11
- version: 0.0.11
+ specifier: 0.0.12
+ version: 0.0.12
'@ice/swc-plugin-keep-export':
specifier: 0.2.0
version: 0.2.0
@@ -1395,14 +1420,14 @@ importers:
specifier: 0.5.10
version: 0.5.10(react-refresh@0.14.0)(webpack-dev-server@4.15.0)(webpack@5.88.2)
'@rspack/core':
- specifier: 0.5.4
- version: 0.5.4(patch_hash=cx7wc7uikmrb5dsrfcy5wrjzui)(@swc/helpers@0.5.1)
+ specifier: 0.5.7
+ version: 0.5.7(patch_hash=hydgitlae4ar2jrvgl5qp2f2um)(@swc/helpers@0.5.1)
'@rspack/dev-server':
- specifier: 0.5.4
- version: 0.5.4(@rspack/core@0.5.4)(@types/express@4.17.17)(webpack@5.88.2)
+ specifier: 0.5.7
+ version: 0.5.7(@rspack/core@0.5.7)(@types/express@4.17.17)(webpack@5.88.2)
'@rspack/plugin-react-refresh':
- specifier: 0.5.4
- version: 0.5.4(react-refresh@0.14.0)
+ specifier: 0.5.7
+ version: 0.5.7(react-refresh@0.14.0)
'@types/less':
specifier: ^3.0.3
version: 3.0.3
@@ -1622,22 +1647,22 @@ importers:
packages/ice:
dependencies:
'@ice/bundles':
- specifier: 0.2.5
+ specifier: 0.2.6
version: link:../bundles
'@ice/route-manifest':
specifier: 1.2.2
version: link:../route-manifest
'@ice/rspack-config':
- specifier: 1.1.5
+ specifier: 1.1.6
version: link:../rspack-config
'@ice/runtime':
- specifier: ^1.4.2
+ specifier: ^1.4.3
version: link:../runtime
'@ice/shared-config':
- specifier: 1.2.5
+ specifier: 1.2.6
version: link:../shared-config
'@ice/webpack-config':
- specifier: 1.1.12
+ specifier: 1.1.13
version: link:../webpack-config
'@swc/helpers':
specifier: 0.5.1
@@ -1722,11 +1747,11 @@ importers:
version: 21.1.1
devDependencies:
'@rspack/core':
- specifier: 0.5.4
- version: 0.5.4(patch_hash=cx7wc7uikmrb5dsrfcy5wrjzui)(@swc/helpers@0.5.1)
+ specifier: 0.5.7
+ version: 0.5.7(patch_hash=hydgitlae4ar2jrvgl5qp2f2um)(@swc/helpers@0.5.1)
'@rspack/dev-server':
- specifier: 0.5.4
- version: 0.5.4(@rspack/core@0.5.4)(@types/express@4.17.17)(webpack@5.88.2)
+ specifier: 0.5.7
+ version: 0.5.7(@rspack/core@0.5.7)(@types/express@4.17.17)(webpack@5.88.2)
'@types/babel__generator':
specifier: ^7.6.4
version: 7.6.4
@@ -2307,15 +2332,15 @@ importers:
packages/rspack-config:
dependencies:
'@ice/bundles':
- specifier: 0.2.5
+ specifier: 0.2.6
version: link:../bundles
'@ice/shared-config':
- specifier: 1.2.5
+ specifier: 1.2.6
version: link:../shared-config
devDependencies:
'@rspack/core':
- specifier: 0.5.4
- version: 0.5.4(patch_hash=cx7wc7uikmrb5dsrfcy5wrjzui)(@swc/helpers@0.5.1)
+ specifier: 0.5.7
+ version: 0.5.7(patch_hash=hydgitlae4ar2jrvgl5qp2f2um)(@swc/helpers@0.5.1)
packages/runtime:
dependencies:
@@ -2381,7 +2406,7 @@ importers:
packages/shared-config:
dependencies:
'@ice/bundles':
- specifier: 0.2.5
+ specifier: 0.2.6
version: link:../bundles
'@rollup/pluginutils':
specifier: ^4.2.0
@@ -2424,10 +2449,10 @@ importers:
packages/webpack-config:
dependencies:
'@ice/bundles':
- specifier: 0.2.5
+ specifier: 0.2.6
version: link:../bundles
'@ice/shared-config':
- specifier: 1.2.5
+ specifier: 1.2.6
version: link:../shared-config
fast-glob:
specifier: ^3.2.11
@@ -6548,8 +6573,8 @@ packages:
'@ice/css-modules-hash-win32-x64-msvc': 0.0.8
dev: false
- /@ice/pack-binding-darwin-arm64@0.0.11:
- resolution: {integrity: sha512-rEehtihZFAhPHXIwwJDgQLCW7nDxR8wVv9uI6XemMgYmhBKkrcHXDPpbuwnlPIepqluXOTV/c1kVIZzEsAFUFg==}
+ /@ice/pack-binding-darwin-arm64@0.0.12:
+ resolution: {integrity: sha512-o/obsLWXWCAnvkavQ7I5NFZSULVUKLLoukyO+I0A+ocSQw3Kync/Iu0+3Sm3GX4EVvR082vilj7bWcBgyw2hzA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
@@ -6557,16 +6582,16 @@ packages:
dev: false
optional: true
- /@ice/pack-binding-darwin-universal@0.0.11:
- resolution: {integrity: sha512-42ExKqjsw0oB+/FiMXObmIESWiqVai6H1xOdxT34afE0zMFkdwFQSdjnqY7giJ9VmXw/lVN6vUKlRlahv0NMZg==}
+ /@ice/pack-binding-darwin-universal@0.0.12:
+ resolution: {integrity: sha512-NRGLEvvQ0rBdNc1GdTVh3IbstFj5aNF4Fvp7ZF31XxcnXmlA1lF96cvYJp9FAJhsEvPOpNNcehOvHSDRchxmkw==}
engines: {node: '>= 10'}
os: [darwin]
requiresBuild: true
dev: false
optional: true
- /@ice/pack-binding-darwin-x64@0.0.11:
- resolution: {integrity: sha512-jCPS8Hm3xRokHZ3VQpGIRcYlOGL6g8JK+ftb/nYUDCUHlSjzafS398Qn3WpPB5O6nXa2qXctyCrVXrHLsNnAaw==}
+ /@ice/pack-binding-darwin-x64@0.0.12:
+ resolution: {integrity: sha512-htMqQvotrye4O43IfebRgI83fy97+reJwuJB+SDGAI7hzj8d6cLrMrOy5DDFlOr2xHRo6nyALJUu1A5Vmu1z6A==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
@@ -6574,8 +6599,8 @@ packages:
dev: false
optional: true
- /@ice/pack-binding-linux-x64-gnu@0.0.11:
- resolution: {integrity: sha512-IRchi7VuNTVoOIsp5GVPe9F6H1ZG2jr2u79f9UXT4Xqv+OeUund6GngP1X0jPfvXzYNR2PY/+Ox7biynxOMVtw==}
+ /@ice/pack-binding-linux-x64-gnu@0.0.12:
+ resolution: {integrity: sha512-5gW2eGgCok+2SJXS9D4pdkjWDCx5zyvwNhGOviOlsUPgXYCfN8WyVlSX1sWVXDyb76Lckl8IjjtiCi5PBWy0cA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -6583,8 +6608,8 @@ packages:
dev: false
optional: true
- /@ice/pack-binding-linux-x64-musl@0.0.11:
- resolution: {integrity: sha512-+8HRztvg2eDJID5+wtf6mJBkNBSSywnLeWBBvVyWXl4wzcpWLHmizXv28g4VMXXLlkqMD1xAXdsO/iKKqsdvGA==}
+ /@ice/pack-binding-linux-x64-musl@0.0.12:
+ resolution: {integrity: sha512-hdKXdq0nWAzdMD+sNSBw1ODqADffknCIsU+E8Qz8FnsK8tpwoh0dzLb8aKrr9yBpCtM+yPUAtIqDVh36WClZ7A==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -6592,8 +6617,8 @@ packages:
dev: false
optional: true
- /@ice/pack-binding-win32-arm64-msvc@0.0.11:
- resolution: {integrity: sha512-4y5SC2sVc5XWgdPN4lZWC5fZcXpHM0oVcbhkIYkxQuYv8Tx6P4gZZh3pfqt95KCmqBjcikBVZ9uZw0NTEuRd1Q==}
+ /@ice/pack-binding-win32-arm64-msvc@0.0.12:
+ resolution: {integrity: sha512-d96DmLUxZ8cgFVbBm30f9CI3H6GDtq9Bh7fk82Yj4DyvwjM1FL2R73zqidZhV3mvV14TmRJgApv1rZPE9dDBSg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
@@ -6601,8 +6626,8 @@ packages:
dev: false
optional: true
- /@ice/pack-binding-win32-x64-msvc@0.0.11:
- resolution: {integrity: sha512-Ewsma3rd/p8FQUcbNuTH8EFmjvgbGHh9gtIcHlT8MyXXjOyV9lDpwDDqmzM0M3Re0FenOSeMDI+1LFy9/mNN3Q==}
+ /@ice/pack-binding-win32-x64-msvc@0.0.12:
+ resolution: {integrity: sha512-yjn2aGLLNDWLQGHt3Svl3JR6KtnEvt3rS052h/gl/dL1sVx1d0VqMZ6yWoDP1P3scJCA7O7Iu1rdBQnMtHFNYw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
@@ -6610,17 +6635,17 @@ packages:
dev: false
optional: true
- /@ice/pack-binding@0.0.11:
- resolution: {integrity: sha512-FEiJ42urDfiYHNAOb4/6Twcwd3KzUwi65qKFlATqCFZM3Fyh/sqwmcMDAvrM0vgJfCP11cmGBD1GsvbMUunP5Q==}
+ /@ice/pack-binding@0.0.12:
+ resolution: {integrity: sha512-09hX2T2nASifPqSSyscgUgquZcoIFGG8cn/3WeOaBRPoZ8d1UjmAetEgRWWzaGPCoOjY8Lo5tV8BGvQKyj91/Q==}
engines: {node: '>= 10'}
optionalDependencies:
- '@ice/pack-binding-darwin-arm64': 0.0.11
- '@ice/pack-binding-darwin-universal': 0.0.11
- '@ice/pack-binding-darwin-x64': 0.0.11
- '@ice/pack-binding-linux-x64-gnu': 0.0.11
- '@ice/pack-binding-linux-x64-musl': 0.0.11
- '@ice/pack-binding-win32-arm64-msvc': 0.0.11
- '@ice/pack-binding-win32-x64-msvc': 0.0.11
+ '@ice/pack-binding-darwin-arm64': 0.0.12
+ '@ice/pack-binding-darwin-universal': 0.0.12
+ '@ice/pack-binding-darwin-x64': 0.0.12
+ '@ice/pack-binding-linux-x64-gnu': 0.0.12
+ '@ice/pack-binding-linux-x64-musl': 0.0.12
+ '@ice/pack-binding-win32-arm64-msvc': 0.0.12
+ '@ice/pack-binding-win32-x64-msvc': 0.0.12
dev: false
/@ice/pkg@1.5.5:
@@ -7785,94 +7810,94 @@ packages:
rollup: 2.79.1
dev: true
- /@rspack/binding-darwin-arm64@0.5.4:
- resolution: {integrity: sha512-MWTLMzrgWk5enKGfctVIhbU5WlpJbXpvUnHKzxSr4dclf+IeBIaXBEs1fwogrS87VdfWTOh+lndyzrozBnxMmQ==}
+ /@rspack/binding-darwin-arm64@0.5.7:
+ resolution: {integrity: sha512-zYTMILRyrON25MW7ifEhkZ6jL33mz8bAHTOhgR8yMpYVJjrKu60+s1qPa+t+GkaH7nNnVmzkTVGECCvaA75hJQ==}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-darwin-x64@0.5.4:
- resolution: {integrity: sha512-+8kvYjN9IllQSSzTrKp74Cf2efFNJZNMk6PWoOeakk43+Z1BgMgzLJTs/1xIDFhzylvLSMYSLO8AhbMMX48TCw==}
+ /@rspack/binding-darwin-x64@0.5.7:
+ resolution: {integrity: sha512-4THSPWVKPMSSD/y3/TWZ5xlSeh1B33I+YnBu/Y3lDFcFrFPtc3ojIDHw3is6l2wcACX6Rro4RgN6zcUij7eEmQ==}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-linux-arm64-gnu@0.5.4:
- resolution: {integrity: sha512-mXtRKCblBT+H1KPWUfeJt6gQFGoMt+lnhk2POcoCeS1AxnxcTFpnci4BC4Ro5zKS2QWSdGdUMtc5GKlBmgwxvg==}
+ /@rspack/binding-linux-arm64-gnu@0.5.7:
+ resolution: {integrity: sha512-JB9FAYWjYAeNCPFh0mQu3SZdFHiA+EY37z1AktLDl789SoEec2HPGkvvOs+OIET1pKWgjUGD4Z4Uq4P/r5JFNA==}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-linux-arm64-musl@0.5.4:
- resolution: {integrity: sha512-P96R8yLT4BKtwYCtomIJE4uIGAh+5I8qLbrTrGamj/6N1D79GgwORW6CllCEnVU9l/Tjkdd+yMJkT9zoACa9gQ==}
+ /@rspack/binding-linux-arm64-musl@0.5.7:
+ resolution: {integrity: sha512-3fNhPvA9Kj/L7rwr2Pj1bvxWBLBgqfkqSvt91iUxPbxgfTiSBQh0Tfb9+hkHv2VCTyNQI/vytkOH+4i4DNXCBw==}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-linux-x64-gnu@0.5.4:
- resolution: {integrity: sha512-/EjM7CkALS7uUF0laVp+wtOICrX2sR5gy4liIYVHKDLu+b4PGRtEQvubrDxikkzPpOYRvF38R7OBMUOJBuBW7A==}
+ /@rspack/binding-linux-x64-gnu@0.5.7:
+ resolution: {integrity: sha512-y/GnXt1hhbKSqzBSy+ALWwievlejQhIIF8FPXL1kKFh60zl7DE+iYHSJ128jIJiph9dQkBnHw0ABJ5D+vbSqdA==}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-linux-x64-musl@0.5.4:
- resolution: {integrity: sha512-dMT9QW4IZ7IGzczsOmzdpGf84IzIecvitSwj7DnulRkxj3++IWLAo80+HDtgn+nPm+1gNVFb11wg5L9x+VjFXw==}
+ /@rspack/binding-linux-x64-musl@0.5.7:
+ resolution: {integrity: sha512-US/FUv6cvbxbe4nymINwer/EQTvGEgCaAIrvKuAP0yAfK0eyqIHYZj/zCBM2qOS69Mpc2FWVMC/ftRyCvAz/xw==}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-win32-arm64-msvc@0.5.4:
- resolution: {integrity: sha512-SsnOqWRw5VQnbz/63wtKsoyj6lfUpQQZyFWfQAMsNt8suIauWI/kf3QLWL/vmBX5Q24Sq16Kl5cMIjxAIJQfiQ==}
+ /@rspack/binding-win32-arm64-msvc@0.5.7:
+ resolution: {integrity: sha512-g7NWXa5EGvh6j1VPXGOFaWuOVxdPYYLh3wpUl46Skrd6qFZKB2r+yNhuXo6lqezwYvbtHEDrmFOHF2S6epXO5g==}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-win32-ia32-msvc@0.5.4:
- resolution: {integrity: sha512-xLlUHn712WhnWN40JeljQCiWBIRd/meMRKSEqTJJdZfNwozd4cZUbq5rxexX6HNjZvkwLACpATDotPVfCKPjbQ==}
+ /@rspack/binding-win32-ia32-msvc@0.5.7:
+ resolution: {integrity: sha512-5Udt4pYpPSd1wlbVKTdWzjha8oV+FQ/EXILHhoS9G7l9rbpqhMs6oIqAgEavQS3t6fKtQU837b+MSBNprudTtw==}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding-win32-x64-msvc@0.5.4:
- resolution: {integrity: sha512-33IBq3yuJTyUKhTGbPwP/kvSf58wpOCBdPvye+ExNSw0uEVwXMs2AqDWDnbBPtZjP8DVN/zu0EoeLhYk9fwkYg==}
+ /@rspack/binding-win32-x64-msvc@0.5.7:
+ resolution: {integrity: sha512-tB/SB27BBDVV0+GpEUHkl2uanCP4Jk/hlnbvl5u6lSGcIxCFm+da4OsyiGDRE24bSEdMc91dmyWVlx5425je+A==}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
- /@rspack/binding@0.5.4:
- resolution: {integrity: sha512-WoAq+pkNAe4jetIwIoUbiqO4cLSvpll90GtpYHqaNS9r9n28l4LBQY/A15W0/XBZeoj0wvMkYEvEZtn64PULLw==}
+ /@rspack/binding@0.5.7:
+ resolution: {integrity: sha512-47MX6wNF1lP/LdShPVhbg689FX1W96Zji7QgbxhRhXmkpOKor7gdajhxqszFHxHYJtqNTLA9BSG38rpIGxJ+fw==}
optionalDependencies:
- '@rspack/binding-darwin-arm64': 0.5.4
- '@rspack/binding-darwin-x64': 0.5.4
- '@rspack/binding-linux-arm64-gnu': 0.5.4
- '@rspack/binding-linux-arm64-musl': 0.5.4
- '@rspack/binding-linux-x64-gnu': 0.5.4
- '@rspack/binding-linux-x64-musl': 0.5.4
- '@rspack/binding-win32-arm64-msvc': 0.5.4
- '@rspack/binding-win32-ia32-msvc': 0.5.4
- '@rspack/binding-win32-x64-msvc': 0.5.4
- dev: true
-
- /@rspack/core@0.5.4(patch_hash=cx7wc7uikmrb5dsrfcy5wrjzui)(@swc/helpers@0.5.1):
- resolution: {integrity: sha512-3yxOllEC93gf4pNiLlgtzE8dPo0QV2naQY24gAPk+EoWlwpmR6p1r7ZdD53etFZPGB4hMm78J/zgwx8jy1TRsw==}
+ '@rspack/binding-darwin-arm64': 0.5.7
+ '@rspack/binding-darwin-x64': 0.5.7
+ '@rspack/binding-linux-arm64-gnu': 0.5.7
+ '@rspack/binding-linux-arm64-musl': 0.5.7
+ '@rspack/binding-linux-x64-gnu': 0.5.7
+ '@rspack/binding-linux-x64-musl': 0.5.7
+ '@rspack/binding-win32-arm64-msvc': 0.5.7
+ '@rspack/binding-win32-ia32-msvc': 0.5.7
+ '@rspack/binding-win32-x64-msvc': 0.5.7
+ dev: true
+
+ /@rspack/core@0.5.7(patch_hash=hydgitlae4ar2jrvgl5qp2f2um)(@swc/helpers@0.5.1):
+ resolution: {integrity: sha512-gUF0PcanPrC2cVfFA4e+qmG66X7FkEKlRbnaUfB4LKw9JQuwiMOXCAtrBdveDjB89KE/3cw/nuYVQwd106uqWA==}
engines: {node: '>=16.0.0'}
peerDependencies:
'@swc/helpers': '>=0.5.1'
@@ -7881,16 +7906,15 @@ packages:
optional: true
dependencies:
'@module-federation/runtime-tools': 0.0.8
- '@rspack/binding': 0.5.4
+ '@rspack/binding': 0.5.7
'@swc/helpers': 0.5.1
- browserslist: 4.22.1
+ browserslist: 4.22.3
enhanced-resolve: 5.12.0
events: 3.3.0
graceful-fs: 4.2.10
json-parse-even-better-errors: 3.0.0
neo-async: 2.6.2
tapable: 2.2.1
- terminal-link: 2.1.1
watchpack: 2.4.0
webpack-sources: 3.2.3
zod: 3.22.3
@@ -7898,12 +7922,12 @@ packages:
dev: true
patched: true
- /@rspack/dev-server@0.5.4(@rspack/core@0.5.4)(@types/express@4.17.17)(webpack@5.88.2):
- resolution: {integrity: sha512-fwJGXCgv38paLkY7yIp3+nTxC/DQ3G2c7qh7UPyr4m3Jrb2X1YdATKE+JOIDd8++P8w/ug4d0Zj0xuwY89zFIA==}
+ /@rspack/dev-server@0.5.7(@rspack/core@0.5.7)(@types/express@4.17.17)(webpack@5.88.2):
+ resolution: {integrity: sha512-CqPZLRq7QCr6EQqYIBFeIeWemXh1TM2RPc3ZZ1Gap+6/KJuRTMIYv/Q3mSQqLET7dn+HQYSWPSoTciJmPu6zCw==}
peerDependencies:
'@rspack/core': '*'
dependencies:
- '@rspack/core': 0.5.4(patch_hash=cx7wc7uikmrb5dsrfcy5wrjzui)(@swc/helpers@0.5.1)
+ '@rspack/core': 0.5.7(patch_hash=hydgitlae4ar2jrvgl5qp2f2um)(@swc/helpers@0.5.1)
chokidar: 3.5.3
connect-history-api-fallback: 2.0.0
express: 4.18.1
@@ -7922,8 +7946,8 @@ packages:
- webpack-cli
dev: true
- /@rspack/plugin-react-refresh@0.5.4(react-refresh@0.14.0):
- resolution: {integrity: sha512-neyCo1bBhTUriu2dSCu6FHQuILKDiKRokIy8B4V3hhequvW6F8EZ1rLcLoHfeikRIzC3ehJxOIuAj2sq6AiJMg==}
+ /@rspack/plugin-react-refresh@0.5.7(react-refresh@0.14.0):
+ resolution: {integrity: sha512-VDVzr0vkBpCeUL7m5PZK7OqB3M+sfSrlkt/1jxFM2sleaRmukxX9Pn+nIYopDbB47HkldotP/GeXCjUwfpAKug==}
peerDependencies:
react-refresh: '>=0.10.0 <1.0.0'
peerDependenciesMeta:
@@ -10614,7 +10638,6 @@ packages:
electron-to-chromium: 1.4.656
node-releases: 2.0.14
update-browserslist-db: 1.0.13(browserslist@4.22.3)
- dev: true
/bs-logger@0.2.6:
resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==}
@@ -10814,7 +10837,7 @@ packages:
/caniuse-api@3.0.0:
resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==}
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
caniuse-lite: 1.0.30001564
lodash.memoize: 4.1.2
lodash.uniq: 4.5.0
@@ -10827,7 +10850,6 @@ packages:
/caniuse-lite@1.0.30001584:
resolution: {integrity: sha512-LOz7CCQ9M1G7OjJOF9/mzmqmj3jE/7VOmrfw6Mgs0E8cjOsbRXQJHsPBfmBOXDskXKrHLyyW3n7kpDW/4BsfpQ==}
- dev: true
/caseless@0.12.0:
resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}
@@ -11398,7 +11420,7 @@ packages:
/core-js-compat@3.29.0:
resolution: {integrity: sha512-ScMn3uZNAFhK2DGoEfErguoiAHhV2Ju+oJo/jK08p7B3f3UhocUrCCkTvnZaiS+edl5nlIoiBXKcwMc6elv4KQ==}
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
/core-js-pure@3.29.0:
resolution: {integrity: sha512-v94gUjN5UTe1n0yN/opTihJ8QBWD2O8i19RfTZR7foONPWArnjB96QA/wk5ozu1mm6ja3udQCzOzwQXTxi3xOQ==}
@@ -12412,7 +12434,6 @@ packages:
/electron-to-chromium@1.4.656:
resolution: {integrity: sha512-9AQB5eFTHyR3Gvt2t/NwR0le2jBSUNwCnMbUCejFWHD+so4tH40/dRLgoE+jxlPeWS43XJewyvCv+I8LPMl49Q==}
- dev: true
/emittery@0.10.2:
resolution: {integrity: sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw==}
@@ -17157,7 +17178,6 @@ packages:
/node-releases@2.0.14:
resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==}
- dev: true
/normalize-package-data@2.5.0:
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
@@ -17796,7 +17816,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
caniuse-api: 3.0.0
colord: 2.9.3
postcss: 8.4.31
@@ -17808,7 +17828,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
postcss: 8.4.31
postcss-value-parser: 4.2.0
@@ -18103,7 +18123,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
caniuse-api: 3.0.0
cssnano-utils: 3.1.0(postcss@8.4.31)
postcss: 8.4.31
@@ -18135,7 +18155,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
cssnano-utils: 3.1.0(postcss@8.4.31)
postcss: 8.4.31
postcss-value-parser: 4.2.0
@@ -18292,7 +18312,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
postcss: 8.4.31
postcss-value-parser: 4.2.0
@@ -18447,7 +18467,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
caniuse-api: 3.0.0
postcss: 8.4.31
@@ -21553,7 +21573,7 @@ packages:
peerDependencies:
postcss: ^8.2.15
dependencies:
- browserslist: 4.22.1
+ browserslist: 4.22.3
postcss: 8.4.31
postcss-selector-parser: 6.0.11
@@ -22689,7 +22709,6 @@ packages:
browserslist: 4.22.3
escalade: 3.1.1
picocolors: 1.0.0
- dev: true
/update-notifier@5.1.0:
resolution: {integrity: sha512-ItnICHbeMh9GqUy31hFPrD1kcuZ3rpxDZbf4KUDavXwS0bW5m7SLbDQpGX3UYr072cbrF5hFUs3r5tUsPwjfHw==}
diff --git a/tests/integration/with-dynamic.test.ts b/tests/integration/with-dynamic.test.ts
new file mode 100644
index 0000000000..2aff930b90
--- /dev/null
+++ b/tests/integration/with-dynamic.test.ts
@@ -0,0 +1,100 @@
+import * as path from 'path';
+import * as fs from 'fs';
+import { fileURLToPath } from 'url';
+import { expect, test, describe, afterAll, beforeAll } from 'vitest';
+import { buildFixture, setupBrowser } from '../utils/build';
+import type { Page } from '../utils/browser';
+import type Browser from '../utils/browser';
+
+// @ts-ignore
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+
+const example = 'with-dynamic';
+
+describe(`build ${example}`, () => {
+ let page: Page;
+ let browser: Browser;
+
+ beforeAll(async () => {
+ await buildFixture(example);
+ const res = await setupBrowser({ example });
+
+ page = res.page;
+ browser = res.browser;
+ });
+
+ describe('normal case', () => {
+ test('basic case', async () => {
+ const htmlPath = '/normal/basic.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+
+ expect(htmlContent.includes('"renderMode":"SSG"')).toBe(true);
+ expect(htmlContent.includes('normal fallback
')).toBe(true);
+ expect(htmlContent.includes('normal text
')).toBe(true);
+ });
+
+ test('should support call w/ a bare import', async () => {
+ const htmlPath = '/normal/bare-import.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+
+ expect(htmlContent.includes('"renderMode":"SSG"')).toBe(true);
+ expect(htmlContent.includes('
bare import fallback
')).toBe(true);
+ expect(htmlContent.includes('
normal text
')).toBe(true);
+ });
+
+ test('should support name export', async () => {
+ const htmlPath = '/normal/name-export.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+
+ expect(htmlContent.includes('"renderMode":"SSG"')).toBe(true);
+ expect(htmlContent.includes('
')).toBe(true);
+ });
+ });
+
+ describe('non-ssr pkg case', () => {
+ test('should downgrade when ssr w/o fallback', async () => {
+ const htmlPath = '/nonssr/ssr-no-fallback.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+
+ expect(await page.$$text('#app')).toStrictEqual(['']);
+ expect(htmlContent.includes('"renderMode":"CSR"')).toBe(true);
+ expect(htmlContent.includes('"downgrade":true')).toBe(true);
+ });
+
+ test('should not downgrade when no ssr no fallback', async () => {
+ const htmlPath = '/nonssr/no-ssr-no-fallback.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+ expect(await page.$$text('#app')).toStrictEqual(['']);
+ expect(htmlContent.includes('"renderMode":"SSG"')).toBe(true);
+ expect(htmlContent.includes('"downgrade":true')).toBe(false);
+ });
+
+ test('should not downgrade and display fallback when no ssr with fallback', async () => {
+ const htmlPath = '/nonssr/no-ssr-fallback.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+ expect(await page.$$text('#app')).toStrictEqual(['fallback']);
+ expect(htmlContent.includes('"renderMode":"SSG"')).toBe(true);
+ expect(htmlContent.includes('"downgrade":true')).toBe(false);
+ });
+
+ test('should downgrade w/o using dynamic', async () => {
+ const htmlPath = '/nonssr/without-dynamic.html';
+ await page.push(htmlPath);
+ const htmlContent = fs.readFileSync(path.join(__dirname, `../../examples/${example}/build${htmlPath}`), 'utf-8');
+
+ expect(await page.$$text('#app')).toStrictEqual(['']);
+ expect(htmlContent.includes('"renderMode":"CSR"')).toBe(true);
+ expect(htmlContent.includes('"downgrade":true')).toBe(true);
+ });
+ });
+
+ afterAll(async () => {
+ await browser.close();
+ });
+});
diff --git a/vitest.config.ts b/vitest.config.ts
index b82be6202b..388f195e29 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -12,6 +12,7 @@ export default defineConfig({
},
test: {
testTimeout: 120000,
+ hookTimeout: 120000,
// To avoid error `Segmentation fault (core dumped)` in CI environment, disable threads
// ref: https://github.com/vitest-dev/vitest/issues/317
threads: false,
diff --git a/website/docs/guide/advanced/integrate-from-rax.md b/website/docs/guide/advanced/integrate-from-rax.md
index 1b448e9e89..9acca2dd8c 100644
--- a/website/docs/guide/advanced/integrate-from-rax.md
+++ b/website/docs/guide/advanced/integrate-from-rax.md
@@ -5,17 +5,6 @@ order: 0901
本文档面向的是使用 Rax App 的开发者,提供迁移到 ice.js 的方式。React 的社区生态显著优于 Rax,切换到 React 之后可以享受到更多的 React 生态,复用复杂场景(富文本、脑图等)社区生态可以大幅度降低成本。
-:::caution
-对于 Rax 小程序的用户,如果你没有使用到以下与原生小程序结合较为紧密的能力,则可以正常参考本文档进行迁移。
-
-- 引入原生 app.js、原生页面、原生自定义组件、小程序插件
-- 引入 Rax 编译时组件
-- 注册页面生命周期及事件
-- 分包加载
-
-如果使用到以上能力,则需要参考 ice.js 文档进行相应能力的迁移。
-:::
-
## ice.js 与 Rax App 的差异
ice.js 和 Rax App 都是应用研发框架,它们默认使用的 UI Framework 不同,前者使用 React,而后者使用 rax.js。但是在 ice.js 3.x 中,你可以使用 [Rax 兼容模式](./rax-compat.md)来运行 Rax 组件。
diff --git a/website/docs/guide/basic/api.md b/website/docs/guide/basic/api.md
index 4e598f2b82..833b841cc6 100644
--- a/website/docs/guide/basic/api.md
+++ b/website/docs/guide/basic/api.md
@@ -55,10 +55,6 @@ export function historyPush (link: string) {
### useParams
-:::caution
-小程序端不支持该 API。
-:::
-
useParams 函数返回动态路由的匹配参数信息。
```tsx
@@ -79,11 +75,6 @@ export default function Home() {
### useSearchParams
-:::caution
-小程序端会返回当前页面 `Page.onLoad` 生命周期返回的 query 参数。
-同时小程序端不支持修改 query string,即调用该 API 返回的 `setSearchParams` 不会生效。
-:::
-
useSearchParams 用于读取和修改当前 URL 的 query string。
```tsx
@@ -109,10 +100,6 @@ export default function Home() {
### useNavigate
-:::caution
-小程序端不支持该 API。可通过 Link 组件或 history 或小程序原生 API 进行跳转。
-:::
-
useNavigate 函数返回一个可以控制跳转的函数,用于组件内部控制路径跳转
```tsx
@@ -134,10 +121,6 @@ export default function Home() {
### useLocation
-:::caution
-小程序端不支持该 API。
-:::
-
useLocation 返回当前 location 信息。
```tsx
@@ -217,10 +200,6 @@ export const pageConfig = definePageConfig(() => ({
### useMounted
-:::caution
-小程序端不支持该 API。
-:::
-
该方法会在 React Hydrate 完成后返回 `true`,一般在开启 SSR/SSG 的应用中,用于控制在不同端中渲染不同的组件。
:::caution
@@ -270,10 +249,6 @@ function Document() {
### `
`
-:::caution
-小程序端不支持该组件。
-:::
-
`
` 组件只允许在 React Hydrate 完成后在 Client 端中渲染组件。
:::tip
@@ -315,20 +290,57 @@ export function Home () {
};
```
-### `
`
-:::caution
-小程序端不支持该组件。
-:::
+### dynamic
+
+`dynamic` API 是用于动态加载组件的 API,用于按需加载组件,并且通过参数配置可以控制组件在 Node 服务下的加载执行行为。
+
+基础使用方式:
+
+```tsx
+import { dynamic } from 'ice';
+
+const ComponentA = dynamic(() => import('../components/A'));
+const ComponentB = dynamic(() => import('../components/B'));
+const ComponentC = dynamic(() => import('../components/C'), { ssr: false });
+
+export default function Home({ show }) {
+ return (
+ <>
+ {/* 渲染组件时直接加载,ComponentA 代码将拆分到额外的 bundle 中 */}
+
+ {/* 仅在 show 为 true 时,加载 ComponentB,表现同 dynamic import */}
+ {show &&
}
+ {/* 不会在 Node 服务端加载渲染,仅在浏览器端渲染,对于组件内容依赖 window 等 client 端变量的组件可以快速兼容*/}
+
+ >
+ );
+}
+```
+
+使用 fallback 方式:
+
+```tsx
+import { dynamic } from 'ice';
+
+const ComponentA = dynamic(() => import('../components/A'), { fallback:
loading...
});
+
+export default function Home({ show }) {
+ return (
+ <>
+ {/* 在 ComponentA 代码加载过程中将显示 fallback 内容 */}
+
+ >
+ );
+}
+```
+
+### `
`
缓存所有路由组件的状态。详细使用方式参考 [Keep Alive 文档](../advanced/keep-alive/#缓存路由组件)。
### `
`
-:::info
-在小程序端 Link 组件底层为原生 `navigator` 组件。
-:::
-
`
` 是 React 组件,用于渲染带路由跳转功能的 `
` 元素。
```tsx
@@ -348,10 +360,6 @@ function Home() {
### ` `
-:::caution
-小程序端不支持该组件。
-:::
-
`` 用于渲染父路由中渲染子路由,通常出现在 `layout.tsx` Layout 组件中。
```tsx title="src/layout.tsx"
@@ -396,8 +404,5 @@ import type { RouteConfig } from 'ice';
### Document 组件
-:::caution
-小程序端不支持该组件。
-:::
`Meta`、`Title`、`Links`、`Scripts` 和 `Main` 组件仅支持在 `src/document.tsx` 中使用,使用场景参考 [Document 文档](./document)
diff --git a/website/docs/guide/basic/app.md b/website/docs/guide/basic/app.md
index 017b7ce00f..2e4b0b4bd8 100644
--- a/website/docs/guide/basic/app.md
+++ b/website/docs/guide/basic/app.md
@@ -34,10 +34,6 @@ export default defineAppConfig(() => ({
- 类型:`string`
- 默认值:`ice-container`
-:::tip
-小程序端不支持修改 rootId。
-:::
-
#### `strict`
是否开启 React 的严格模式 (React.StrictMode)
@@ -54,10 +50,6 @@ export default defineAppConfig(() => ({
### router
-:::tip
-小程序端不支持 `router` 配置。关于小程序的 `router` 配置参考[小程序开发-路由](../miniapp/router)
-:::
-
#### `type`
路由类型
diff --git a/website/docs/guide/basic/config.md b/website/docs/guide/basic/config.md
index 271cccdf94..25ad5ed6fa 100644
--- a/website/docs/guide/basic/config.md
+++ b/website/docs/guide/basic/config.md
@@ -57,10 +57,6 @@ export default defineConfig(() => ({
### crossOriginLoading
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`false | 'anonymous' | 'use-credentials'`
- 默认值:`false`
@@ -121,10 +117,6 @@ console.log(AGE);
### publicPath
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`string`
- 默认值:`/`
@@ -139,10 +131,6 @@ console.log(AGE);
### hash
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`boolean | string`
- 默认值:`false`
@@ -158,10 +146,6 @@ export default defineConfig(() => ({
### externals
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`Record`
- 默认值:`{}`
@@ -208,10 +192,6 @@ export default Document;
### proxy
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`object`
- 默认值:`{}`
@@ -402,10 +382,6 @@ export default defineConfig(() => ({
### ssr
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`boolean`
- 默认值:`false`
@@ -413,10 +389,6 @@ export default defineConfig(() => ({
### ssg
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`boolean`
- 默认值:`true`
@@ -424,10 +396,6 @@ export default defineConfig(() => ({
### server
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`{ format: 'esm' | 'cjs'; bundle: boolean; ignores: IgnorePattern[]; externals: string[]; onDemand: boolean; }`
- 默认值:`{ format: 'esm', bundle: false, ignores: [], externals: [], onDemand: false }`
@@ -491,10 +459,6 @@ export default defineConfig(() => ({
### routes
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`{ ignoreFiles: string[]; defineRoutes: (route: DefineRouteFunction) => void }`
- 默认值:`{}`
@@ -592,8 +556,7 @@ export default defineConfig({
### splitChunks @deprecated
:::caution
-不再建议使用,能力由 codeSplitting 替代。
-小程序端不支持该配置。
+不再建议使用,能力由 codeSplitting 替代
:::
默认会根据模块体积自动拆分 chunks,有可能会出现多个 bundle。如果不希望打包产物出现过多 bundle ,可设置成 `false`。
@@ -639,10 +602,6 @@ ice.js 内置了大量 ES 语法支持,便于开发者进行编码。对于 [p
### mock
-:::caution
-小程序端不支持该配置。
-:::
-
- 类型:`{ exclude: string[] }`
- 默认值:`{}`
@@ -731,4 +690,28 @@ export default defineConfig(() => ({
}));
```
+### optimization
+
+- 类型:`{ disableRouter: boolean; optimizePackageImport: boolean | string[] }`
+- 默认值:`{}`
+
+框架提供内置的优化能力,针对不同场景提供优化策略:
+- `disableRouter`:默认为 `false`,如果希望关闭路由能力,可以设置为 `true`。主要应用不存在依赖路由能力的场景,比如不存在 SPA 页面跳转。
+- `optimizePackageImport`:默认为 `false`,开启后框架默认会对已知三方依赖进行按需加载,项目的构建体验将进一步提升,内置三方依赖列表参考[代码](https://github.com/alibaba/ice/blob/1989fc18fa26230e91322e225dd20633d268a26b/packages/ice/src/config.ts#L364-L421)。
+
+
+参考配置:
+```js
+import { defineConfig } from '@ice/app';
+
+export default defineConfig(() => ({
+ optimization: {
+ disableRouter: true,
+ // optimizePackageImport 配置为 true 则使用内置的三方依赖列表,如果配置为数组则会在内置列表基础上追加
+ optimizePackageImport: ['@ice/components'],
+ },
+}));
+```
+
+
> 如有定制需求欢迎👏 PR 或反馈:
diff --git a/website/docs/guide/basic/document.md b/website/docs/guide/basic/document.md
index 1a5ef8a576..d21ddb8dd9 100644
--- a/website/docs/guide/basic/document.md
+++ b/website/docs/guide/basic/document.md
@@ -3,10 +3,6 @@ title: 定制 HTML
order: 12
---
-:::tip
-小程序端不支持该能力。
-:::
-
ice.js 使用 JSX 维护页面的 HTML 模板结构,其入口位于 `src/document.tsx`。
## 初始模板
@@ -223,4 +219,4 @@ function Document() {