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
<script>
import { innerWidth, innerHeight } from 'svelte/reactivity/window';
</script>

<div>
{innerWidth.current}x{innerHeight.current}px
</div>

<style>
div {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: max(1em, min(8vmin, 8em));
}
</style>

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
import "svelte/internal/disclose-version";
import "svelte/internal/flags/legacy";
import * as $ from "svelte/internal/client";
import { innerWidth, innerHeight } from 'svelte/reactivity/window';

var root = $.template(`<div class="svelte-gxwyc"> </div>`);

export default function App($$anchor, $$props) {
$.push($$props, false);
$.init();

var div = root();
var text = $.child(div);

$.reset(div);
$.template_effect(() => $.set_text(text, `${innerWidth.current ?? ""}x${innerHeight.current ?? ""}px`));
$.append($$anchor, div);
$.pop();
}
result = svelte.compile(source, {
generate: ,
});

div.svelte-gxwyc {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: max(1em, min(8vmin, 8em));
}

		
			
				
  • Root {
    • css: StyleSheet {...}
      • type: "StyleSheet"
      • start: 149
      • end: 313
      • attributes: []
      • children: [...] (1)
        • Rule {...}
          • type: "Rule"
          • prelude: SelectorList {...}
            • type: "SelectorList"
            • start: 158
            • end: 161
            • children: [...] (1)
              • ComplexSelector {...}
                • type: "ComplexSelector"
                • start: 158
                • end: 161
                • children: [...] (1)
                  • RelativeSelector {...}
                    • type: "RelativeSelector"
                    • combinator: null
                    • selectors: [...] (1)
                      • TypeSelector {...}
                        • type: "TypeSelector"
                        • name: "div"
                        • start: 158
                        • end: 161
                        }
                      ]
                    • start: 158
                    • end: 161
                    }
                  ]
                }
              ]
            }
          • block: Block {...}
            • type: "Block"
            • start: 162
            • end: 304
            • children: [...] (6)
              • Declaration {...}
                • type: "Declaration"
                • start: 166
                • end: 177
                • property: "width"
                • value: "100%"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 181
                • end: 193
                • property: "height"
                • value: "100%"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 197
                • end: 210
                • property: "display"
                • value: "flex"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 214
                • end: 233
                • property: "align-items"
                • value: "center"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 237
                • end: 260
                • property: "justify-content"
                • value: "center"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 264
                • end: 300
                • property: "font-size"
                • value: "max(1em, min(8vmin, 8em))"
                }
              ]
            }
          • start: 158
          • end: 304
          }
        ]
      • content: {...}
        • start: 156
        • end: 305
        • styles: "\n\tdiv {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tfont-size: max(1em, min(8vmin, 8em));\n\t}\n"
        • comment: null
        }
      }
    • js: []
    • start: 89
    • end: 147
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (3)
        • Text {...}
          • type: "Text"
          • start: 87
          • end: 89
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 89
          • end: 147
          • name: "div"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: -1
              • end: -1
              • name: "class"
              • value: [...] (1)
                • Text {...}
                  • type: "Text"
                  • data: "svelte-gxwyc"
                  • raw: "svelte-gxwyc"
                  • start: -1
                  • end: -1
                  }
                ]
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (5)
              • Text {...}
                • type: "Text"
                • start: 94
                • end: 96
                • raw: "\n\t"
                • data: "\n\t"
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 96
                • end: 116
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 97
                  • end: 115
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 2
                      }
                    • end: {...}
                      • line: 6
                      • column: 20
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 97
                    • end: 107
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 2
                        }
                      • end: {...}
                        • line: 6
                        • column: 12
                        }
                      }
                    • name: "innerWidth"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 108
                    • end: 115
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 13
                        }
                      • end: {...}
                        • line: 6
                        • column: 20
                        }
                      }
                    • name: "current"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 116
                • end: 117
                • raw: "x"
                • data: "x"
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 117
                • end: 138
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 118
                  • end: 137
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 23
                      }
                    • end: {...}
                      • line: 6
                      • column: 42
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 118
                    • end: 129
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 23
                        }
                      • end: {...}
                        • line: 6
                        • column: 34
                        }
                      }
                    • name: "innerHeight"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 130
                    • end: 137
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 35
                        }
                      • end: {...}
                        • line: 6
                        • column: 42
                        }
                      }
                    • name: "current"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 138
                • end: 141
                • raw: "px"
                • data: "px"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 147
          • end: 149
          • raw: "\n\n"
          • data: "\n\n"
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 87
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 78
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 3
            • column: 0
            }
          }
        • body: [...] (1)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 77
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 68
                }
              }
            • specifiers: [...] (2)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 29
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 20
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 29
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 20
                      }
                    }
                  • name: "innerWidth"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 29
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 20
                      }
                    }
                  • name: "innerWidth"
                  }
                }
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 31
                • end: 42
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 22
                    }
                  • end: {...}
                    • line: 2
                    • column: 33
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 31
                  • end: 42
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 22
                      }
                    • end: {...}
                      • line: 2
                      • column: 33
                      }
                    }
                  • name: "innerHeight"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 31
                  • end: 42
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 22
                      }
                    • end: {...}
                      • line: 2
                      • column: 33
                      }
                    }
                  • name: "innerHeight"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 50
              • end: 76
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 41
                  }
                • end: {...}
                  • line: 2
                  • column: 67
                  }
                }
              • value: "svelte/reactivity/window"
              • raw: "'svelte/reactivity/window'"
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time