-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Allow Custom templates to alias to an existing template engine (JSX, TS, TSX templates in Eleventy) #2248
Comments
I am willing to submit a PR for this if the maintainers are open to this suggestion. |
This idea from @zachleat seems like a great alternative as well https://twitter.com/zachleat/status/1473036576468918279. |
I am so sorry for the super-late reply here. This is almost possible today in Eleventy 1.x using current APIs: eleventyConfig.addExtension("11ty.tsx", {
key: "11ty.js",
read: false,
}); I don’t consider needing > build
> node --require esbuild-register node_modules/.bin/eleventy
[11ty] Writing _site/index.html from ./index.11ty.tsx
[11ty] Wrote 1 file in 0.03 seconds (v2.0.0-canary.18) There is one big problem, it isn’t fetching the data out of the file for the data cascade. I’m going to continue this one tomorrow, I think configuration-enabled aliasing will be useful so I don’t have to be the arbiter of these aliases moving forward. Aside, I do think it’s worthwhile to allow multiple aliases in a single command, so I added that to 2.0.0-canary.19: // v2.0.0-canary.19 or newer
eleventyConfig.addExtension([ "11ty.jsx", "11ty.ts", "11ty.tsx" ], {
key: "11ty.js"
}); |
Thanks!
That's what I was trying to solve for with this suggestion. |
Updated your gist with the new API: https://gist.github.com/zachleat/b274ee939759b032bc320be1a03704a2 |
Docs are building to https://www.11ty.dev/docs/languages/custom/#aliasing-an-existing-template-language This will ship with 2.0.0-canary.19 |
This is amazing, thanks! |
@pspeter3 I just gave this a try, works with I wrote a Vitest test for my component. Thought I would have to wedge the |
Official template syntax docs for TypeScript and JSX just shipped here: https://www.11ty.dev/docs/languages/jsx/ |
Is your feature request related to a problem? Please describe.
Allow users to run eleventy through Babel, TypeScript, ESBuild, or others without registering a custom template engine.
Describe the solution you'd like
Add
11ty.js
,11ty.ts
, and11ty.tsx
to the TemplateEngineManager. https://github.com/11ty/eleventy/blob/master/src/TemplateEngineManager.js#L26.Describe alternatives you've considered
Allow users to add entries to the extension map. This would also work just fine.
The text was updated successfully, but these errors were encountered: