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
stores.js
<script>
import { time } from './stores.js';

const formatter = new Intl.DateTimeFormat('en', {
hour12: true,
hour: 'numeric',
minute: '2-digit',
second: '2-digit'
});
</script>

<h1>The time is {formatter.format($time)}</h1>

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 { time } from './stores.js';

var root = $.template(`<h1> </h1>`);

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

const [$$stores, $$cleanup] = $.setup_stores();
const $time = () => $.store_get(time, '$time', $$stores);

const formatter = new Intl.DateTimeFormat('en', {
hour12: true,
hour: 'numeric',
minute: '2-digit',
second: '2-digit'
});

$.init();

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

$.reset(h1);
$.template_effect(($0) => $.set_text(text, `The time is ${$0 ?? ''}`), [() => formatter.format($time())], $.derived_safe_equal);
$.append($$anchor, h1);
$.pop();
$$cleanup();
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 190
    • end: 236
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 188
          • end: 190
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 190
          • end: 236
          • name: "h1"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (2)
              • Text {...}
                • type: "Text"
                • start: 194
                • end: 206
                • raw: "The time is "
                • data: "The time is "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 206
                • end: 231
                • expression: CallExpression {...}
                  • type: "CallExpression"
                  • start: 207
                  • end: 230
                  • loc: {...}
                    • start: {...}
                      • line: 12
                      • column: 17
                      }
                    • end: {...}
                      • line: 12
                      • column: 40
                      }
                    }
                  • callee: MemberExpression {...}
                    • type: "MemberExpression"
                    • start: 207
                    • end: 223
                    • loc: {...}
                      • start: {...}
                        • line: 12
                        • column: 17
                        }
                      • end: {...}
                        • line: 12
                        • column: 33
                        }
                      }
                    • object: Identifier {...}
                      • type: "Identifier"
                      • start: 207
                      • end: 216
                      • loc: {...}
                        • start: {...}
                          • line: 12
                          • column: 17
                          }
                        • end: {...}
                          • line: 12
                          • column: 26
                          }
                        }
                      • name: "formatter"
                      }
                    • property: Identifier {...}
                      • type: "Identifier"
                      • start: 217
                      • end: 223
                      • loc: {...}
                        • start: {...}
                          • line: 12
                          • column: 27
                          }
                        • end: {...}
                          • line: 12
                          • column: 33
                          }
                        }
                      • name: "format"
                      }
                    • computed: false
                    • optional: false
                    }
                  • arguments: [...] (1)
                    • Identifier {...}
                      • type: "Identifier"
                      • start: 224
                      • end: 229
                      • loc: {...}
                        • start: {...}
                          • line: 12
                          • column: 34
                          }
                        • end: {...}
                          • line: 12
                          • column: 39
                          }
                        }
                      • name: "$time"
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 188
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 179
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 10
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 45
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 36
                }
              }
            • specifiers: [...] (1)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 23
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 14
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "time"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "time"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 31
              • end: 44
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 22
                  }
                • end: {...}
                  • line: 2
                  • column: 35
                  }
                }
              • value: "./stores.js"
              • raw: "'./stores.js'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 48
            • end: 178
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 9
                • column: 4
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 54
                • end: 177
                • loc: {...}
                  • start: {...}
                    • line: 4
                    • column: 7
                    }
                  • end: {...}
                    • line: 9
                    • column: 3
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 54
                  • end: 63
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 7
                      }
                    • end: {...}
                      • line: 4
                      • column: 16
                      }
                    }
                  • name: "formatter"
                  }
                • init: NewExpression {...}
                  • type: "NewExpression"
                  • start: 66
                  • end: 177
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 19
                      }
                    • end: {...}
                      • line: 9
                      • column: 3
                      }
                    }
                  • callee: MemberExpression {...}
                    • type: "MemberExpression"
                    • start: 70
                    • end: 89
                    • loc: {...}
                      • start: {...}
                        • line: 4
                        • column: 23
                        }
                      • end: {...}
                        • line: 4
                        • column: 42
                        }
                      }
                    • object: Identifier {...}
                      • type: "Identifier"
                      • start: 70
                      • end: 74
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 23
                          }
                        • end: {...}
                          • line: 4
                          • column: 27
                          }
                        }
                      • name: "Intl"
                      }
                    • property: Identifier {...}
                      • type: "Identifier"
                      • start: 75
                      • end: 89
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 28
                          }
                        • end: {...}
                          • line: 4
                          • column: 42
                          }
                        }
                      • name: "DateTimeFormat"
                      }
                    • computed: false
                    • optional: false
                    }
                  • arguments: [...] (2)
                    • Literal {...}
                      • type: "Literal"
                      • start: 90
                      • end: 94
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 43
                          }
                        • end: {...}
                          • line: 4
                          • column: 47
                          }
                        }
                      • value: "en"
                      • raw: "'en'"
                      }
                    • ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 96
                      • end: 176
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 49
                          }
                        • end: {...}
                          • line: 9
                          • column: 2
                          }
                        }
                      • properties: [...] (4)
                        • Property {...}
                          • type: "Property"
                          • start: 100
                          • end: 112
                          • loc: {...}
                            • start: {...}
                              • line: 5
                              • column: 2
                              }
                            • end: {...}
                              • line: 5
                              • column: 14
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 100
                            • end: 106
                            • loc: {...}
                              • start: {...}
                                • line: 5
                                • column: 2
                                }
                              • end: {...}
                                • line: 5
                                • column: 8
                                }
                              }
                            • name: "hour12"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 108
                            • end: 112
                            • loc: {...}
                              • start: {...}
                                • line: 5
                                • column: 10
                                }
                              • end: {...}
                                • line: 5
                                • column: 14
                                }
                              }
                            • value: true
                            • raw: "true"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 116
                          • end: 131
                          • loc: {...}
                            • start: {...}
                              • line: 6
                              • column: 2
                              }
                            • end: {...}
                              • line: 6
                              • column: 17
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 116
                            • end: 120
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 2
                                }
                              • end: {...}
                                • line: 6
                                • column: 6
                                }
                              }
                            • name: "hour"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 122
                            • end: 131
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 8
                                }
                              • end: {...}
                                • line: 6
                                • column: 17
                                }
                              }
                            • value: "numeric"
                            • raw: "'numeric'"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 135
                          • end: 152
                          • loc: {...}
                            • start: {...}
                              • line: 7
                              • column: 2
                              }
                            • end: {...}
                              • line: 7
                              • column: 19
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 135
                            • end: 141
                            • loc: {...}
                              • start: {...}
                                • line: 7
                                • column: 2
                                }
                              • end: {...}
                                • line: 7
                                • column: 8
                                }
                              }
                            • name: "minute"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 143
                            • end: 152
                            • loc: {...}
                              • start: {...}
                                • line: 7
                                • column: 10
                                }
                              • end: {...}
                                • line: 7
                                • column: 19
                                }
                              }
                            • value: "2-digit"
                            • raw: "'2-digit'"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 156
                          • end: 173
                          • loc: {...}
                            • start: {...}
                              • line: 8
                              • column: 2
                              }
                            • end: {...}
                              • line: 8
                              • column: 19
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 156
                            • end: 162
                            • loc: {...}
                              • start: {...}
                                • line: 8
                                • column: 2
                                }
                              • end: {...}
                                • line: 8
                                • column: 8
                                }
                              }
                            • name: "second"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 164
                            • end: 173
                            • loc: {...}
                              • start: {...}
                                • line: 8
                                • column: 10
                                }
                              • end: {...}
                                • line: 8
                                • column: 19
                                }
                              }
                            • value: "2-digit"
                            • raw: "'2-digit'"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    ]
                  }
                }
              ]
            • kind: "const"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Readable stores • Playground • Svelte