Skip to content

Commit bb62915

Browse files
committed
feat: update svelte to 5.0.0-next.115 && minor refactor
1 parent 7c0861b commit bb62915

File tree

6 files changed

+488
-61
lines changed

6 files changed

+488
-61
lines changed

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
4848
},
4949
"peerDependencies": {
50-
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.112"
50+
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.115"
5151
},
5252
"peerDependenciesMeta": {
5353
"svelte": {
@@ -68,16 +68,16 @@
6868
"@ota-meshi/eslint-plugin": "^0.15.3",
6969
"@types/benchmark": "^2.1.5",
7070
"@types/chai": "^4.3.14",
71-
"@types/eslint": "^8.56.7",
71+
"@types/eslint": "^8.56.10",
7272
"@types/eslint-scope": "^3.7.7",
7373
"@types/eslint-visitor-keys": "^3.3.0",
7474
"@types/estree": "^1.0.5",
7575
"@types/mocha": "^10.0.6",
76-
"@types/node": "^20.12.5",
76+
"@types/node": "^20.12.7",
7777
"@types/semver": "^7.5.8",
78-
"@typescript-eslint/eslint-plugin": "^7.5.0",
79-
"@typescript-eslint/parser": "~7.7.0",
80-
"@typescript-eslint/types": "~7.7.0",
78+
"@typescript-eslint/eslint-plugin": "^7.7.1",
79+
"@typescript-eslint/parser": "~7.7.1",
80+
"@typescript-eslint/types": "~7.7.1",
8181
"benchmark": "^2.1.4",
8282
"chai": "^4.4.1",
8383
"env-cmd": "^10.1.0",
@@ -87,27 +87,27 @@
8787
"eslint-config-prettier": "^9.1.0",
8888
"eslint-plugin-eslint-comments": "^3.2.0",
8989
"eslint-plugin-json-schema-validator": "^5.1.0",
90-
"eslint-plugin-jsonc": "^2.15.0",
91-
"eslint-plugin-n": "^17.0.0",
90+
"eslint-plugin-jsonc": "^2.15.1",
91+
"eslint-plugin-n": "^17.3.1",
9292
"eslint-plugin-node-dependencies": "^0.12.0",
9393
"eslint-plugin-prettier": "^5.1.3",
94-
"eslint-plugin-regexp": "^2.4.0",
95-
"eslint-plugin-svelte": "^2.35.1",
94+
"eslint-plugin-regexp": "^2.5.0",
95+
"eslint-plugin-svelte": "^2.38.0",
9696
"eslint-plugin-yml": "^1.14.0",
9797
"estree-walker": "^3.0.3",
9898
"locate-character": "^3.0.0",
99-
"magic-string": "^0.30.9",
99+
"magic-string": "^0.30.10",
100100
"mocha": "^10.4.0",
101101
"mocha-chai-jest-snapshot": "^1.1.4",
102102
"nyc": "^15.1.0",
103103
"prettier": "~3.2.5",
104104
"prettier-plugin-pkg": "^0.18.1",
105-
"prettier-plugin-svelte": "^3.2.2",
105+
"prettier-plugin-svelte": "^3.2.3",
106106
"rimraf": "^5.0.5",
107107
"semver": "^7.6.0",
108-
"svelte": "^5.0.0-next.112",
109-
"svelte2tsx": "^0.7.6",
110-
"typescript": "~5.4.4",
108+
"svelte": "^5.0.0-next.115",
109+
"svelte2tsx": "^0.7.7",
110+
"typescript": "~5.4.5",
111111
"typescript-eslint-parser-for-extra-files": "^0.6.0"
112112
},
113113
"publishConfig": {

src/parser/compat.ts

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import type ESTree from "estree";
33
import type * as SvAST from "./svelte-ast-types";
44
import type * as Compiler from "svelte/compiler";
5-
import { parseAttributes } from "./html";
65

76
export type Child =
87
| Compiler.Text
@@ -31,16 +30,22 @@ export function getModuleFromRoot(
3130
}
3231
export function getOptionsFromRoot(
3332
svelteAst: Compiler.Root | SvAST.AstLegacy,
34-
code: string,
3533
): Compiler.SvelteOptionsRaw | null {
3634
const root = svelteAst as Compiler.Root;
3735
if (root.options) {
38-
if ((root.options as any).__raw__) {
39-
return (root.options as any).__raw__;
40-
}
41-
// If there is no `__raw__` property in the `SvelteOptions` node,
42-
// we will parse `<svelte:options>` ourselves.
43-
return parseSvelteOptions(root.options, code);
36+
return {
37+
type: "SvelteOptions",
38+
name: "svelte:options",
39+
attributes: root.options.attributes,
40+
fragment: {
41+
type: "Fragment",
42+
nodes: [],
43+
transparent: true,
44+
},
45+
start: root.options.start,
46+
end: root.options.end,
47+
parent: null as any,
48+
};
4449
}
4550
return null;
4651
}
@@ -239,40 +244,3 @@ export function getDeclaratorFromConstTag(
239244
(node as SvAST.ConstTag).expression
240245
);
241246
}
242-
243-
function parseSvelteOptions(
244-
options: Compiler.SvelteOptions,
245-
code: string,
246-
): Compiler.SvelteOptionsRaw {
247-
const { start, end } = options;
248-
const nameEndName = start + "<svelte:options".length;
249-
const { attributes, index: tagEndIndex } = parseAttributes(
250-
code,
251-
nameEndName + 1,
252-
);
253-
const fragment: Compiler.Fragment = {
254-
type: "Fragment",
255-
nodes: [],
256-
transparent: true,
257-
};
258-
if (code.startsWith(">", tagEndIndex)) {
259-
const childEndIndex = code.indexOf("</svelte:options", tagEndIndex);
260-
fragment.nodes.push({
261-
type: "Text",
262-
data: code.slice(tagEndIndex + 1, childEndIndex),
263-
start: tagEndIndex + 1,
264-
end: childEndIndex,
265-
raw: code.slice(tagEndIndex + 1, childEndIndex),
266-
parent: fragment,
267-
});
268-
}
269-
return {
270-
type: "SvelteOptions",
271-
name: "svelte:options",
272-
attributes,
273-
fragment,
274-
start,
275-
end,
276-
parent: null as any,
277-
};
278-
}

src/parser/converts/root.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function convertSvelteRoot(
4949
const fragment = getFragmentFromRoot(svelteAst);
5050
if (fragment) {
5151
let children = getChildren(fragment);
52-
const options = getOptionsFromRoot(svelteAst, ctx.code);
52+
const options = getOptionsFromRoot(svelteAst);
5353
if (options) {
5454
children = [...children];
5555
if (
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svelte:options runes={true} ></svelte:options>

0 commit comments

Comments
 (0)