Esbuild: Command line option to treat all files as .jsx?

Created on 9 Mar 2020  路  2Comments  路  Source: evanw/esbuild

As a curious developer,
In order to try out esbuild on an existing project,
I'd like to be able to run esbuild without first renaming a lot of files.

Given that the React projects I've seen so far used .js everywhere (because for .jsx other tools just didn't work), would a command line option be very bad? It could be named --accept-slowdown-treat-all-js-as-jsx :) or maybe just --jsx or something?

Most helpful comment

Yes, this is a good idea. I'm actually already planning on doing this. I'm planning to have a hard-coded set of loaders built into the executable, which can then be overridden per file extension. This is a more general-purpose mechanism that will also be helpful for other loaders. For example, you may want to have each .png file loaded as a base64 string. I'm not sure what the exact syntax will be yet.

All 2 comments

Yes, this is a good idea. I'm actually already planning on doing this. I'm planning to have a hard-coded set of loaders built into the executable, which can then be overridden per file extension. This is a more general-purpose mechanism that will also be helpful for other loaders. For example, you may want to have each .png file loaded as a base64 string. I'm not sure what the exact syntax will be yet.

So, for the parameter format, what are some options? Does any tool do this already? Is this something akin to a babel-ish preset? One cool approach could be ~--go,go,FILENAME-gadget~ ehm... --use=jsx and that goes and fetches from the git repo and caches jsx.esbuild.yml from then on. And the yml can contain various things. Too much too soon? :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frandiox picture frandiox  路  3Comments

vforsh picture vforsh  路  3Comments

tonyhb picture tonyhb  路  3Comments

qnp picture qnp  路  4Comments

ojanvafai picture ojanvafai  路  3Comments