diff --git a/.changeset/plenty-shirts-pull.md b/.changeset/plenty-shirts-pull.md new file mode 100644 index 000000000000..602da2dc54f5 --- /dev/null +++ b/.changeset/plenty-shirts-pull.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] allow `@` route breakouts to layouts in `[foo]` or `(foo)` directories diff --git a/packages/kit/src/core/sync/create_manifest_data/index.js b/packages/kit/src/core/sync/create_manifest_data/index.js index aa10db01d13d..d39282fa446e 100644 --- a/packages/kit/src/core/sync/create_manifest_data/index.js +++ b/packages/kit/src/core/sync/create_manifest_data/index.js @@ -321,7 +321,7 @@ function analyze(project_relative, file, component_extensions, module_extensions const component_extension = component_extensions.find((ext) => file.endsWith(ext)); if (component_extension) { const name = file.slice(0, -component_extension.length); - const pattern = /^\+(?:(page(?:@([a-zA-Z0-9_-]*))?)|(layout(?:@([a-zA-Z0-9_-]*))?)|(error))$/; + const pattern = /^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/; const match = pattern.exec(name); if (!match) { // TODO remove for 1.0 diff --git a/packages/kit/src/core/sync/create_manifest_data/index.spec.js b/packages/kit/src/core/sync/create_manifest_data/index.spec.js index f22ab207c262..4d2596e23d8e 100644 --- a/packages/kit/src/core/sync/create_manifest_data/index.spec.js +++ b/packages/kit/src/core/sync/create_manifest_data/index.spec.js @@ -494,7 +494,11 @@ test('creates routes with named layouts', () => { { component: 'samples/named-layouts/b/c/c2/+page@.svelte', parent_id: '' }, // 11 { component: 'samples/named-layouts/b/d/(special)/+page.svelte' }, // 12 { component: 'samples/named-layouts/b/d/(special)/(extraspecial)/d2/+page.svelte' }, // 13 - { component: 'samples/named-layouts/b/d/d1/+page.svelte' } // 14 + { + component: 'samples/named-layouts/b/d/(special)/(extraspecial)/d3/+page@(special).svelte', + parent_id: '(special)' + }, // 14 + { component: 'samples/named-layouts/b/d/d1/+page.svelte' } // 15 ]); assert.equal(routes.filter((route) => route.page).map(simplify_route), [ @@ -521,7 +525,7 @@ test('creates routes with named layouts', () => { { id: 'b/d/d1', pattern: '/^/b/d/d1/?$/', - page: { layouts: [0], errors: [1], leaf: 14 } + page: { layouts: [0], errors: [1], leaf: 15 } }, { id: '(special)/(alsospecial)/b/c/c1', @@ -532,6 +536,11 @@ test('creates routes with named layouts', () => { id: 'b/d/(special)/(extraspecial)/d2', pattern: '/^/b/d/d2/?$/', page: { layouts: [0, 6, 7], errors: [1, undefined, undefined], leaf: 13 } + }, + { + id: 'b/d/(special)/(extraspecial)/d3', + pattern: '/^/b/d/d3/?$/', + page: { layouts: [0, 6], errors: [1, undefined], leaf: 14 } } ]); }); diff --git a/packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/(extraspecial)/d3/+page@(special).svelte b/packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/(extraspecial)/d3/+page@(special).svelte new file mode 100644 index 000000000000..e69de29bb2d1