diff --git a/.changeset/new-lamps-argue.md b/.changeset/new-lamps-argue.md new file mode 100644 index 0000000000..44a745b413 --- /dev/null +++ b/.changeset/new-lamps-argue.md @@ -0,0 +1,5 @@ +--- +'@ice/app': patch +--- + +fix: compatible with dynamic routes when disable lazy import diff --git a/examples/routes-generate/ice.config.mts b/examples/routes-generate/ice.config.mts index 7fe6668fd0..4e84aa7555 100644 --- a/examples/routes-generate/ice.config.mts +++ b/examples/routes-generate/ice.config.mts @@ -1,6 +1,7 @@ import { defineConfig } from '@ice/app'; export default defineConfig(() => ({ + codeSplitting: false, routes: { ignoreFiles: ['about.tsx', 'products.tsx'], defineRoutes: (route) => { diff --git a/packages/ice/src/routes.ts b/packages/ice/src/routes.ts index 4b32c975ca..5717261188 100644 --- a/packages/ice/src/routes.ts +++ b/packages/ice/src/routes.ts @@ -62,7 +62,8 @@ export function getRoutesDefination(nestRouteManifest: NestedRouteManifest[], la if (lazy) { loadStatement = `import(/* webpackChunkName: "p_${componentName}" */ '${formatPath(componentPath)}')`; } else { - const camelComponentName = componentName.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()); + // Consider the case of the component name is `page-$id`. + const camelComponentName = componentName.replace(/-(\w|\$)/g, (_, letter) => letter.toUpperCase()); routeImports.push(`import * as ${camelComponentName} from '${formatPath(componentPath)}';`); loadStatement = camelComponentName; }