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

Add no-config support for jsx #751

Merged
merged 2 commits into from
Feb 10, 2018
Merged

Add no-config support for jsx #751

merged 2 commits into from
Feb 10, 2018

Conversation

sheeldotme
Copy link
Contributor

Parcel aims to be a zero configuration web application bundler yet it currently requires configuration for JSX support. This PR changes that.

For context:
@amPerl on slack stated:

do you mean automatically including react presets detecting jsx? in which case there might be other frameworks that use similar syntax with different presets (edited)

and my response was:

Great point @amPerl, the transform-react-jsx plugin actually allows you to define a custom jsx pragma as follows:

/** @jsxFrag DomFrag */

So in reality, one can use this adaptation with any library that utilizes jsx with no further configuration files required. If one does prefer to use a configuration file to override the pragma, of course that option is always available. So I really don't see the downside here, with considerable value for those who came looking for "zero configuration" which is what parcel promises.

If there's a different way you'd like to have this implemented let me know. If you have doubts that this should be included as part of parcel I'd love to hear your objections.

Thanks,

Sheel

@codecov-io
Copy link

codecov-io commented Feb 5, 2018

Codecov Report

Merging #751 into master will decrease coverage by 0.25%.
The diff coverage is 93.1%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #751      +/-   ##
==========================================
- Coverage   94.04%   93.79%   -0.26%     
==========================================
  Files          65       65              
  Lines        2151     2174      +23     
==========================================
+ Hits         2023     2039      +16     
- Misses        128      135       +7
Impacted Files Coverage Δ
src/assets/JSAsset.js 93.58% <ø> (ø) ⬆️
src/transforms/babel.js 93.39% <93.1%> (+1.82%) ⬆️
src/assets/CSSAsset.js 82.35% <0%> (-7.36%) ⬇️
src/WorkerFarm.js 91.52% <0%> (-1.7%) ⬇️
src/Logger.js 95.45% <0%> (-1.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 665e6b1...d313baf. Read the comment docs.

@devongovett
Copy link
Member

Awesome, thanks @sheeldotme! 🏆 I added a few tests.

I've also added support for JSX in normal .js files as well, including support for other react-like libraries like preact. Parcel looks for them in the package dependencies and sets the JSX pragma automatically. This only happens in application code, not in node_modules.

@devongovett devongovett merged commit 5e224bd into parcel-bundler:master Feb 10, 2018
devongovett pushed a commit that referenced this pull request Oct 15, 2018
* support no-config jsx

* Automatically enable JSX in normal .js files if react or preact are dependencies
devongovett pushed a commit that referenced this pull request Oct 15, 2018
* support no-config jsx

* Automatically enable JSX in normal .js files if react or preact are dependencies
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

Successfully merging this pull request may close these issues.

None yet

3 participants