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

Feature Request: <link data-trunk> dependency on other <link data-trunk rel=rust> #878

Open
LumaKernel opened this issue Sep 15, 2024 · 1 comment

Comments

@LumaKernel
Copy link

LumaKernel commented Sep 15, 2024

Description

<link data-trunk> is fetching the data which is existing before building of Rust resources. If Rust compilation creates the assets like stylesheet (for example, this is done by stylers, which is static stylesheet generator), they are not correctly loaded by Trunk as non-existent file, or fetching old one which is made by the last build, which cause the version mismatch.

error from build pipeline

Caused by:
    0: error getting canonical path for "/the-proj-dir/target/stylers/main.css"
    1: No such file or directory (os error 2)

Stylers officially offers the way for this by adding following post_build script, but this is intended for <link rel=stylesheet> without data-trunk, which is not tracked by Trunk and loaded dynamically. It's problematic. Cache wouldn't be busted in local development/production, and optimization is not done by Trunk.

[[hooks]]
stage = "post_build"
command = "sh"
command_arguments = ["-c", "cp ./target/stylers/main.css $TRUNK_STAGING_DIR/"]

The full entrypoint html is like following:

<!DOCTYPE html>
<html>
  <head>
    <link data-trunk rel="rust" data-bin="leptos" />
    <link data-trunk rel="css" href="target/stylers/main.css" />
  </head>
  <body></body>
</html>

Expected feature

I want the feature to specify the dependency of them, or just wait all asset fetching after Rust resources' builds.

First idea would look like following:

<!DOCTYPE html>
<html>
  <head>
    <link data-trunk rel="rust" data-bin="leptos" id="main" />
    <link data-trunk rel="css" href="target/stylers/main.css" data-depends="main" />
  </head>
  <body></body>
</html>

Not sure how can we treat that if there're multiple dependencies.

Second idea is simple, but not extensible.

@ctron
Copy link
Collaborator

ctron commented Sep 16, 2024

I agree that having a chain of internal build dependencies makes sense. However, this will be a bigger task, as trunk currently has no idea, other than the hard coded order of running processors.

I think it makes sense adding this to a more long-term roadmap. And I think the idea to represent this with the link element makes sense. I'd definitely like to consider this for a post 0.21.x release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants