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

Allow for custom file extensions #68

Open
slogsdon opened this issue Jun 18, 2018 · 2 comments
Open

Allow for custom file extensions #68

slogsdon opened this issue Jun 18, 2018 · 2 comments

Comments

@slogsdon
Copy link

Hello! Is there any interest supporting custom file extensions for components? Today, it seems like these are limited to .js, .jsx, and .mdx, but this prevents using languages that compile to JavaScript for these files. A less than ideal workaround exists where a simple JS file can be used to re-export the component (see below), but it would be fantastic if this workaround wasn't required.

Workaround example: Typescript

File ./components/component.tsx:

import * as React from "react";
const Component = () => <div>Example Component</div>;
export default Component;

File ./docs/component.js:

export default from "../components/component";

where x0 is invoked as x0 build docs.

@jxnblk
Copy link
Member

jxnblk commented Jun 19, 2018

Yeah, we've been looking into ways to handle this and using something like minimatch for file patterns – the biggest issue is the webpack's require.context has to have a static regex. We could require a context for all files, then filter based on the match, but I'd definitely want to do some light performance benchmarks to see what that's like.

Is the main thing you're looking for TypeScript support? If so, that'd be worth opening a new issue for as I'd like to add that as a feature

@slogsdon
Copy link
Author

slogsdon commented Jun 19, 2018

Yes, Typescript’s .tsx extension (required for JSX support) was the first one I tried, but another one that soon came to mind was for Vue’s .vue extension to support its single-file components.

I can open another issue specifically for Typescript if you’d like to go down that path and can also submit a PR to help out.

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