Skip to content

Commit 0741ee6

Browse files
authored
chore: update acorn parser ecmaVersion to parse import attributes (#16098)
* bump acorn parser version * fix failing tests * lint
1 parent 2bbaaa3 commit 0741ee6

File tree

18 files changed

+41
-34
lines changed

18 files changed

+41
-34
lines changed

.changeset/brave-baboons-suffer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: update acorn parser `ecmaVersion` to parse import attributes

packages/svelte/src/compiler/phases/1-parse/acorn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function parse(source, typescript, is_script) {
3636
ast = parser.parse(source, {
3737
onComment,
3838
sourceType: 'module',
39-
ecmaVersion: 13,
39+
ecmaVersion: 16,
4040
locations: true
4141
});
4242
} finally {
@@ -64,7 +64,7 @@ export function parse_expression_at(source, typescript, index) {
6464
const ast = parser.parseExpressionAt(source, index, {
6565
onComment,
6666
sourceType: 'module',
67-
ecmaVersion: 13,
67+
ecmaVersion: 16,
6868
locations: true
6969
});
7070

packages/svelte/tests/parser-legacy/samples/action-duplicate/output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
"end": 20,
1616
"type": "Action",
1717
"name": "autofocus",
18-
"modifiers": [],
19-
"expression": null
18+
"expression": null,
19+
"modifiers": []
2020
},
2121
{
2222
"start": 21,
2323
"end": 34,
2424
"type": "Action",
2525
"name": "autofocus",
26-
"modifiers": [],
27-
"expression": null
26+
"expression": null,
27+
"modifiers": []
2828
}
2929
],
3030
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-call/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 39,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "CallExpression",
2120
"start": 21,
@@ -66,7 +65,8 @@
6665
}
6766
],
6867
"optional": false
69-
}
68+
},
69+
"modifiers": []
7070
}
7171
],
7272
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-identifier/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 28,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 20,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "message"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-literal/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 36,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Literal",
2120
"start": 21,
@@ -32,7 +31,8 @@
3231
},
3332
"value": "tooltip msg",
3433
"raw": "'tooltip msg'"
35-
}
34+
},
35+
"modifiers": []
3636
}
3737
],
3838
"children": []

packages/svelte/tests/parser-legacy/samples/action/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"end": 20,
1616
"type": "Action",
1717
"name": "autofocus",
18-
"modifiers": [],
19-
"expression": null
18+
"expression": null,
19+
"modifiers": []
2020
}
2121
],
2222
"children": []

packages/svelte/tests/parser-legacy/samples/animation/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"end": 50,
2121
"type": "Animation",
2222
"name": "flip",
23-
"modifiers": [],
24-
"expression": null
23+
"expression": null,
24+
"modifiers": []
2525
}
2626
],
2727
"children": [

packages/svelte/tests/parser-legacy/samples/attribute-class-directive/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 22,
1616
"type": "Class",
1717
"name": "foo",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 16,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "isFoo"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": []

packages/svelte/tests/parser-legacy/samples/attribute-with-whitespace/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 23,
1616
"type": "EventHandler",
1717
"name": "click",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 19,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "foo"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": [

0 commit comments

Comments
 (0)