Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
A.svelte
B.svelte
<script>
import A from './A.svelte';
import B from './B.svelte';

let Thing = A;
</script>

<select bind:value={Thing}>
<option value={A}>A</option>
<option value={B}>B</option>
</select>

<!-- only one of these will update -->
<Thing />
<svelte:component this={Thing} />

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
/* App.svelte generated by Svelte v4.2.18 */
import {
SvelteComponent,
add_render_callback,
append,
check_outros,
construct_svelte_component,
create_component,
destroy_component,
detach,
element,
empty,
group_outros,
init,
insert,
listen,
mount_component,
safe_not_equal,
select_option,
select_value,
set_input_value,
space,
transition_in,
transition_out
} from "svelte/internal";

import "svelte/internal/disclose-version";
import A from './A.svelte';
import B from './B.svelte';

function create_fragment(ctx) {
let select;
let option0;
let option1;
let t2;
let thing;
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • {
    • html: Fragment {...}
      • start: 95
      • end: 276
      • type: "Fragment"
      • children: [...] (8)
        • Text {...}
          • start: 93
          • end: 95
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Element {...}
          • start: 95
          • end: 192
          • type: "Element"
          • name: "select"
          • attributes: [...] (1)
            • Binding {...}
              • start: 103
              • end: 121
              • type: "Binding"
              • name: "value"
              • modifiers: []
              • expression: Identifier {...}
                • type: "Identifier"
                • start: 115
                • end: 120
                • loc: {...}
                  • start: {...}
                    • line: 8
                    • column: 20
                    }
                  • end: {...}
                    • line: 8
                    • column: 25
                    }
                  }
                • name: "Thing"
                }
              }
            ]
          • children: [...] (5)
            • Text {...}
              • start: 122
              • end: 124
              • type: "Text"
              • raw: "\n\t"
              • data: "\n\t"
              }
            • Element {...}
              • start: 124
              • end: 152
              • type: "Element"
              • name: "option"
              • attributes: [...] (1)
                • Attribute {...}
                  • start: 132
                  • end: 141
                  • type: "Attribute"
                  • name: "value"
                  • value: [...] (1)
                    • MustacheTag {...}
                      • start: 138
                      • end: 141
                      • type: "MustacheTag"
                      • expression: Identifier {...}
                        • type: "Identifier"
                        • start: 139
                        • end: 140
                        • loc: {...}
                          • start: {...}
                            • line: 9
                            • column: 16
                            }
                          • end: {...}
                            • line: 9
                            • column: 17
                            }
                          }
                        • name: "A"
                        }
                      }
                    ]
                  }
                ]
              • children: [...] (1)
                • Text {...}
                  • start: 142
                  • end: 143
                  • type: "Text"
                  • raw: "A"
                  • data: "A"
                  }
                ]
              }
            • Text {...}
              • start: 152
              • end: 154
              • type: "Text"
              • raw: "\n\t"
              • data: "\n\t"
              }
            • Element {...}
              • start: 154
              • end: 182
              • type: "Element"
              • name: "option"
              • attributes: [...] (1)
                • Attribute {...}
                  • start: 162
                  • end: 171
                  • type: "Attribute"
                  • name: "value"
                  • value: [...] (1)
                    • MustacheTag {...}
                      • start: 168
                      • end: 171
                      • type: "MustacheTag"
                      • expression: Identifier {...}
                        • type: "Identifier"
                        • start: 169
                        • end: 170
                        • loc: {...}
                          • start: {...}
                            • line: 10
                            • column: 16
                            }
                          • end: {...}
                            • line: 10
                            • column: 17
                            }
                          }
                        • name: "B"
                        }
                      }
                    ]
                  }
                ]
              • children: [...] (1)
                • Text {...}
                  • start: 172
                  • end: 173
                  • type: "Text"
                  • raw: "B"
                  • data: "B"
                  }
                ]
              }
            • Text {...}
              • start: 182
              • end: 183
              • type: "Text"
              • raw: "\n"
              • data: "\n"
              }
            ]
          }
        • Text {...}
          • start: 192
          • end: 194
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Comment {...}
          • start: 194
          • end: 232
          • type: "Comment"
          • data: " only one of these will update "
          • ignores: []
          }
        • Text {...}
          • start: 232
          • end: 233
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • InlineComponent {...}
          • start: 233
          • end: 242
          • type: "InlineComponent"
          • name: "Thing"
          • attributes: []
          • children: []
          }
        • Text {...}
          • start: 242
          • end: 243
          • type: "Text"
          • raw: "\n"
          • data: "\n"
          }
        • InlineComponent {...}
          • start: 243
          • end: 276
          • type: "InlineComponent"
          • name: "svelte:component"
          • attributes: []
          • children: []
          • expression: Identifier {...}
            • type: "Identifier"
            • start: 267
            • end: 272
            • loc: {...}
              • start: {...}
                • line: 15
                • column: 24
                }
              • end: {...}
                • line: 15
                • column: 29
                }
              }
            • name: "Thing"
            }
          }
        ]
      }
    • css: undefined
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 93
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 84
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 6
            • column: 0
            }
          }
        • body: [...] (3)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 37
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 28
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 17
                • end: 18
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 8
                    }
                  • end: {...}
                    • line: 2
                    • column: 9
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 17
                  • end: 18
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 8
                      }
                    • end: {...}
                      • line: 2
                      • column: 9
                      }
                    }
                  • name: "A"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 24
              • end: 36
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 15
                  }
                • end: {...}
                  • line: 2
                  • column: 27
                  }
                }
              • value: "./A.svelte"
              • raw: "'./A.svelte'"
              }
            }
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 39
            • end: 66
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 28
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 46
                • end: 47
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 8
                    }
                  • end: {...}
                    • line: 3
                    • column: 9
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 46
                  • end: 47
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 8
                      }
                    • end: {...}
                      • line: 3
                      • column: 9
                      }
                    }
                  • name: "B"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 53
              • end: 65
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 15
                  }
                • end: {...}
                  • line: 3
                  • column: 27
                  }
                }
              • value: "./B.svelte"
              • raw: "'./B.svelte'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 69
            • end: 83
            • loc: {...}
              • start: {...}
                • line: 5
                • column: 1
                }
              • end: {...}
                • line: 5
                • column: 15
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 73
                • end: 82
                • loc: {...}
                  • start: {...}
                    • line: 5
                    • column: 5
                    }
                  • end: {...}
                    • line: 5
                    • column: 14
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 73
                  • end: 78
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 5
                      }
                    • end: {...}
                      • line: 5
                      • column: 10
                      }
                    }
                  • name: "Thing"
                  }
                • init: Identifier {...}
                  • type: "Identifier"
                  • start: 81
                  • end: 82
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 13
                      }
                    • end: {...}
                      • line: 5
                      • column: 14
                      }
                    }
                  • name: "A"
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      }
    • module: undefined
    }
The AST is not public API and may change at any point in time