gustavnikolaj / express-jsxtransform Goto Github PK
View Code? Open in Web Editor NEWExpress middleware that transforms jsx on the way out.
License: BSD 3-Clause "New" or "Revised" License
Express middleware that transforms jsx on the way out.
License: BSD 3-Clause "New" or "Revised" License
I think we need to hide the contents of this middleware behind a file extension check. I am getting this problem on a standard webpage, single index.html, single main.css and jquery:
✗ munter at pollex in ~/temp
$ livestyle -r app/ -p 9000 --autoprefixer --jsxtransform
Serving static files from /home/munter/temp/app
Listening to http://0.0.0.0:9000/
info - socket.io started
http.js:689
throw new Error('Can\'t set headers after they are sent.');
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:689:11)
at ServerResponse.res.setHeader (/home/munter/git/livestyle/node_modules/express/node_modules/connect/lib/patch.js:59:22)
at ServerResponse.<anonymous> (/home/munter/git/livestyle/node_modules/express-autoprefixer/lib/autoprefixer.js:40:25)
at ServerResponse.emit (events.js:92:17)
at /home/munter/git/livestyle/node_modules/express-processimage/node_modules/express-hijackresponse/lib/index.js:118:34
at process._tickCallback (node.js:419:13)
If I remove the --jsxtransform enabler things work out as expected:
✗ munter at pollex in ~/temp
$ livestyle -r app/ -p 9000 --autoprefixer
Serving static files from /home/munter/temp/app
Listening to http://0.0.0.0:9000/
info - socket.io started
While upgrading dependencies and testing one of our systems I found all calls were returning a Content-Type of text/javascript. The jsxtransform middleware appears to be doing this to all requests:
intercept: function (body, send) {
var annotationInserted = false;
if (res.statusCode === 200) {
// ...
res.setHeader('Content-Type', 'text/javascript');
res.setHeader('Content-Length', Buffer.byteLength(body));
send(body);
}
Am I missing something, or is this a bug?
Partial solution:
I have modified module.json to depend on v.0.13.1 of react-tools and things sort of work ok for me now. It looks like it's just the changes in syntax making some tests fail during npm install:
Thanks
J.
As I was made aware in Munter/generator-greenfield#3 facebook no longer uses the jsxtransform module, but babel for their jsx transpilation needs.
I'm no longer using this module myself, but I'll be happy to make changes to it, to move it forward. I just need some advice from actual users.
Would it make sense, to just wrap babel and use that for transpilation of just JSX - if it is even possible to configure babel to do that - or would a full blown babel transpiler be called for? Does it even make sense to do that?
I would love some suggestions on how to move it forward.
/cc @Munter
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.