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

Support .hbs extensions for entry files #39

Open
alexlafroscia opened this issue Mar 23, 2021 · 5 comments
Open

Support .hbs extensions for entry files #39

alexlafroscia opened this issue Mar 23, 2021 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@alexlafroscia
Copy link
Owner

As far as I can tell, Vite makes a hard assumption that the file it starts to resolve linked files from is an HTML file. There is code I've seen internally that validates that the extension is .html.

It would be nice if we could use .hbs for these files, if we're going to have Handlebars syntax in them, just for the purposes of syntax highlighting and the like.

I'm not sure what allowing non-html files at the "top level" would look like, but it would be really nice to support!

@alexlafroscia alexlafroscia added the enhancement New feature or request label Mar 23, 2021
@alexlafroscia
Copy link
Owner Author

I've been looking into this, and I don't think it's possible. Rollup doesn't seem to support changing the id for a file while transforming it, and a bunch of logic within Vite seems to require the .html extension for the entry file.

I can successfully get the .hbs file at the top level through the Handlebars transform, but something within Vite (or maybe Rollup?) chokes on it after that; presumably because it's getting the wrong extension.

@alexlafroscia alexlafroscia added the help wanted Extra attention is needed label Mar 29, 2021
@Chris2011
Copy link

I now run in this problem :D. Of course I can fix it with changeing hbs from html but as you already said, it would be cool. Beside that, I didn't believe that this is possible, I googled just short and I found this: https://github.com/yohangz/rollup-plugin-hbs Could this be a solution?

@alexlafroscia
Copy link
Owner Author

Unfortunately, I don't think it is. That plugin defines a transform hook, which this plugin currently does not do, but certainly could!

I took a stab at implementing one to see if that would do the trick last week, but unfortunately it did not because I can't change the .hbs file extension to .html through the transform, and Vite is expecting that the "entry file" is an .html file (it's hard-coded in their code in some places that I've seen while looking through how Vite actually "works" under-the-hood).

It could be an issue worth raising on the Vite repo to see if we could somehow find a solution to this, though!

@Chris2011
Copy link

Chris2011 commented Apr 12, 2021

Maybe there could be a ticket created for hbs. I dunno whether there is a ticket yet. I googled a couple of days ago and all what I found was the rollup hbs plugin. @jdf221 thx for investigating :).

@Chris2011
Copy link

I saw the discussion in the vite repo. Is there anything new here? Do you think, your code is ready for a PR @jdf221 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants