Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init script location in index.html #72

Closed
MartinKavik opened this issue Oct 5, 2020 · 3 comments · Fixed by #73
Closed

Init script location in index.html #72

MartinKavik opened this issue Oct 5, 2020 · 3 comments · Fixed by #73
Assignees
Labels
assets Build pipelines for specific asset types

Comments

@MartinKavik
Copy link
Contributor

How can I change the init script location in index.html?
(Is it possible? Did I overlook something in README?)

Input:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>

<body>
    <section id="app"></section>
    <trunk-link type="rust">
</body>

</html>

(I've copy-pasted trunk-link from #46)

Expected output:

...
<body>
    <section id="app"></section>
    <script type="module">
      import init from '/index-719b4e04e016028b.js';
      init('/index-719b4e04e016028b_bg.wasm');
    </script>
</body>
...

Thanks!

@thedodd
Copy link
Member

thedodd commented Oct 6, 2020

Hey @MartinKavik! Excellent question. I've actually made really great progress on #46 and I'm getting close to being able to merge the code I've got so far to be able to start a clean implementation of the last bits of #46.

Any way, the syntax I've landed on is just a little different. I'll request for your review on the PR along with a few other folks just to get some feedback.


How can I change the init script location in index.html?

Right now the answer is: you can't :'( However, as I get closer to finishing up the PR that I'm currently hacking on, you will be able to specify things like that.

Essentially what the behavior will be is that as assets are processed, their HTML output will replace the HTML element which was responsible for spawning the pipeline. So if you declare your <link data-trunk rel="rust"/> link in the body (this is the syntax which I've pretty much landed on) then the output wasm/JS loader script will be placed in the body as well.

Hopefully that helps. I'll keep you posted as I move closer to finishing this up.

@thedodd
Copy link
Member

thedodd commented Oct 6, 2020

Yup, just tested this functionality out over on #73 and it works exactly as expected. Hopefully that code will land soon.

@thedodd
Copy link
Member

thedodd commented Oct 6, 2020

This will be closed by #73 once it lands.

@thedodd thedodd self-assigned this Oct 6, 2020
@thedodd thedodd added the assets Build pipelines for specific asset types label Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets Build pipelines for specific asset types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants