diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts index 89cdae41ad..c9c4868821 100644 --- a/packages/router-plugin/src/core/code-splitter/compilers.ts +++ b/packages/router-plugin/src/core/code-splitter/compilers.ts @@ -623,7 +623,7 @@ export function compileCodeSplitReferenceRoute( ) { programPath.unshiftContainer('body', [ template.statement( - `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`, + `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl.replace(/'/g, "\\'")}')`, )(), ]) } @@ -719,7 +719,7 @@ export function compileCodeSplitReferenceRoute( ) { programPath.unshiftContainer('body', [ template.statement( - `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`, + `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl.replace(/'/g, "\\'")}')`, )(), ]) }