Skip to content

Commit

Permalink
fix: support module script attribute
Browse files Browse the repository at this point in the history
fixes #2472
  • Loading branch information
dummdidumm committed Aug 22, 2024
1 parent 815a1ff commit fe60da4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/svelte2tsx/src/svelte2tsx/nodes/Scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export class Scripts {
if (
tag.attributes &&
tag.attributes.find(
(a) => a.name == 'context' && a.value.length == 1 && a.value[0].raw == 'module'
(a) =>
(a.name == 'context' &&
a.value.length == 1 &&
a.value[0].raw == 'module') ||
a.name === 'module'
)
) {
moduleScriptTag = tag;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
///<reference types="svelte" />
;
export function preload() {}
let b = 5;
;;function render() {

let world = "name"
;
async () => {

{ svelteHTML.createElement("h1", {}); world; }};
return { props: {world: world}, slots: {}, events: {} }}

export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(['world'], __sveltets_2_with_any_event(render()))) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export let world = "name"
</script>
<script module>
export function preload() {}
let b = 5;
</script>
<h1>hello {world}</h1>

0 comments on commit fe60da4

Please sign in to comment.