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

Expose the template generator via a REST api #80

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

modmuss50
Copy link
Member

No description provided.

canvas: {
create(width, height) {
// Not implemented in Cloudflare Workers
throw new Error("Not implemented")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably reuse the one from the CLI.

@modmuss50
Copy link
Member Author

It seems that cloudflare workers dont allow the use of eval, this is used by ETA (the templating library we use). I dont see an immediate way around this.

It does also present an intresting attack vector for this if we do self host this.

@deirn
Copy link
Member

deirn commented Apr 6, 2024

I think it's possible to use Vite to precompile the eval into string templates.
https://github.com/storipress/unplugin-eta/ It's for Eta v2, but I don't think we necessarily need v3 features.

@modmuss50
Copy link
Member Author

Ohh intresting, thanks. It seems it uses ETA.compileToString to generate the code usually consumed via eval. Doing this at build would likely be a benefit everywhere this is ran.

@deirn
Copy link
Member

deirn commented Apr 7, 2024

Well, I tried it, doesn't seem to be working. Still spits out Function calls.
https://github.com/deirn/fabricmc.net/tree/precompile-eta

@deirn
Copy link
Member

deirn commented Apr 7, 2024

Eta v3's compile seems to guard the Function call, so it works fine here
https://github.com/deirn/fabricmc.net/tree/precompile-eta3
Custom made Vite plugin :P

@modmuss50
Copy link
Member Author

Eta v3's compile seems to guard the Function call, so it works fine here https://github.com/deirn/fabricmc.net/tree/precompile-eta3 Custom made Vite plugin :P

Thanks, I have cherry-picked this into my branch. Ill continune from here :)

@@ -1,4 +1,5 @@
{
"remoteUser": "node",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity, I changed the Dev Container to use the node user instead of root as it messes with the file permission on Linux host.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought it was to solve the warning that jekyll prints :) Solved 2 things at once 👍

scripts/vite.config.js Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

2 participants