From a0cf65adadf83886ad7ef28ffb112d805bbba2d5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 16 Aug 2022 11:27:45 -0400 Subject: [PATCH] use LayoutLoad inside +layout.js files --- .changeset/rare-spiders-ring.md | 5 +++++ packages/migrate/migrations/routes/migrate_page_js/index.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/rare-spiders-ring.md diff --git a/.changeset/rare-spiders-ring.md b/.changeset/rare-spiders-ring.md new file mode 100644 index 000000000000..45de42c65ca5 --- /dev/null +++ b/.changeset/rare-spiders-ring.md @@ -0,0 +1,5 @@ +--- +'svelte-migrate': patch +--- + +Use LayoutLoad inside +layout.js files diff --git a/packages/migrate/migrations/routes/migrate_page_js/index.js b/packages/migrate/migrations/routes/migrate_page_js/index.js index 5f60b7d49431..308a9b9d08fb 100644 --- a/packages/migrate/migrations/routes/migrate_page_js/index.js +++ b/packages/migrate/migrations/routes/migrate_page_js/index.js @@ -37,8 +37,8 @@ export function migrate_page(content, filename) { return content; } - const match = /\+(?:(page)|(layout(?:-([^.@]+))?))/.exec(filename); - const load_name = match?.[3] ? `LayoutLoad.${match[3]}` : match?.[2] ? `LayoutLoad` : 'PageLoad'; + const match = /__layout(?:-([^.@]+))?/.exec(filename); + const load_name = match?.[1] ? `LayoutLoad.${match[1]}` : match ? `LayoutLoad` : 'PageLoad'; for (const statement of file.ast.statements) { const fn = name ? get_function_node(statement, name) : undefined;