Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support svelte 4 #948

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ manually.
<details>
<summary>Background</summary>

For `.svelte` single file components it uses the `svelte` (version 3.x)
For `.svelte` single file components it uses the `svelte` (version 4.x)

- which will be in your module dependencies if you're developing with Svelte.
- because of how svelte works, all `.svelte` files depend on `"svelte/internal"`.
Expand Down
143 changes: 139 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"proxyquire": "2.1.3",
"svelte": "3.59.1",
"svelte": "4.2.18",
"symlink-dir": "6.0.1",
"typescript": "5.5.3",
"upem": "9.0.4",
Expand Down Expand Up @@ -294,7 +294,7 @@
{
"package": "svelte",
"policy": "pin",
"because": "upgrading to supporting svelte 4 will require a non-trivial amount of labour (which we are going to invest, but not right now)"
"because": "upgrading to supporting svelte 5 will require a non-trivial amount of labour (which we are going to invest, but not right now)"
}
]
},
Expand All @@ -306,7 +306,7 @@
"coffee-script": ">=1.0.0 <2.0.0",
"coffeescript": ">=1.0.0 <3.0.0",
"livescript": ">=1.0.0 <2.0.0",
"svelte": ">=3.0.0 <4.0.0",
"svelte": ">=3.0.0 <5.0.0",
"swc": ">=1.0.0 <2.0.0",
"typescript": ">=2.0.0 <6.0.0",
"vue-template-compiler": ">=2.0.0 <3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/meta.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions test/extract/transpile/__fixtures__/svelte-too.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* generated by Svelte v3.59.1 */
/* generated by Svelte v4.2.18 */
import {
SvelteComponent,
append,
Expand All @@ -15,6 +15,7 @@ import {
transition_out,
} from "svelte/internal";

import "svelte/internal/disclose-version";
import "./page.css";
import Header from "./Header.svelte";

Expand All @@ -39,9 +40,7 @@ function create_fragment(ctx) {
create_component(header.$$.fragment);
t0 = space();
section = element("section");

section.innerHTML = `<h2>Pages in Storybook</h2>
<img src="./my.png" alt="my alt"/>`;
section.innerHTML = `<h2>Pages in Storybook</h2> <img src="./my.png" alt="my alt"/>`;
},
m(target, anchor) {
insert(target, article, anchor);
Expand All @@ -66,7 +65,10 @@ function create_fragment(ctx) {
current = false;
},
d(detaching) {
if (detaching) detach(article);
if (detaching) {
detach(article);
}

destroy_component(header);
},
};
Expand Down
12 changes: 7 additions & 5 deletions test/extract/transpile/__fixtures__/svelte.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* generated by Svelte v3.59.1 */
/* generated by Svelte v4.2.18 */
import {
SvelteComponent,
append,
Expand All @@ -15,6 +15,7 @@ import {
transition_out,
} from "svelte/internal";

import "svelte/internal/disclose-version";
import "./page.css";

function create_fragment(ctx) {
Expand All @@ -38,9 +39,7 @@ function create_fragment(ctx) {
create_component(header.$$.fragment);
t0 = space();
section = element("section");

section.innerHTML = `<h2>Pages in Storybook</h2>
<img src="./my.png" alt="my alt"/>`;
section.innerHTML = `<h2>Pages in Storybook</h2> <img src="./my.png" alt="my alt"/>`;
},
m(target, anchor) {
insert(target, article, anchor);
Expand All @@ -65,7 +64,10 @@ function create_fragment(ctx) {
current = false;
},
d(detaching) {
if (detaching) detach(article);
if (detaching) {
detach(article);
}

destroy_component(header);
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/extract/transpile/meta.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("[U] extract/transpile/meta", () => {
},
{
name: "svelte",
version: ">=3.0.0 <4.0.0",
version: ">=3.0.0 <5.0.0",
available: true,
},
{
Expand Down
1 change: 0 additions & 1 deletion test/extract/transpile/svelte-preprocess.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { equal } from "node:assert/strict";
// eslint-disable-next-line node/file-extension-in-import
import * as svelteCompiler from "svelte/compiler";
import normalizeNewline from "normalize-newline";
import thing from "#extract/transpile/typescript-wrap.mjs";
Expand Down