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

Choose js vs jsx #24

Open
DavidSSchwartz opened this issue Jun 20, 2023 · 3 comments
Open

Choose js vs jsx #24

DavidSSchwartz opened this issue Jun 20, 2023 · 3 comments

Comments

@DavidSSchwartz
Copy link

I'm working with Vite and it seems to not allow jsx in js files. I'd be happy to add, maybe an '-x' flag to create files as jsx.
I see an earlier version had something similar to this. Wondering if your open to putting something similar to what was (but more focused) back in.

@fsgreco
Copy link

fsgreco commented Mar 24, 2024

Hello @DavidSSchwartz I had the same problem, just fixed this in a fork of mine in case you're interested.
You can install it and try it by yourself by running:

npm i -D github:fsgreco/new-component

Then use npx new-component [component_name] from your project root.
This fork will always create a jsx file (since that's also broadly compatible with other circumstances)

Repo: https://github.com/fsgreco/new-component

This fork also has a sightly benefit that you can now give the name you want it will always convert it in PascalCase.
More details in this pull request: #27

(unfortunately I changed things and made a pull request before known that this project is not under active maintenance. So nowadays I just use my fork for new projects)

@jelly8173
Copy link

jelly8173 commented Apr 13, 2024

Maybe its a lack of documentation, but according to sources you can issue new-component -l jsx Something to create jsx files.

Also it is possible to create config file to make this setting persistent, like:

{
  "lang": "jsx"
}

@mohammadazeemwani
Copy link

As of now new-component doesn't provide any way to create components of .jsx extension.

but I recently forked this library and made some changes to achieve this:

if you have previously installed this library globally / at project level, uninstall it.

  1. run npm uninstall -g new-component to uninstall globally OR npm uninstall new-component to uninstall at project-level.

  2. run npm i -g github:mohammadazeemwani/new-component and it's done🎉

now you can add components traditionally as new-component NameOfComponent

Side Note
if you decided to use .js extension for some reasons, just add "fileExtenstion": "js" to your configuration file and it will set js extension providing you are using javascript as language

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

4 participants