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

@wordpress/scripts to be able to transpile .jsx files in addition to .js files #21009

Closed
cliffordp opened this issue Mar 19, 2020 · 6 comments · Fixed by #28002
Closed

@wordpress/scripts to be able to transpile .jsx files in addition to .js files #21009

cliffordp opened this issue Mar 19, 2020 · 6 comments · Fixed by #28002
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Tool] WP Scripts /packages/scripts [Type] Build Tooling Issues or PRs related to build tooling [Type] Enhancement A suggestion for improvement.

Comments

@cliffordp
Copy link
Contributor

Is your feature request related to a problem? Please describe.
.jsx files aren't processed by wordpress/scripts' webpack file, but .js files are.

Describe the solution you'd like
Is it as simple as changing https://github.com/WordPress/gutenberg/blob/v7.7.1/packages/scripts/config/webpack.config.js#L38

from:
test: /\.js$/,
to:
test: /\.jsx?$/,

Describe alternatives you've considered
I was playing around with this so much, I didn't isolate if the above code change would solve things, but it just might???

@talldan talldan added [Type] Build Tooling Issues or PRs related to build tooling [Type] Enhancement A suggestion for improvement. [Tool] WP Scripts /packages/scripts labels Mar 19, 2020
@talldan
Copy link
Contributor

talldan commented Mar 19, 2020

Hi @cliffordp. My understanding is that the jsx extension is not needed, but I realise there might be a preference for some to use that extension.

Another consideration is that WordPress might consider a coding standard around file extensions to keep things consistent across projects.

As this is a small change, it might be an idea to put together a PR with your proposal.

@cliffordp
Copy link
Contributor Author

I've chosen not to use wp/scripts for my build process, for other issues besides this, but if you want me to submit it, I surely will... just won't be dogfooding it. Let me know.

@gziolo
Copy link
Member

gziolo commented Mar 20, 2020

We don’t use .jsx extension for files in both Gutenberg and WordPress core. It’s something that is totally optional for many projects and needs extra configuration. In practice, it’s something that might become a challenge at scale when you refactor and you end up having files that no longer contain JSX and it forces you to rename the file or what’s even worse you forget to do so. It’s just simpler for the wider group of people to have one extension supported. I would be in favor of keeping things as is. It would require changes not only for the build script but to bring consistency also for:

  • format-js
  • lint-js
  • test-e2e
  • test-unit-js

It’s something you can raise for the WordPress Core JS meeting that happens every week (check https://make.wordpress.org/meetings/#core for the exact date) to validate with the wider group. I might be in the minority.

@gziolo gziolo added the Needs Decision Needs a decision to be actionable or relevant label Mar 20, 2020
@gziolo
Copy link
Member

gziolo commented Mar 25, 2020

It’s something you can raise for the WordPress Core JS meeting that happens every week (check https://make.wordpress.org/meetings/#core for the exact date) to validate with the wider group. I might be in the minority.

Actually, I did it already, see:
https://docs.google.com/document/d/1grsJXePI9Dd1R4Cz4Pou82ufIt5Ylx5E76lONyyHblQ/edit.

There is a similar proposal for JS formatting opened by @a6software in #21151.

@gziolo
Copy link
Member

gziolo commented Apr 10, 2020

Notes from the Core JS chat (https://make.wordpress.org/core/2020/04/06/javascript-chat-summary-march-31-2020/):

There is a small discussion about seeing if it is necessary to discourage or not jsx files. Noticing that changes to accept jsx are quite simple. And are even accepted in some code already. There are different opinions, so the team prefer to continue the discussion.

@gziolo gziolo modified the milestone: @wordpress/scripts v13 Dec 19, 2020
@gziolo gziolo removed the Needs Decision Needs a decision to be actionable or relevant label Jan 5, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 5, 2021
gziolo added a commit that referenced this issue Jan 5, 2021
@gziolo
Copy link
Member

gziolo commented Jan 5, 2021

Given that this proposal aligns with other commands that already work with .jsx:

  • format-js
  • lint-js
  • test-unit

I decided to open #28002 that implements it, mostly for consistency 😄

gziolo added a commit that referenced this issue Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Tool] WP Scripts /packages/scripts [Type] Build Tooling Issues or PRs related to build tooling [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants