Skip to content

Commit

Permalink
Merge branch 'main' into chore/unify-migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel3108 committed Jan 10, 2025
2 parents 969433e + e87dfd2 commit f34bb2f
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 35 deletions.
5 changes: 0 additions & 5 deletions .changeset/chatty-queens-judge.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/stale-ties-move.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/strange-ducks-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': minor
---

feat: allow sub path migration or none at all for Svelte 5 migration
5 changes: 0 additions & 5 deletions .changeset/wet-students-taste.md

This file was deleted.

2 changes: 1 addition & 1 deletion documentation/docs/20-commands/40-sv-migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npx sv migrate [migration]

### `app-state`

Migrates `$app/store` usage to `$app/state` in `.svelte` files. See the [migration guide](/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated) for more details.
Migrates `$app/stores` usage to `$app/state` in `.svelte` files. See the [migration guide](/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated) for more details.

### `svelte-5`

Expand Down
1 change: 1 addition & 0 deletions packages/addons/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineAddon({
sv.devDependency('@eslint/compat', '^1.2.3');
sv.devDependency('globals', '^15.0.0');
sv.devDependency('eslint-plugin-svelte', '^2.36.0');
sv.devDependency('@eslint/js', '^9.17.0');

if (typescript) sv.devDependency('typescript-eslint', '^8.0.0');

Expand Down
4 changes: 2 additions & 2 deletions packages/addons/paraglide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default defineAddon({

imports.addDefault(script.ast, '$lib/paraglide/messages.js', '* as m');
imports.addNamed(script.ast, '$app/navigation', { goto: 'goto' });
imports.addNamed(script.ast, '$app/stores', { page: 'page' });
imports.addNamed(script.ast, '$app/state', { page: 'page' });
imports.addNamed(script.ast, '$lib/i18n', { i18n: 'i18n' });
if (typescript) {
imports.addNamed(
Expand All @@ -253,7 +253,7 @@ export default defineAddon({
${ts('', '* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage')}
${ts('', '*/')}
function switchToLanguage(newLanguage${ts(': AvailableLanguageTag')}) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# sv

## 0.6.11
### Patch Changes


- fix: properly add `eslint` dependency ([#375](https://github.com/sveltejs/cli/pull/375))


- feat: migrate to `$app/state` ([#358](https://github.com/sveltejs/cli/pull/358))

## 0.6.10
### Patch Changes


- fix: correctly resolve package manager commands in `create`'s next-steps ([#360](https://github.com/sveltejs/cli/pull/360))


- fix: don't generate sourcemaps for release ([#373](https://github.com/sveltejs/cli/pull/373))


- chore: update-dependencies ([#356](https://github.com/sveltejs/cli/pull/356))


- fix: make `lucia` validation error messages more descriptive ([#363](https://github.com/sveltejs/cli/pull/363))

## 0.6.9
### Patch Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sv",
"version": "0.6.9",
"version": "0.6.11",
"type": "module",
"description": "A CLI for creating and updating SvelteKit projects",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/js/common/jsdoc-comment/input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function switchToLanguage(newLanguage) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
2 changes: 1 addition & 1 deletion packages/core/tests/js/common/jsdoc-comment/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage
*/
function switchToLanguage(newLanguage) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
8 changes: 4 additions & 4 deletions packages/create/templates/demo/src/routes/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { page } from '$app/stores';
import { page } from '$app/state';
import logo from '$lib/images/svelte-logo.svg';
import github from '$lib/images/github.svg';
</script>
Expand All @@ -16,13 +16,13 @@
<path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" />
</svg>
<ul>
<li aria-current={$page.url.pathname === '/' ? 'page' : undefined}>
<li aria-current={page.url.pathname === '/' ? 'page' : undefined}>
<a href="/">Home</a>
</li>
<li aria-current={$page.url.pathname === '/about' ? 'page' : undefined}>
<li aria-current={page.url.pathname === '/about' ? 'page' : undefined}>
<a href="/about">About</a>
</li>
<li aria-current={$page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
<li aria-current={page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
<a href="/sverdle">Sverdle</a>
</li>
</ul>
Expand Down
6 changes: 6 additions & 0 deletions packages/migrate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# svelte-migrate

## 1.7.1
### Patch Changes


- chore: update-dependencies ([#356](https://github.com/sveltejs/cli/pull/356))

## 1.7.0
### Minor Changes

Expand Down
41 changes: 34 additions & 7 deletions packages/migrate/migrations/svelte-5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export async function migrate() {
bail('Please re-run this script in a directory with a package.json');
}

p.log.warning(
'This migration is experimental — please report any bugs to https://github.com/sveltejs/svelte/issues'
);

const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));

const svelte_dep = pkg.devDependencies?.svelte ?? pkg.dependencies?.svelte;
Expand Down Expand Up @@ -140,12 +136,41 @@ export async function migrate() {
(dir) => fs.statSync(dir).isDirectory() && dir !== 'node_modules' && !dir.startsWith('.')
)
.map((dir) => ({ title: dir, value: dir, selected: true }))
.concat([
{
title: 'custom (overrides selection, allows to specify sub folders)',
value: ',', // a value that definitely isn't a valid folder name so it cannot clash
selected: false
}
])
});

if (p.isCancel(folders) || !folders?.length) {
process.exit(1);
}

if (folders.value.includes(',')) {
const custom = await prompts({
type: 'list',
name: 'value',
message: 'Specify folder paths (comma separated)'
});

if (!custom.value) {
process.exit(1);
}

folders.value = custom.value.map((/** @type {string} */ folder) => (folder = folder.trim()));
}

const do_migration = await prompts({
type: 'confirm',
name: 'value',
message:
'Do you want to use the migration tool to convert your Svelte components to the new syntax? (You can also do this per component or sub path later)',
initial: true
});

update_pkg_json();

const use_ts = fs.existsSync('tsconfig.json');
Expand All @@ -170,9 +195,11 @@ export async function migrate() {
for (const file of files) {
if (extensions.some((ext) => file.endsWith(ext))) {
if (svelte_extensions.some((ext) => file.endsWith(ext))) {
update_svelte_file(file, transform_module_code, (code) =>
transform_svelte_code(code, migrate, { filename: file, use_ts })
);
if (do_migration.value) {
update_svelte_file(file, transform_module_code, (code) =>
transform_svelte_code(code, migrate, { filename: file, use_ts })
);
}
} else {
update_js_file(file, transform_module_code);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-migrate",
"version": "1.7.0",
"version": "1.7.1",
"type": "module",
"description": "A CLI for migrating Svelte(Kit) codebases",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function getConfig(project) {
output: {
dir: outDir,
format: 'esm',
sourcemap: true
sourcemap: !process.env.CI
},
external,
plugins: [
Expand Down

0 comments on commit f34bb2f

Please sign in to comment.