-
Notifications
You must be signed in to change notification settings - Fork 305
Description
rel="rust": Trunk will compile the specified Cargo project as WASM and load it. This is optional. If not specified, Trunk will look for a Cargo.toml in the parent directory of the source HTML file.
Documentation says this is optional, but this actually changes the location of the script injection:
with it, the link tag itself is replaced with the script:
source html:
<html>
<head>
<link data-trunk rel="rust"/>
<link data-trunk rel="sass" href="index.scss" />
</head>
<body>
</body>
</html>generated:
<html>
<head>
<script type="module">
import init, * as bindings from '/assets/client-5455a487dd5da727.js';
const wasm = await init({ module_or_path: '/assets/client-5455a487dd5da727_bg.wasm' });
window.wasmBindings = bindings;
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
</script>
<link rel="stylesheet" href="/assets/index-232e1e25f4b6d090.css" integrity="sha384-oY/aFVIKfzgglyctp06MaZO9X8o4Dax0bXiA3yeBTd9kyUQa9vss/KYhEab3tmHm"/>
<link rel="modulepreload" href="/assets/client-5455a487dd5da727.js" crossorigin="anonymous" integrity="sha384-Rkwni3BMX5OTJjXck89V4myzDCsLcIyhLGIwZsEJZ4tVnHUOUJMuNEOfJ+1H+iYV"><link rel="preload" href="/assets/client-5455a487dd5da727_bg.wasm" crossorigin="anonymous" integrity="sha384-fxQtjXLrH7B5ZKln0m2g4Qrrh+kmxaE5uWM3+8vx9KY0S37U6cfXhWHUazWJX6B1" as="fetch" type="application/wasm"></head>
<body>
</body>
</html>without it, the script will be injected into the body:
before:
<html>
<head>
<link data-trunk rel="sass" href="index.scss" />
</head>
<body>
</body>
</html>before:
<html>
<head>
<link rel="stylesheet" href="/assets/index-232e1e25f4b6d090.css" integrity="sha384-oY/aFVIKfzgglyctp06MaZO9X8o4Dax0bXiA3yeBTd9kyUQa9vss/KYhEab3tmHm"/>
<link rel="modulepreload" href="/assets/client-5455a487dd5da727.js" crossorigin="anonymous" integrity="sha384-Rkwni3BMX5OTJjXck89V4myzDCsLcIyhLGIwZsEJZ4tVnHUOUJMuNEOfJ+1H+iYV"><link rel="preload" href="/assets/client-5455a487dd5da727_bg.wasm" crossorigin="anonymous" integrity="sha384-fxQtjXLrH7B5ZKln0m2g4Qrrh+kmxaE5uWM3+8vx9KY0S37U6cfXhWHUazWJX6B1" as="fetch" type="application/wasm"></head>
<body>
<script type="module">
import init, * as bindings from '/assets/client-5455a487dd5da727.js';
const wasm = await init({ module_or_path: '/assets/client-5455a487dd5da727_bg.wasm' });
window.wasmBindings = bindings;
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
</script></body>
</html>This has caused me hydration panics in a yew SSR project where during hydration the client side expects the first child in the body to be a comment string with the name of the App component yet it encountered this script tag.
It would be nice if the script placement can be consistent with or without the link tag